[BioPython] back translation
    Daniel Tomso 
    dtomso at athenixcorp.com
       
    Wed Sep 20 18:01:16 UTC 2006
    
    
  
Hello--
Here are some code bits, not in BioPython, but they will generate
degenerate nucleotide sequence from any amino acid sequence, given a
back translation table.  The first routine covers the degeneration, the
second just describes how I built the back translation table, but of
course you could use any similar structure.
Hope this helps, especially if there isn't an existing BioPython method.
Dan T.
def degenerate(self, aasequence, prefixes = ['']): # this is recursive
        """ Returns a list containing degenerate nucleic acid sequences
based on an amino acid sequence. """
        if len(aasequence) == 0:
            return prefixes
        else:          
            aa = aasequence[0]
            aasequence = aasequence[1:]
            newprefixes = []
            for prefix in prefixes:
                for codon in self.btable[aa]:
                    newprefixes.append(prefix + codon)
            return self.degenerate(aasequence, prefixes = newprefixes)
           
def build_btable(self):
        """ Builds a back-translation table for degenerate sequence
generation. """
        btable = {}
        for codon in self.ttable.keys():
            aa = self.aa(codon)
            if btable.has_key(aa): # single-letter aa
                btable[aa].append(codon)
            else:
                btable[aa] = [codon]
        return btable
Daniel J. Tomso
Senior Scientist, Bioinformatics
Athenix Corporation
2202 Ellis Road
Suite B
Durham, NC 27703
 
919.281.0920
dtomso at athenixcorp.com
www.athenixcorp.com
-----Original Message-----
From: biopython-bounces at lists.open-bio.org
[mailto:biopython-bounces at lists.open-bio.org] On Behalf Of Edoardo
Saccenti
Sent: Wednesday, September 20, 2006 1:51 PM
To: biopython at lists.open-bio.org
Subject: [BioPython] back translation
Hi Folks,
I'm wondering if there is a way using biopython to get ALL the possible
back translation of a given protein sequence.
Following the example on the cookbook I only get one DNA sequence!
I googled and I found this:
"""""
To get a list of all posible codons, replace
  for key in keys:
      back_table[table[key]] = key
with
  for key in keys:
      back_table[table[key]] = back_table.get(table[key], []) +
                               [key]
""""
I tried to modify but, of course, I get an error from the string package
Does anybod had to deal with this problem before?
Ciao
Edoardo 
_______________________________________________
BioPython mailing list  -  BioPython at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biopython
    
    
More information about the Biopython
mailing list