get_leaves#
- biotite.sequence.phylo.get_leaves(tree: DiGraph, node: Any | None = None) list[Any][source]#
Get the leaf nodes that are direct or indirect children of the given node.
- Parameters:
- treeDiGraph
The tree.
- nodehashable, optional
The node whose descendant leaves are returned. If the node is a leaf itself, the list contains only this node. By default, the root is used, i.e. all leaves are returned.
- Returns:
- leaveslist of hashable
The leaf nodes in depth-first order, i.e. leaves from the first child are listed before leaves from the second child etc.
Examples
>>> tree = from_newick("((0,1),(2,3));") >>> print(get_leaves(tree)) [0, 1, 2, 3] >>> intermediate = next(tree.predecessors(2)) >>> print(get_leaves(tree, intermediate)) [2, 3]