skbio.core.tree.TreeNode.to_newick

TreeNode.to_newick(with_distances=False, semicolon=True, escape_name=True)[source]

Return the newick string representation of this tree.

Please see TreeNode.from_newick for a further description of the Newick format

Parameters:

with_distances : bool

If true, include lengths between nodes

semicolon : bool

If true, terminate the tree string with a semicolon

escape_name : bool

If true, wrap node names that include []’”(),:;_ in single quotes

Returns:

str

A Newick string representation of the tree

See also

from_newick

Examples

>>> from skbio.core.tree import TreeNode
>>> tree = TreeNode.from_newick("((a,b)c,(d,e)f)root;")
>>> print tree.to_newick()
((a,b)c,(d,e)f)root;