Package Bio :: Package Phylo :: Module BaseTree :: Class Tree
[hide private]
[frames] | no frames]

Class Tree

source code

 object --+    
          |    
TreeElement --+
              |
 object --+   |
          |   |
  TreeMixin --+
              |
             Tree
Known Subclasses:

A phylogenetic tree, containing global info for the phylogeny.

The structure and node-specific data is accessible through the 'root' clade attached to the Tree instance.

Instance Methods [hide private]
 
__init__(self, root=None, rooted=True, id=None, name=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
as_phyloxml(self, **kwargs)
Convert this tree to a PhyloXML-compatible Phylogeny.
source code
 
root_with_outgroup(self, outgroup_targets, *more_targets, **kwargs)
Reroot this tree with the outgroup clade containing outgroup_targets.
source code
 
root_at_midpoint(self)
Root the tree at the midpoint of the two most distant taxa.
source code
 
is_terminal(self)
True if the root of this tree is terminal.
source code
 
__format__(self, format_spec)
Serialize the tree as a string in the specified file format.
source code
 
format(self, format)
Serialize the tree as a string in the specified file format.
source code
 
__str__(self)
String representation of the entire tree.
source code

Inherited from TreeElement: __repr__

Inherited from TreeMixin: collapse, collapse_all, common_ancestor, count_terminals, depths, distance, find_any, find_clades, find_elements, get_nonterminals, get_path, get_terminals, is_bifurcating, is_monophyletic, is_parent_of, is_preterminal, ladderize, prune, split, total_branch_length, trace

Inherited from TreeMixin (private): _filter_search

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

Class Methods [hide private]
 
from_clade(cls, clade, **kwargs)
Create a new Tree object given a clade.
source code
 
randomized(cls, taxa, branch_length=1.0, branch_stdev=None)
Create a randomized bifurcating tree given a list of taxa.
source code
Properties [hide private]
  clade
The first clade in this tree (not itself).

Inherited from object: __class__

Method Details [hide private]

__init__(self, root=None, rooted=True, id=None, name=None)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • root (Clade) - The starting node of the tree. If the tree is rooted, this will usually be the root node.
  • rooted (bool) - Whether or not the tree is rooted. By default, a tree is assumed to be rooted.
  • id (str) - The identifier of the tree, if there is one.
  • name (str) - The name of the tree, in essence a label.
Overrides: object.__init__
(inherited documentation)

from_clade(cls, clade, **kwargs)
Class Method

source code 

Create a new Tree object given a clade.

Keyword arguments are the usual Tree constructor parameters.

randomized(cls, taxa, branch_length=1.0, branch_stdev=None)
Class Method

source code 
Create a randomized bifurcating tree given a list of taxa.
Parameters:
  • taxa - Either an integer specifying the number of taxa to create (automatically named taxon#), or an iterable of taxon names, as strings.
Returns:
a tree of the same type as this class.

as_phyloxml(self, **kwargs)

source code 

Convert this tree to a PhyloXML-compatible Phylogeny.

This lets you use the additional annotation types PhyloXML defines, and save this information when you write this tree as 'phyloxml'.

root_with_outgroup(self, outgroup_targets, *more_targets, **kwargs)

source code 

Reroot this tree with the outgroup clade containing outgroup_targets.

Operates in-place.

Edge cases:

  • If outgroup == self.root, no change
  • If outgroup is terminal, create new bifurcating root node with a 0-length branch to the outgroup
  • If outgroup is internal, use the given outgroup node as the new trifurcating root, keeping branches the same
  • If the original root was bifurcating, drop it from the tree, preserving total branch lengths
Parameters:
  • outgroup_branch_length - length of the branch leading to the outgroup after rerooting. If not specified (None), then:

    • If the outgroup is an internal node (not a single terminal taxon), then use that node as the new root.
    • Otherwise, create a new root node as the parent of the outgroup.

root_at_midpoint(self)

source code 

Root the tree at the midpoint of the two most distant taxa.

This operates in-place, leaving a bifurcating root. The topology of the tree is otherwise retained, though no guarantees are made about the stability of clade/node/taxon ordering.

__format__(self, format_spec)

source code 

Serialize the tree as a string in the specified file format.

This method supports the format built-in function added in Python 2.6/3.0.

Parameters:
  • format_spec - a lower-case string supported by Bio.Phylo.write as an output file format.
Overrides: object.__format__

format(self, format)

source code 

Serialize the tree as a string in the specified file format.

This duplicates the __format__ magic method for pre-2.6 Pythons.

__str__(self)
(Informal representation operator)

source code 

String representation of the entire tree.

Serializes each sub-clade recursively using repr to create a summary of the object structure.

Overrides: object.__str__

Property Details [hide private]

clade

The first clade in this tree (not itself).
Get Method:
unreachable.clade(self) - The first clade in this tree (not itself).