src/problems/prtm.lisp @ fc16ddecf261
Merge.
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 07 Nov 2018 20:38:33 -0500 |
parents |
8de2e6d7c9d9 |
children |
474d88a2af2e |
(in-package :rosalind)
(defconstant +monoisotopic-mass-of-water+ 18.01056d0
"The monoisotopic mass of a single water molecule, in Daltons.")
(defun monoisotopic-mass (residue)
;; todo is a hash table faster here? we could also do an array
;; starting at (char-code #\A) if we really wanted
(ecase residue
;; These have to be doubles or we get too much rounding error. It's fine.
(#\A 71.03711d0)
(#\C 103.00919d0)
(#\D 115.02694d0)
(#\E 129.04259d0)
(#\F 147.06841d0)
(#\G 57.02146d0)
(#\H 137.05891d0)
(#\I 113.08406d0)
(#\K 128.09496d0)
(#\L 113.08406d0)
(#\M 131.04049d0)
(#\N 114.04293d0)
(#\P 97.05276d0)
(#\Q 128.05858d0)
(#\R 156.10111d0)
(#\S 87.03203d0)
(#\T 101.04768d0)
(#\V 99.06841d0)
(#\W 186.07931d0)
(#\Y 163.06333d0)))
(define-problem prtm (data string)
"SKADYEK"
"821.392"
(-<> data
(delete #\newline <>)
(summation <> :key #'monoisotopic-mass)
(format nil "~,3F" <>)))