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]
 
__format__(self, format_spec)
Serialize the tree as a string in the specified file format.
source code
 
__init__(self, root=None, rooted=True, id=None, name=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__str__(self)
String representation of the entire tree.
source code
 
as_phyloxml(self, **kwargs)
Convert this tree to a PhyloXML-compatible Phylogeny.
source code
 
format(self, format)
Serialize the tree as a string in the specified file format.
source code
 
is_terminal(self)
True if the root of this tree is terminal.
source code
 
root_with_outgroup(self, outgroup_targets, *more_targets)
Reroot this tree with the outgroup clade containing outgroup_targets.
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]

__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. The format_spec should be a lower case string supported by Bio.Phylo.write as an output file format.

Overrides: object.__format__

__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)

__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__

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'.

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.

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.

root_with_outgroup(self, outgroup_targets, *more_targets)

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

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).