Trees | Indices | Help |
---|
|
object --+ | TreeMixin
Methods for Tree- and Clade-based classes.
This lets Tree and Clade support the same traversal and searching operations without requiring Clade to inherit from Tree, so Clade isn't required to have all of Tree's attributes -- just 'root' (a Clade instance) and 'is_terminal()'.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
Perform a BFS or DFS traversal through all elements in this tree.
|
Return the first element found by find_elements(), or None. This is also useful for checking whether any matching element exists in the tree, and can be used in a conditional expression. |
Find all tree elements matching the given attributes. The arbitrary keyword arguments indicate the attribute name of the sub-element and the value to match: string, integer or boolean. Strings are evaluated as regular expression matches; integers are compared directly for equality, and booleans evaluate the attribute's truth value (True or False) before comparing. To handle nonzero floats, search with a boolean argument, then filter the result manually. If no keyword arguments are given, then just the class type is used for matching. The result is an iterable through all matching objects, by depth-first search. (Not necessarily the same order as the elements appear in the source file!) Example: >>> from Bio.Phylo.IO import PhyloXMIO >>> phx = PhyloXMLIO.read('phyloxml_examples.xml') >>> matches = phx.phylogenies[5].find_elements(code='OCTVU') >>> matches.next() Taxonomy(code='OCTVU', scientific_name='Octopus vulgaris')
|
Find each clade containing a matching element. That is, find each element as with find_elements(), but return the corresponding clade object. (This is usually what you want.) The result is an iterable through all matching objects, searching depth-first (preorder) by default. |
List the clades directly between this root and the given target. Returns a list of all clade objects along this path, ending with the given target, but excluding the root clade. |
List of all clade object between two targets in this tree. Excluding start, including finish. |
Most recent common ancestor (clade) of all the given targets. Edge cases:
|
Create a mapping of tree clades to depths (by branch length). The result is a dictionary where the keys are all of the Clade instances in the tree, and the values are the distance from the root to each clade (including terminals). By default the distance is the cumulative branch length leading to the clade. With the unit_branch_lengths=True option, only the number of branches (levels in the tree) is counted.
|
Calculate the sum of the branch lengths between two targets. If only one target is specified, the other is the root of this tree. |
Return True if tree downstream of node is strictly bifurcating. I.e., all nodes have either 2 or 0 children (internal or external, respectively). The root may have 3 descendents and still be considered part of a bifurcating tree, because it has no ancestor. |
MRCA of terminals if they comprise a complete subclade, or False. I.e., there exists a clade such that its terminals are the same set as the given targets. The given targets must be terminals of the tree. To match both Bio.Nexus.Trees and the other multi-target methods in Bio.Phylo, arguments to this method can be specified either of two ways: (i) as a single list of targets, or (ii) separately specified targets, e.g. is_monophyletic(t1, t2, t3) -- but not both. For convenience, this method returns the common ancestor (MCRA) of the targets if they are monophyletic (instead of the value True), and False otherwise.
|
True if target is a descendent of this tree. Not required to be a direct descendent. To check only direct descendents of a clade, simply use list membership testing: "if subclade in clade: ..." |
Deletes target from the tree, relinking its children to its parent.
|
Collapse all the descendents of this tree, leaving only terminals. Branch lengths are preserved, i.e. the distance to each terminal stays the same. To collapse only certain elements, use the collapse method directly in a loop with find_clades: >>> for clade in tree.find_clades(branch_length=True, order='level'): ... if (clade.branch_length < .5 and ... not clade.is_terminal() and ... clade is not self.root): ... tree.collapse(clade) Note that level-order traversal helps avoid strange side-effects when modifying the tree while iterating over its clades. |
Sort clades in-place according to the number of terminal nodes. Deepest clades are last by default. Use reverse=True to sort clades deepest-to-shallowest. |
Prunes a terminal clade from the tree. If taxon is from a bifurcation, the connecting node will be collapsed and its branch length added to remaining terminal node. This might be no longer be a meaningful value.
|
Generate n (default 2) new descendants. In a species tree, this is a speciation event. New clades have the given branch_length and the same name as this clade's root plus an integer suffix (counting from 0). For example, splitting a clade named "A" produces sub-clades named "A0" and "A1". |
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Apr 1 00:42:15 2011 | http://epydoc.sourceforge.net |