File: make_codon_map.py

package info (click to toggle)
libqes 0.2.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,204 kB
  • sloc: ansic: 5,102; python: 56; sh: 29; makefile: 13
file content (21 lines) | stat: -rw-r--r-- 622 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from Bio.Data import CodonTable

nts = "ACGTU"

codon_tab = CodonTable.generic_by_name["Standard"].forward_table
print "char\ntranslate_codon(char *codon)\n{"
for a in nts:
    print "    else if (codon[0] == '%s') {" % a
    for b in nts:
        print "        else if (codon[1] == '%s') {" % b
        for c in nts:
            print "            else if (codon[2] == '%s')" % c ,
            codon = "".join((a,b,c))
            try:
                aa = codon_tab[codon]
            except KeyError:
                aa = "*"
            print "return '%s'" % aa
        print "         }"
    print "    }"
print "}"