TreeNode.
descending_branch_length
(tip_subset=None)[source]¶Find total descending branch length from self or subset of self tips
State: Experimental as of 0.4.0.
Parameters: | tip_subset : Iterable, or None
|
---|---|
Returns: | float
|
Raises: | ValueError
|
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