src/problems/gc.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/gc (:use :cl :rosalind :losh :iterate))
(in-package :rosalind/gc)

(defparameter *input* ">Rosalind_6404
CCTGCGGAAGATCGGCACTAGAATAGCCAGAACCGTTTCTCTGAGGCTTCCGGCCTTCCC
TCCCACTAATAATTCTGAGG
>Rosalind_5959
CCATCGGTAGCGCATCCTTAGTCCAATTAAGTCCCTATCCAGGCGCTCCGCCGAAGGTCT
ATATCCATTTGTCAGCAGACACGC
>Rosalind_0808
CCACCCTCGTGGTATGGCTAGGCATTCAGGAACCGGAGAACGCTTCAGACCAGCCCGGAC
TGGGAACCTGCGGGCAGTAGGTGGAAT")

(defparameter *output* "Rosalind_0808
60.919540")


(define-problem gc (data stream) *input* *output*
  (labels ((gcp (base)
             (or (char= #\G base)
                 (char= #\C base)))
           (gc-content (string)
             (/ (count-if #'gcp string)
                (length string))))
    (iterate
      (for (label dna) :in-fasta data)
      (for gc = (gc-content dna))
      (finding (format nil "~A~%~,6F" label (* 100 gc))
               :maximizing gc))))