skbio.tree.TreeNode.descending_branch_length#

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

Find total descending branch length from self to a set of tips.

Parameters:
tip_subsetiterable of str, optional

If None, the total descending branch length for all tips in the tree will be returned. If a list of tip names 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

If 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