skbio.tree.TreeNode.unpack#

TreeNode.unpack(uncache=True)[source]#

Unpack an internal node in place.

Parameters:
uncachebool, optional

Whether to clear caches of the tree if present (default: True). See details.

Added in version 0.6.3.

Raises:
ValueError

If input node is root or tip.

Notes

This method sequentially: 1) elongates child nodes by branch length of self (omit if there is no branch length), 2) removes self from parent node, and 3) grafts child nodes to parent node.

The current node must be an internal node with a parent. The root is an internal node but cannot be unpacked because it has no parent to graft its children onto.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(['((c:2.0,d:3.0)a:1.0,(e:2.0,f:1.0)b:2.0);'])
>>> tree.find('b').unpack()
>>> print(tree)
((c:2.0,d:3.0)a:1.0,e:4.0,f:3.0);