Refactor to remove some boilerplate
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 23 Feb 2019 12:42:07 -0500 |
parents |
638d42c1ebe6 |
children |
2735aa6aab79 |
(in-package :rosalind)
(defparameter *input-gc* ">Rosalind_6404
CCTGCGGAAGATCGGCACTAGAATAGCCAGAACCGTTTCTCTGAGGCTTCCGGCCTTCCC
TCCCACTAATAATTCTGAGG
>Rosalind_5959
CCATCGGTAGCGCATCCTTAGTCCAATTAAGTCCCTATCCAGGCGCTCCGCCGAAGGTCT
ATATCCATTTGTCAGCAGACACGC
>Rosalind_0808
CCACCCTCGTGGTATGGCTAGGCATTCAGGAACCGGAGAACGCTTCAGACCAGCCCGGAC
TGGGAACCTGCGGGCAGTAGGTGGAAT")
(defparameter *output-gc* "Rosalind_0808
60.919540")
(define-problem gc (data stream)
*input-gc*
*output-gc*
(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))))
;; (problem-gc *input-gc*)
;; (solve gc)