Skip to content

Instantly share code, notes, and snippets.

@amonshiz
Created March 1, 2015 18:29
Show Gist options
  • Save amonshiz/b577a7987cc55f9c0947 to your computer and use it in GitHub Desktop.
Save amonshiz/b577a7987cc55f9c0947 to your computer and use it in GitHub Desktop.
import qualified Bioinformatics.Protein as P
import qualified Bioinformatics.RNANucleotide as R
import qualified Data.Map as M
codonRNATable = M.fromListWith (++) . map (\(k,v) -> (v, [k])) $ M.toList P.rnaCodonTable
codonLookup :: P.AminoAcid -> [R.RNAString]
codonLookup = maybe [] id . (flip M.lookup codonRNATable)
codonMappings :: [P.AminoAcid] -> [[R.RNAString]]
codonMappings cs = [codonLookup P.Stop] ++ map codonLookup cs
rnaCombinations :: [P.AminoAcid] -> Int
rnaCombinations = foldl (\acc rs -> acc * length rs `mod` 1000000) 1 . codonMappings
main = do
aaChars <- getLine
putStrLn . show . rnaCombinations $ map P.charToAminoAcid aaChars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment