skbio.tree.TreeNode.unrooted_move#

TreeNode.unrooted_move(parent=None, branch_attrs={'length', 'support'}, uncache=True)[source]#

Walk the tree unrooted-style and rearrange it.

Added in version 0.6.2.

Parameters:
parentTreeNode or None

Direction of walking (from parent to self). If specified, walking to the parent will be prohibited.

branch_attrsset of str, optional

Attributes of TreeNode objects that should be considered as branch attributes during the operation.

uncachebool, optional

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

Added in version 0.6.3.

Notes

This method recursively walks a tree from a given node in an unrooted style (i.e., directions of branches are not assumed). It rerranges the tree such that the given node becomes the root node and all other nodes are re-positioned accordingly, whereas the topology remains the same.

This method manipulates the tree in place. There is no return value. The new tree should be referred to by the node where the operation started, as it has become the new root node.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,(b,c)d)e,(f,g)h)i;"])
>>> new_root = tree.find('d')
>>> new_root.unrooted_move()
>>> print(new_root)
(b,c,(a,((f,g)h)i)e)d;