skbio.tree.TreeNode.find#
- TreeNode.find(name)[source]#
Find a node by name.
- Parameters:
- nameTreeNode or str
The name of the node to find. If a
TreeNode
object is provided, will find this particular node in the tree.
- Returns:
- TreeNode
The found node.
- Raises:
- MissingNodeError
If the node to be searched for is not found in the current tree.
See also
Notes
This method will first attempt to find the node in the tips. If it cannot find a corresponding tip, it will then search through the internal nodes of the tree. In practice, phylogenetic trees and other common trees in biology do not have unique internal node names. As a result, this find method will only return the first occurrence of an internal node encountered on a postorder traversal of the tree.
The first call of
find
will cache a node lookup table in the tree on the assumption that additional calls tofind
will be made. Seedetails
.This method searches within the entire tree where self is located, regardless if self is the root node.
Examples
>>> from skbio import TreeNode >>> tree = TreeNode.read(["((a,b)c,(d,e)f);"]) >>> node = tree.find('c') >>> node.name 'c'