skbio.tree.TreeNode.accumulate_to_ancestor#

TreeNode.accumulate_to_ancestor(ancestor)[source]#

Return the sum of the distance between self and ancestor.

Parameters:
ancestorTreeNode

The node of the ancestor to accumulate distance too

Returns:
float

The sum of lengths between self and ancestor

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

distance

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