src/problems/spec.lisp @ cd3fc11e3298
CONV, SPEC
author |
Steve Losh <steve@stevelosh.com> |
date |
Thu, 04 Aug 2022 22:30:18 -0400 |
parents |
(none) |
children |
7fcd748a4f00 |
(defpackage :rosalind/spec (:use :cl :rosalind :losh :iterate))
(in-package :rosalind/spec)
(defparameter *input* "3524.8542
3710.9335
3841.974
3970.0326
4057.0646")
(defparameter *output* "WMQS")
(defun roughly= (a b &optional (epsilon (* 0.000001d0 (min a b))))
(< (abs (- a b)) epsilon))
(defun find-amino-acid (weight)
(rassocar weight u:*monoisotopic-masses* :test #'roughly=))
(define-problem spec (data stream) *input* *output*
(let* ((*read-default-float-format* 'double-float)
(prefix-weights (u:read-lines data :key #'parse-float:parse-float))
(weights (mapcar #'- (rest prefix-weights) prefix-weights))
(result (mapcar #'find-amino-acid weights)))
(string-join "" result)))