Last active
December 21, 2015 07:48
-
-
Save erasmas/6273272 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
(use 'clojure.java.io) | |
(defn read-lines [file] | |
(with-open [rdr (reader file)] | |
(doall (line-seq rdr)))) | |
(defn dna-reverse-complement [dna] | |
"Takes a DNA string and returns it's reverse complement" | |
(apply str (map (fn [x] | |
(cond | |
(= x \A) \T | |
(= x \T) \A | |
(= x \G) \C | |
(= x \C) \G | |
:else x)) | |
(reverse dna)))) | |
(defn dna-reverse-complement2 [s] | |
(let [reversed-dna (reverse s) | |
pairs {\T \A, \A \T, \G \C, \C \G}] | |
(apply str (map pairs reversed-dna)))) | |
(defn hamming-distance [s t] | |
(reduce + (map #(if (= % %2) 0 1) s t))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment