Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
11 additions
and
18 deletions.
-
+10
−17
src/rosalind/basics.clj
-
+1
−1
test/rosalind/basics_test.clj
|
|
@@ -1,24 +1,17 @@ |
|
|
(ns rosalind.basics) |
|
|
|
|
|
(defn dna-counter-fn |
|
|
"This actually does the counting" |
|
|
[dna cnt] |
|
|
(let [l (first dna) |
|
|
r (rest dna)] |
|
|
(case l |
|
|
\A (def h (assoc cnt :A (+ 1 (:A cnt)))) |
|
|
\G (def h (assoc cnt :G (+ 1 (:G cnt)))) |
|
|
\C (def h (assoc cnt :C (+ 1 (:C cnt)))) |
|
|
\T (def h (assoc cnt :T (+ 1 (:T cnt)))) |
|
|
nil) |
|
|
(if (empty? r) |
|
|
h |
|
|
(recur r h)))) |
|
|
|
|
|
(defn dna-count |
|
|
(defn count-dna |
|
|
"Counts DNA Neucleotides" |
|
|
[dna] |
|
|
(let [h (dna-counter-fn dna {:A 0 :C 0 :T 0 :G 0})] |
|
|
(let [h (reduce (fn [c base] |
|
|
(case base |
|
|
\A (assoc c :A (+ 1 (:A c))) |
|
|
\G (assoc c :G (+ 1 (:G c))) |
|
|
\C (assoc c :C (+ 1 (:C c))) |
|
|
\T (assoc c :T (+ 1 (:T c))) |
|
|
nil)) |
|
|
{:A 0 :C 0 :T 0 :G 0} |
|
|
dna)] |
|
|
[(:A h) (:C h) (:G h) (:T h)])) |
|
|
|
|
|
(defn transcribe-dna |
|
|
|
@@ -6,7 +6,7 @@ |
|
|
(testing "Counting DNA Nucleotides" |
|
|
(is (= |
|
|
[20 12 17 21] |
|
|
(dna-count "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")))) |
|
|
(count-dna "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")))) |
|
|
|
|
|
(testing "Transcribing DNA into RNA" |
|
|
(is (= "GAUGGAACUUGACUACGUAAAUU" |
|
|
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.