CONV, SPEC
author |
Steve Losh <steve@stevelosh.com> |
date |
Thu, 04 Aug 2022 22:30:18 -0400 |
parents |
86d92162dc1f |
children |
(none) |
(defpackage :rosalind/orf (:use :cl :rosalind :losh :iterate))
(in-package :rosalind/orf)
(defparameter *input*
">Rosalind_99
AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG")
(defparameter *output*
"M
MTPRLGLESLLE
MGMTPRLGLESLLE
MLLGSFRLIPKETLIQVAGSSPCNLS")
(defun translate-all (rna)
"Return all possible proteins that can be translated from `rna`."
(iterate
(for start :first 0 :then (1+ protein-start))
(for (values protein protein-start) = (u:translate rna :start start))
(while protein)
(collect protein)))
(define-problem orf (data stream) *input* *output*
(let* ((dna (cdr (first (u:read-fasta-into-alist data))))
(rna1 (u:transcribe dna))
(rna2 (u:transcribe (u:reverse-complement dna))))
(_ (append (translate-all rna1)
(translate-all rna2))
(remove-duplicates _ :test #'string=)
(sort _ #'< :key #'length)
(format nil "~{~A~^~%~}" _))))