scikit-bio is back in active development! Check out our announcement of revitalization.

skbio.tree.TreeNode.descending_branch_length#

TreeNode.descending_branch_length(tip_subset=None)[source]#

Find total descending branch length from self or subset of self tips.

Parameters:
tip_subsetIterable, or None

If None, the total descending branch length for all tips in the tree will be returned. If a list of tips is provided then only the total descending branch length associated with those tips will be returned.

Returns:
float

The total descending branch length for the specified set of tips.

Raises:
ValueError

A ValueError is raised if the list of tips supplied to tip_subset contains internal nodes or non-tips.

Notes

This function replicates cogent’s totalDescendingBranch Length method and extends that method to allow the calculation of total descending branch length of a subset of the tips if requested. The postorder guarantees that the function will always be able to add the descending branch length if the node is not a tip.

Nodes with no length will have their length set to 0. The root length (if it exists) is ignored.

Examples

>>> from skbio import TreeNode
>>> tr = TreeNode.read(["(((A:.1,B:1.2)C:.6,(D:.9,E:.6)F:.9)G:2.4,"
...                     "(H:.4,I:.5)J:1.3)K;"])
>>> tdbl = tr.descending_branch_length()
>>> sdbl = tr.descending_branch_length(['A','E'])
>>> print(round(tdbl, 1), round(sdbl, 1))
8.9 2.2