scikit-bio is back in active development! Check out our announcement of revitalization.

skbio.tree.TreeNode.remove_deleted#

TreeNode.remove_deleted(func)[source]#

Delete nodes in which func(node) evaluates True.

Remove all descendants from self that evaluate True from func. This has the potential to drop clades.

Parameters:
funca function

A function that evaluates True when a node should be deleted

See also

pop
remove

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["(a,b)c;"])
>>> tree.remove_deleted(lambda x: x.name == 'b')
>>> print(tree)
(a)c;