Package Bio :: Package CodonAlign :: Module CodonAlignment' :: Class CodonAlignment
[hide private]
[frames] | no frames]

Class CodonAlignment

source code

             object --+        
                      |        
Align.Generic.Alignment --+    
                          |    
 Align.MultipleSeqAlignment --+
                              |
                             CodonAlignment

Codon Alignment class that inherits from MultipleSeqAlignment.

>>> from Bio.Alphabet import generic_dna
>>> from Bio.SeqRecord import SeqRecord
>>> from Bio.Alphabet import IUPAC, Gapped
>>> a = SeqRecord(CodonSeq("AAAACGTCG", alphabet=default_codon_alphabet), id="Alpha")
>>> b = SeqRecord(CodonSeq("AAA---TCG", alphabet=default_codon_alphabet), id="Beta")
>>> c = SeqRecord(CodonSeq("AAAAGGTGG", alphabet=default_codon_alphabet), id="Gamma")
>>> print(CodonAlignment([a, b, c]))
CodonAlphabet(Standard) CodonAlignment with 3 rows and 9 columns (3 codons)
AAAACGTCG Alpha
AAA---TCG Beta
AAAAGGTGG Gamma
Instance Methods [hide private]
 
__getitem__(self, index, alphabet=None)
Return a CodonAlignment object for single indexing
source code
 
__init__(self, records='', name=None, alphabet=CodonAlphabet(Standard))
Initialize a new MultipleSeqAlignment object.
source code
 
__str__(self)
Return a multi-line string summary of the alignment.
source code
 
get_aln_length(self) source code
 
get_dn_ds_matrix(self, method='NG86')
Available methods include NG86, LWL85, YN00 and ML.
source code
 
get_dn_ds_tree(self, dn_ds_method='NG86', tree_method='UPGMA')
Method for constructing dn tree and ds tree.
source code
 
toMultipleSeqAlignment(self)
Return a MultipleSeqAlignment containing all the SeqRecord in the CodonAlignment using Seq to store sequences
source code

Inherited from Align.MultipleSeqAlignment: __add__, add_sequence, append, extend, get_column, sort

Inherited from Align.MultipleSeqAlignment (private): _append

Inherited from Align.Generic.Alignment: __format__, __iter__, __len__, __repr__, format, get_alignment_length, get_all_seqs, get_seq_by_num

Inherited from Align.Generic.Alignment (private): _str_line

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]
 
from_msa(cls, align, alphabet=CodonAlphabet(Standard))
Function to convert a MultipleSeqAlignment to CodonAlignment.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__getitem__(self, index, alphabet=None)
(Indexing operator)

source code 

Return a CodonAlignment object for single indexing

Overrides: Align.Generic.Alignment.__getitem__

__init__(self, records='', name=None, alphabet=CodonAlphabet(Standard))
(Constructor)

source code 

Initialize a new MultipleSeqAlignment object.

Arguments:

  • records - A list (or iterator) of SeqRecord objects, whose sequences are all the same length. This may be an be an empty list.
  • alphabet - The alphabet for the whole alignment, typically a gapped alphabet, which should be a super-set of the individual record alphabets. If omitted, a consensus alphabet is used.
  • annotations - Information about the whole alignment (dictionary).

You would normally load a MSA from a file using Bio.AlignIO, but you can do this from a list of SeqRecord objects too:

>>> from Bio.Alphabet import generic_dna
>>> from Bio.Seq import Seq
>>> from Bio.SeqRecord import SeqRecord
>>> a = SeqRecord(Seq("AAAACGT", generic_dna), id="Alpha")
>>> b = SeqRecord(Seq("AAA-CGT", generic_dna), id="Beta")
>>> c = SeqRecord(Seq("AAAAGGT", generic_dna), id="Gamma")
>>> align = MultipleSeqAlignment([a, b, c], annotations={"tool": "demo"})
>>> print(align)
DNAAlphabet() alignment with 3 rows and 7 columns
AAAACGT Alpha
AAA-CGT Beta
AAAAGGT Gamma
>>> align.annotations
{'tool': 'demo'}

NOTE - The older Bio.Align.Generic.Alignment class only accepted a single argument, an alphabet. This is still supported via a backwards compatible "hack" so as not to disrupt existing scripts and users, but is deprecated and will be removed in a future release.

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

Return a multi-line string summary of the alignment.

This output is indicated to be readable, but large alignment is shown truncated. A maximum of 20 rows (sequences) and 60 columns (20 codons) are shown, with the record identifiers. This should fit nicely on a single screen. e.g.

Overrides: object.__str__

from_msa(cls, align, alphabet=CodonAlphabet(Standard))
Class Method

source code 

Function to convert a MultipleSeqAlignment to CodonAlignment. It is the user's responsibility to ensure all the requirement needed by CodonAlignment is met.

get_dn_ds_tree(self, dn_ds_method='NG86', tree_method='UPGMA')

source code 

Method for constructing dn tree and ds tree. Argument:

  • dn_ds_method - Available methods include NG86, LWL85, YN00 and ML.
  • tree_method - Available methods include UPGMA and NJ.