skbio.tree.TreeNode.find_by_id#

TreeNode.find_by_id(node_id)[source]#

Find a node by id.

This search method is based from the root.

Parameters:
node_idint

The id of a node in the tree

Returns:
TreeNode

The tree node with the matching id

Raises:
MissingNodeError

This method will raise if the id cannot be found

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.

Examples

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