skbio.tree.BPTree.positions#
- BPTree.positions(names)[source]#
Positions of named nodes.
A name is resolved as
skbio.tree.TreeNode.findresolves it: to the tip of that name if there is one, else to the first internal node of that name in preorder.- Parameters:
- namesstr or iterable of str
A name, or names, of nodes.
- Returns:
- int or numpy.ndarray of intp
The position (opening parenthesis) of the node of each name: an int for a single name, else an array in the order of
names.
- Raises:
- MissingNodeError
If a name is not found in the tree, or is None.
See also
Examples
>>> from skbio.tree import BPTree >>> tree = BPTree.read(["((a:1,b:2)c:3,(d:4,e:5)f:6)root;"]) >>> tree.positions(["e", "c", "root"]) array([10, 1, 0]) >>> tree.positions("f") 7