Package Bio :: Package Phylo :: Module TreeConstruction :: Class DistanceTreeConstructor
[hide private]
[frames] | no frames]

Class DistanceTreeConstructor

source code

     object --+    
              |    
TreeConstructor --+
                  |
                 DistanceTreeConstructor

Distance based tree constructor.

Example

>>> from TreeConstruction import DistanceTreeConstructor
>>> constructor = DistanceTreeConstructor()

UPGMA Tree:

>>> upgmatree = constructor.upgma(dm)
>>> print upgmatree
Tree(rooted=True)
    Clade(name='Inner4')
        Clade(branch_length=0.171955155115, name='Inner1')
            Clade(branch_length=0.111111111111, name='Epsilon')
            Clade(branch_length=0.111111111111, name='Delta')
        Clade(branch_length=0.0673103855608, name='Inner3')
            Clade(branch_length=0.0907558806655, name='Inner2')
                Clade(branch_length=0.125, name='Gamma')
                Clade(branch_length=0.125, name='Beta')
            Clade(branch_length=0.215755880666, name='Alpha')

NJ Tree:

>>> njtree = constructor.nj(dm)
>>> print njtree
Tree(rooted=False)
    Clade(name='Inner3')
        Clade(branch_length=0.0142054862889, name='Inner2')
            Clade(branch_length=0.239265540676, name='Inner1')
                Clade(branch_length=0.0853101915988, name='Epsilon')
                Clade(branch_length=0.136912030623, name='Delta')
            Clade(branch_length=0.292306275042, name='Alpha')
        Clade(branch_length=0.0747705106139, name='Beta')
        Clade(branch_length=0.175229489386, name='Gamma')
Instance Methods [hide private]
 
__init__(self, distance_calculator=None, method='nj')
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
build_tree(self, msa)
Caller to built the tree from a MultipleSeqAlignment object. This should be implemented in subclass
source code
 
upgma(self, distance_matrix)
Construct and return an UPGMA(Unweighted Pair Group Method with Arithmetic mean) tree.
source code
 
nj(self, distance_matrix)
Construct and return an Neighbor Joining tree.
source code
 
_height_of(self, clade)
calculate height of the clade -- the longest path to one of the terminals
source code

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

Class Variables [hide private]
  methods = ['nj', 'upgma']
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, distance_calculator=None, method='nj')
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • method (str) - Distance tree construction method, 'nj'(default) or 'upgma'.
  • distance_calculator (DistanceCalculator) - The distance matrix calculator for multiple sequence alignment. It must be provided if build_tree will be called.
Overrides: object.__init__
(inherited documentation)

build_tree(self, msa)

source code 
Caller to built the tree from a MultipleSeqAlignment object. This should be implemented in subclass
Overrides: TreeConstructor.build_tree
(inherited documentation)

upgma(self, distance_matrix)

source code 
Construct and return an UPGMA(Unweighted Pair Group Method with Arithmetic mean) tree.
Parameters:
  • distance_matrix (_DistanceMatrix) - The distance matrix for tree construction.

nj(self, distance_matrix)

source code 
Construct and return an Neighbor Joining tree.
Parameters:
  • distance_matrix (_DistanceMatrix) - The distance matrix for tree construction.