skbio.tree.TreeNode.to_newick

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

Return the newick string representation of this tree.

Note

Deprecated in scikit-bio 0.2.0-dev to_newick will be removed in scikit-bio 0.3.0. It is replaced by write, which is a more general method for serializing TreeNode instances. write supports multiple file formats by taking advantage of scikit-bio’s I/O registry system. See skbio.io for more details.

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 import TreeNode
>>> tree = TreeNode.read(StringIO("((a,b)c,(d,e)f)root;"))
>>> print(tree.to_newick())
((a,b)c,(d,e)f)root;