Skip to content

Instantly share code, notes, and snippets.

@amonshiz
Created March 10, 2015 04:37
Show Gist options
  • Save amonshiz/120713dd82e2c2283635 to your computer and use it in GitHub Desktop.
Save amonshiz/120713dd82e2c2283635 to your computer and use it in GitHub Desktop.
import qualified Bioinformatics.Protein as P
import qualified Data.Map as M
calculateProteinMass :: P.Protein -> Double
calculateProteinMass ps =
let masses = map getValue ps
getValue aa = maybe 0.0 id (M.lookup aa P.monoisotopicMasses)
in sum masses
main = do
aas <- getLine
putStrLn . show . calculateProteinMass $ map P.charToAminoAcid aas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment