skbio.tree.TreeNode.accumulate_to_ancestor¶
-
TreeNode.
accumulate_to_ancestor
(ancestor)[source]¶ Return the sum of the distance between self and ancestor
State: Experimental as of 0.4.0.
- Parameters
ancestor (TreeNode) – The node of the ancestor to accumulate distance too
- Returns
The sum of lengths between self and ancestor
- Return type
- Raises
NoParentError – A NoParentError is raised if the ancestor is not an ancestor of self
NoLengthError – A NoLengthError is raised if one of the nodes between self and ancestor (including self) lacks a length attribute
See also
Examples
>>> from skbio import TreeNode >>> tree = TreeNode.read(["((a:1,b:2)c:3,(d:4,e:5)f:6)root;"]) >>> root = tree >>> tree.find('a').accumulate_to_ancestor(root) 4.0