Fork me on GitHub"

# skbio.tree.TreeNode.unrooted_deepcopy

TreeNode.unrooted_deepcopy(parent=None)

  Walks the tree unrooted-style and returns a new copy

  State: Experimental as of 0.4.0.

  Perform a deepcopy of self and return a new copy of the tree as an unrooted copy. This is useful for defining new roots of the tree as the TreeNode.

  This method calls TreeNode.unrooted_copy which is recursive.

  Parameters:

    parent (TreeNode or None) – Used to avoid infinite loops when performing the unrooted traverse

  Returns:

    A new copy of the tree

  Return type:

    TreeNode

  See also

  `copy`, `unrooted_copy`, `root_at`

  Examples

      >>> from skbio import TreeNode
      >>> tree = TreeNode.read(["((a,(b,c)d)e,(f,g)h)i;"])
      >>> new_tree = tree.find('d').unrooted_deepcopy()
      >>> print(new_tree)
      (b,c,(a,((f,g)h)e)d)root;