skbio.tree.TreeNode.find_by_id

TreeNode.find_by_id(node_id)[source]

Find a node by id.

State: Experimental as of 0.4.0.

This search method is based from the root.

Parameters

node_id (int) – The id of a node in the tree

Returns

The tree node with the matcing id

Return type

TreeNode

Notes

This method does not cache id associations. A full traversal of the tree is performed to find a node by an id on every call.

Raises

MissingNodeError – This method will raise if the id cannot be found

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b)c,(d,e)f);"])
>>> print(tree.find_by_id(2).name)
d