src/problems/prob.lisp @ e3aefcbf364c

Cache Uniprot results on the filesystem

This will make only the first `(run-tests)` on a given computer take forever,
instead of the first `(run-tests)` of a given Lisp session.  It will also
hopefully make the Uniprot folks not hate me.
author Steve Losh <steve@stevelosh.com>
date Fri, 24 Jan 2020 23:05:16 -0500
parents 2735aa6aab79
children (none)
(defpackage :rosalind/prob (:use :cl :rosalind :losh :iterate))
(in-package :rosalind/prob)

(defparameter *input*
  "ACGATACAA
0.129 0.287 0.423 0.476 0.641 0.742 0.783")

(defparameter *output*
  "-5.737 -5.217 -5.263 -5.360 -5.958 -6.628 -7.009")


(define-problem prob (data stream) *input* *output*
  (let ((dna (read-line data))
        (gc-contents (read-all-from-string (read-line data))))
    (flet ((prob (gc-content)
             (iterate
               (for base :in-string dna)
               (summing (log (u:base-probability gc-content base) 10)))))
      (u:float-string (mapcar #'prob gc-contents)))))