[BioPython] codons and complements
Jeffrey Chang
jchang@SMI.Stanford.EDU
Tue, 12 Oct 1999 10:22:41 -0700 (PDT)
> Next question should we use 'clever' translation ? (or greedy translation?)
> Synonymous codons, like CTA, CTT, CTG and gives Leucine(L). Should CTN
> (maybe from a sequencing error) recognize the codon family and translate
> CIN to L ?
Encoding "wobble" into the translator is an interesting idea.
I believe Andrew's scheme can currently handle this.
(stolen from Andrew's MarkMissingCodon example)
(sequence table information from NCBI:
ftp://ncbi.nlm.nih.gov/entrez/misc/data/seqcode.prt
)
class MarkAmbiguousCodon:
ambiguous_table = {"B" : ['G', 'T', 'C'],
"D" : ['G', 'A', 'T'],
...}
def __init__(self, codon_table):
self.data = codon_table
def __getitem__(self, key):
try:
return self.data[key]
except KeyError:
# Generate a list of all the possible codon resolutions.
# Check to make sure that they all encode the same amino acid.
# What happens if they don't?
class MarkAmbiguousTable:
def __init__(self, codon_table):
self.codon_table = MarkAmbiguousCodon(codon_table)
self.output_seq_constructor = ProteinSeq
translate(seq, MarkAmbiguousTable(seq.codon_table))
Jeff