biopython v1.71.0 Bio.Phylo.BaseTree.Tree

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.

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

Link to this section Summary

Functions

Serialize the tree as a string in the specified file format

Initialize parameter for phylogenetic tree

String representation of the entire tree

Convert this tree to a PhyloXML-compatible Phylogeny

The first clade in this tree (not itself)

Serialize the tree as a string in the specified file format

Create a new Tree object given a clade

True if the root of this tree is terminal

Recursively serialize sub-elements

Create a randomized bifurcating tree given a list of taxa

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

Reroot this tree with the outgroup clade containing outgroup_targets

Link to this section Functions

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.

:param format_spec: a lower-case string supported by Bio.Phylo.write

as an output file format.

Initialize parameter for phylogenetic tree.

String representation of the entire tree.

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

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

The first clade in this tree (not itself).

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

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

Create a new Tree object given a clade.

Keyword arguments are the usual Tree constructor parameters.

True if the root of this tree is terminal.

Create a randomized bifurcating tree given a list of taxa.

:param taxa: Either an integer specifying the number of taxa to create

(automatically named taxon
strings.

:returns: a tree of the same type as this class.

Link to this function root_at_midpoint()

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.

Link to this function root_with_outgroup()

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

:param 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.