skbio.core.tree.TreeNode.copy

TreeNode.copy()[source]

Returns 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.core.tree import TreeNode
>>> tree = TreeNode.from_newick("((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