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

skbio.tree.TreeNode.__copy__#

TreeNode.__copy__()[source]#

Return a copy of self using an iterative approach.

Perform an iterative deepcopy of self. It is not assured that the copy of node attributes will be performed iteratively as that depends on the copy method of the types being copied

Returns:
TreeNode

A new copy of self

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b)c,(d,e)f)root;"])
>>> tree_copy = tree.copy()
>>> tree_nodes = set([id(n) for n in tree.traverse()])
>>> tree_copy_nodes = set([id(n) for n in tree_copy.traverse()])
>>> print(len(tree_nodes.intersection(tree_copy_nodes)))
0