-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fasta-notes.lisp
49 lines (37 loc) · 1.26 KB
/
fasta-notes.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;;;; fasta-notes.lisp
(defpackage #:fasta-notes
(:use #:cl
#:fasta-notes.model)
(:export #:create-codon-models))
(in-package #:fasta-notes)
(defun nucleotide-list ()
'(A G T C))
(defun nucleotide-values ()
'(0 1 2 3))
(defun get-nucleotide-assocs ()
(pairlis (nucleotide-list) (nucleotide-values)))
(defun get-nucleotide-value (nucleotide)
(cdr (assoc (find-symbol (symbol-name nucleotide) 'fasta-notes) (get-nucleotide-assocs))))
(defun get-codon-values (codon)
(map 'list #'get-nucleotide-value codon))
(defun codon-value (codon)
(let ((val (get-codon-values codon)))
(cons
(reduce #'+ (butlast val))
(reduce #'+ (rest val)))))
(defun get-dur (int)
(nth int '(1 1/2 1/4 1/8 1/16 1/32 1/64 1/128)))
(defun stop-codon-p (codon)
(not (every #'null
(map 'list
#'(lambda (x) (equal codon x))
'((T G A) (T A G) (T A A))))))
(defun create-codon-model (codon)
(let ((val (codon-value codon)))
(if (stop-codon-p val)
(make-codon-note :is-pause t
:dur (get-dur (cdr val)))
(make-codon-note :degree (car val)
:dur (get-dur (cdr val))))))
(defun create-codon-models (codon-list)
(map 'list #'create-codon-model codon-list))