Phylogenetic tree structure encapsulation; allow rearrangement of said structure. Tree rearrangements inducing other topologies include Nearest Neighbor Interchange (NNI), Subtree Pruning and Regrafting (SPR), and Tree Bisection and Reconstruction (TBR). Each of these describe a transfer of one node in phylogenetic trees from one parent of a tree to a new parent. Respectively, these operators describe transformations that are subsets of those possible by the successive operator. For example, an NNI operator can perform transformations that are a subset of the transformations possible by the SPR operator.
Encapsulates a single rearrangement move of type SPR, NNI, ...
Initialize by providing a pointer to a base topology, a target branch to be moved, and its destination.
| Parameters: |
|
|---|
Bases: pylogeny.base.treeStructure
Encapsulate a tree topology, wrapping the newick tree structure as a richer, rooted tree data structure object. Is immutable.
Perform an NNI move of a branch to a destination, only if that destination branch is a parent’s parent or a parent’s sibling. Returns a rearrangement structure (not the actual new structure) that can then be polled for the actual move; this is in order to save memory.
| Returns: | a rearrangement object |
|---|
Perform an SPR move of a branch to a destination branch, creating a new node there. Returns a rearrangement structure (not the actual new structure) that can then be polled for the actual move; this is in order to save memory.
| Returns: | a rearrangement object |
|---|
Initialize structure with a top-level internal node OR nothing.
| Parameters: |
|
|---|
Consider all valid NNI moves for a given topology and return all possible rearrangements.
| Returns: | a list of rearrangement objects |
|---|
Consider all valid NNI moves for a given branch in the topology and return all possible rearrangements.
| Returns: | a list of rearrangement objects |
|---|
Consider all valid SPR moves for a given topology and return all possible rearrangements.
| Returns: | a list of rearrangement objects |
|---|
Consider all valid SPR moves for a given branch in the topology and return all possible rearrangements.
| Returns: | a list of rearrangement objects |
|---|
Consider all valid moves of a given rearrangement operator for a given topology. Uses a given rearrangement operator type defined in this module. For example, calling this function by providing TYPE_NNI as the type will iterate over all NNI operations. By default, the type is TYPE_SPR.
| Returns: | a list of rearrangement objects |
|---|
Get all bipartitions.
| Returns: | a list of tree.bipartition objects |
|---|
Given a bipartition object, return a branch that creates that partition of taxa.
| Parameters: | bip (a tree.bipartition object) – a bipartition |
|---|---|
| Returns: | a newick.branch object |
Given a bipartition of taxa, return a branch that creates that partition of tree taxa.
| Parameters: | bip – a tuple of taxa names |
|---|---|
| Returns: | a newick.branch object |
Return all branches from this topology.
| Returns: | a list of newick.branch objects |
|---|
Return all leaves from this topology.
| Returns: | a list of newick.node objects |
|---|
Given a branch, return corresponding bipartition.
| Parameters: | br (a newick.branch object) – a branch |
|---|---|
| Returns: | a tree.bipartition object |
Consider all valid NNI moves for a given branch in the topology and and yield all possible rearrangements as a generator.
| Returns: | a generator of rearrangement objects |
|---|
Consider all valid SPR moves for a given branch in the topology and yield all possible rearrangements as a generator.
| Returns: | a generator of rearrangement objects |
|---|
Iterate over all possible rearrangements for a branch using a given rearrangement operator type defined in this module. For example, calling this function by providing TYPE_NNI as the type will iterate over all NNI operations. By default, the type is TYPE_SPR.
Given a branch, lock it such that no transitions can ever occur across it.
| Parameters: | branch (a newick.branch object) – a branch |
|---|---|
| Returns: | a boolean (True if success) |
Move a branch and attach to a destination branch. Return new structure, or return merely the resultant Newick string.
| Returns: | a topology object or a Newick string |
|---|
Parse a newick string and assign the tree to this object. Cannot already be initialized with a tree.
| Returns: | None |
|---|
Reroots the given tree structure such that it is rooted nearest the lowest-order leaf or a provided leaf.
| Parameters: | toleaf (a newick.node object) – a leaf node from this topology |
|---|