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

Class ParsimonyTreeConstructor

source code

     object --+    
              |    
TreeConstructor --+
                  |
                 ParsimonyTreeConstructor

Parsimony tree constructor.

Example

>>> from Bio import AlignIO
>>> from TreeConstruction import *
>>> aln = AlignIO.read(open('Tests/TreeConstruction/msa.phy'), 'phylip')
>>> print aln
SingleLetterAlphabet() alignment with 5 rows and 13 columns
AACGTGGCCACAT Alpha
AAGGTCGCCACAC Beta
GAGATTTCCGCCT Delta
GAGATCTCCGCCC Epsilon
CAGTTCGCCACAA Gamma
>>> starting_tree = Phylo.read('Tests/TreeConstruction/nj.tre', 'newick')
>>> print tree
Tree(weight=1.0, rooted=False)
    Clade(branch_length=0.0, name='Inner3')
        Clade(branch_length=0.01421, name='Inner2')
            Clade(branch_length=0.23927, name='Inner1')
                Clade(branch_length=0.08531, name='Epsilon')
                Clade(branch_length=0.13691, name='Delta')
            Clade(branch_length=0.29231, name='Alpha')
        Clade(branch_length=0.07477, name='Beta')
        Clade(branch_length=0.17523, name='Gamma')
>>> from TreeConstruction import *
>>> scorer = ParsimonyScorer()
>>> searcher = NNITreeSearcher(scorer)
>>> constructor = ParsimonyTreeConstructor(searcher, starting_tree)
>>> pars_tree = constructor.build_tree(aln)
>>> print pars_tree
Tree(weight=1.0, rooted=True)
    Clade(branch_length=0.0)
        Clade(branch_length=0.197335, name='Inner1')
            Clade(branch_length=0.13691, name='Delta')
            Clade(branch_length=0.08531, name='Epsilon')
        Clade(branch_length=0.041935, name='Inner2')
            Clade(branch_length=0.01421, name='Inner3')
                Clade(branch_length=0.17523, name='Gamma')
                Clade(branch_length=0.07477, name='Beta')
            Clade(branch_length=0.29231, name='Alpha')
Instance Methods [hide private]
 
__init__(self, searcher, starting_tree=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
build_tree(self, alignment)
Caller to built the tree from a MultipleSeqAlignment object. This should be implemented in subclass
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, searcher, starting_tree=None)
(Constructor)

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

Parameters:
  • searcher, TreeSearcher - tree searcher to search the best parsimony tree.
  • starting_tree, Tree - starting tree provided to the searcher.
Overrides: object.__init__
(inherited documentation)

build_tree(self, alignment)

source code 
Caller to built the tree from a MultipleSeqAlignment object. This should be implemented in subclass
Parameters:
  • alignment, MultipleSeqAlignment - multiple sequence alignment to calculate parsimony tree.
Overrides: TreeConstructor.build_tree