Skip to content

Instantly share code, notes, and snippets.

@timyates
Created June 14, 2010 13:12
Show Gist options
  • Save timyates/437658 to your computer and use it in GitHub Desktop.
Save timyates/437658 to your computer and use it in GitHub Desktop.
(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"))
@jandot
Copy link

jandot commented Jun 14, 2010

@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