# HG changeset patch # User Steve Losh # Date 1352743358 18000 # Node ID c025fc91d497690af582f24ce6003852fa717172 # Parent 7f4e6345e260add005f9cb983de4aed909f096bf Two more. diff -r 7f4e6345e260 -r c025fc91d497 project.clj --- a/project.clj Mon Nov 12 12:36:49 2012 -0500 +++ b/project.clj Mon Nov 12 13:02:38 2012 -0500 @@ -6,4 +6,4 @@ :dependencies [[org.clojure/clojure "1.4.0"] [the/parsatron "0.0.3"] [org.clojure/math.combinatorics "0.0.3"] - ]) + [roul "0.2.0"]]) diff -r 7f4e6345e260 -r c025fc91d497 src/rosalind/p007.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rosalind/p007.clj Mon Nov 12 13:02:38 2012 -0500 @@ -0,0 +1,27 @@ +(ns rosalind.p007 + (:require [clojure.string :as s])) + +(def sample "0.23 0.31 0.75") + +(defn content-probs [gcc] + (let [gc (/ gcc 2) + at (/ (- 1 gcc) 2)] + {:g gc + :c gc + :a at + :t at})) + +(defn chance-of-twice [prob] + (* prob prob)) + +(defn solve [s] + (let [gccs (map #(Float/parseFloat %) + (s/split (s/trim s) #"\s+"))] + (println (s/join " " + (for [gcc gccs] + (reduce + (map chance-of-twice + (vals (content-probs gcc))))))))) + +(solve sample) + +(solve (slurp "/Users/sjl/Downloads/rosalind_prob.txt")) diff -r 7f4e6345e260 -r c025fc91d497 src/rosalind/p008.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rosalind/p008.clj Mon Nov 12 13:02:38 2012 -0500 @@ -0,0 +1,84 @@ +(ns rosalind.p008 + (:require [clojure.string :as s])) + + +(def sample "AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA") + +(def acid + {"UUU" \F + "CUU" \L + "AUU" \I + "GUU" \V + "UUC" \F + "CUC" \L + "AUC" \I + "GUC" \V + "UUA" \L + "CUA" \L + "AUA" \I + "GUA" \V + "UUG" \L + "CUG" \L + "AUG" \M + "GUG" \V + "UCU" \S + "CCU" \P + "ACU" \T + "GCU" \A + "UCC" \S + "CCC" \P + "ACC" \T + "GCC" \A + "UCA" \S + "CCA" \P + "ACA" \T + "GCA" \A + "UCG" \S + "CCG" \P + "ACG" \T + "GCG" \A + "UAU" \Y + "CAU" \H + "AAU" \N + "GAU" \D + "UAC" \Y + "CAC" \H + "AAC" \N + "GAC" \D + "UAA" nil + "CAA" \Q + "AAA" \K + "GAA" \E + "UAG" nil + "CAG" \Q + "AAG" \K + "GAG" \E + "UGU" \C + "CGU" \R + "AGU" \S + "GGU" \G + "UGC" \C + "CGC" \R + "AGC" \S + "GGC" \G + "UGA" nil + "CGA" \R + "AGA" \R + "GGA" \G + "UGG" \W + "CGG" \R + "AGG" \R + "GGG" \G}) + + +(defn solve [s] + (println (->> s + s/trim + (partition 3) + (map s/join) + (map acid) + s/join))) + +(solve sample) + +(solve (slurp "/Users/sjl/Downloads/rosalind_prot.txt"))