Created
June 14, 2010 13:12
-
-
Save timyates/437658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user) | |
(defn- reverse-base [base] | |
(let [mapping { :A \T :T \A :G \C :C \G } | |
key (keyword (.toString base))] | |
(key mapping))) | |
(defn reverse-complement [sequence] | |
(let [rev-seq (reverse (.toUpperCase sequence))] | |
(map reverse-base rev-seq))) | |
(println "Reverse complement gives" (reverse-complement "TGAC")) |
@wmacgyver: This is the code that we're trying to get going:
(ns bio)
(defn reverse-str
"Reverse a string"
[s]
(apply str (reverse s))
)
(defn complement
"Complement a base"
[base]
(let [mapping { :A \T :T \A :G \C :C \G }
key (keyword (.toString base))]
(key mapping)))
)
(println bio/complement (bio/reverse-str "TGACC"))
Output should be: "GGTCA"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for that link. Does help to clear it up at least a little bit for me. Trouble is that the core 'complement' cannot be easily accessed then (apart from prepending "clojure.core/"). Would be nice if we could say:
(println bio/complement(bio/reverse-str "TGACC"))
i.e. adding "bio" in front.