Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Static Public Attributes
Bio.Data.CodonTable.CodonTable Class Reference
Inheritance diagram for Bio.Data.CodonTable.CodonTable:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def __str__

Public Attributes

 forward_table
 back_table
 start_codons
 stop_codons

Static Public Attributes

 nucleotide_alphabet = Alphabet.generic_nucleotide
 protein_alphabet = Alphabet.generic_protein
dictionary forward_table = {}
dictionary back_table = {}
list start_codons = []
list stop_codons = []

Detailed Description

Definition at line 41 of file CodonTable.py.


Constructor & Destructor Documentation

def Bio.Data.CodonTable.CodonTable.__init__ (   self,
  nucleotide_alphabet = nucleotide_alphabet,
  protein_alphabet = protein_alphabet,
  forward_table = forward_table,
  back_table = back_table,
  start_codons = start_codons,
  stop_codons = stop_codons 
)

Definition at line 53 of file CodonTable.py.

00053 
00054                  start_codons = start_codons, stop_codons = stop_codons):
00055         self.nucleotide_alphabet = nucleotide_alphabet
00056         self.protein_alphabet = protein_alphabet
00057         self.forward_table = forward_table
00058         self.back_table = back_table
00059         self.start_codons = start_codons
00060         self.stop_codons = stop_codons

Here is the caller graph for this function:


Member Function Documentation

Returns a simple text representation of the codon table

e.g.
>>> import Bio.Data.CodonTable
>>> print Bio.Data.CodonTable.standard_dna_table
>>> print Bio.Data.CodonTable.generic_by_id[1]

Definition at line 61 of file CodonTable.py.

00061 
00062     def __str__(self):
00063         """Returns a simple text representation of the codon table
00064 
00065         e.g.
00066         >>> import Bio.Data.CodonTable
00067         >>> print Bio.Data.CodonTable.standard_dna_table
00068         >>> print Bio.Data.CodonTable.generic_by_id[1]
00069         """
00070 
00071         if self.id:
00072             answer = "Table %i" % self.id
00073         else:
00074             answer = "Table ID unknown"
00075         if self.names:
00076             answer += " " + ", ".join(filter(None, self.names))
00077 
00078         #Use the main four letters (and the conventional ordering)
00079         #even for ambiguous tables
00080         letters = self.nucleotide_alphabet.letters
00081         if isinstance(self.nucleotide_alphabet, Alphabet.DNAAlphabet) \
00082         or (letters is not None and "T" in letters):
00083             letters = "TCAG"
00084         else:
00085             #Should be either RNA or generic nucleotides,
00086             #e.g. Bio.Data.CodonTable.generic_by_id[1]
00087             letters = "UCAG"
00088 
00089         #Build the table...
00090         answer=answer + "\n\n  |" + "|".join( \
00091             ["  %s      " % c2 for c2 in letters] \
00092             ) + "|"
00093         answer=answer + "\n--+" \
00094                + "+".join(["---------" for c2 in letters]) + "+--"
00095         for c1 in letters:
00096             for c3 in letters:
00097                 line = c1 + " |"
00098                 for c2 in letters:
00099                     codon = c1+c2+c3
00100                     line = line + " %s" % codon
00101                     if codon in self.stop_codons:
00102                         line = line + " Stop|"
00103                     else:
00104                         try:
00105                             amino = self.forward_table[codon]
00106                         except KeyError:
00107                             amino = "?"
00108                         except TranslationError:
00109                             amino = "?"
00110                         if codon in self.start_codons:
00111                             line = line + " %s(s)|" % amino
00112                         else:
00113                             line = line + " %s   |" % amino
00114                 line = line + " " + c3
00115                 answer = answer + "\n"+ line 
00116             answer=answer + "\n--+" \
00117                   + "+".join(["---------" for c2 in letters]) + "+--"
00118         return answer
            

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 46 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 57 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 45 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 56 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 43 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 47 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 58 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 48 of file CodonTable.py.

Reimplemented in Bio.Data.CodonTable.NCBICodonTable.

Definition at line 59 of file CodonTable.py.


The documentation for this class was generated from the following file: