skbio.tree.TreeNode.find_by_id#

TreeNode.find_by_id(node_id)[source]#

Find a node by ID.

Parameters:
node_idint

The ID of a node in the tree.

Returns:
TreeNode

The node with the matching ID.

Raises:
MissingNodeError

If the ID cannot be found.

See also

assign_ids
find

Notes

This method searches within the subtree under the current node. But the IDs are assigned from the root of the entire tree.

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