Source

rosalind / src / rosalind / p008.clj

Full commit
(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"))