ete2.parser.newick

Package ete2 :: Package parser :: Module newick |
[hide private]
[frames] | no frames]

# Module newick

source code

Classes | [hide private]
| NewickError Exception class designed for NewickIO errors.

Functions | [hide private]
format_node(node, node_type, format) | source code
node2leafformat(node, format) | source code
node2internalformat(node, format) | source code
print_supported_formats() | source code
read_newick(newick, root_node=None, format=0) Reads a newick tree from either a string or a file, and returns an ETE tree structure. | source code
_read_newick_from_string(nw, root_node, format) Reads a newick string in the New Hampshire format. | source code
_parse_extra_features(node, NHX_string) Reads node's extra data form its NHX string. | source code
_read_node_data(subnw, current_node, node_type, format) Reads a leaf node from a subpart of the original newick tree | source code
write_newick(node, features=`[``]`, format=1, _is_root=True) Recursively reads a tree structure and returns its NHX representation. | source code
_get_features_string(self, features=`[``]`) Generates the extended newick string NHX with extra data about a node. | source code

Variables | [hide private]
| __VERSION__ = ``'``ete2-2.0rev90``'``
| _ILEGAL_NEWICK_CHARS = ``'``:;(),\\[\\]\t\n\r=``'``
| _NHX_RE = ``'``\\[&&NHX:[^\\]]*\\]``'``
| _FLOAT_RE = ``'``[+-]?\\d+\\.?\\d*``'``
| _NAME_RE = ``'``[^():,;\\[\\]]+``'``
| DEFAULT_DIST = `1.0`
| DEFAULT_NAME = ``'````'``
| DEFAULT_SUPPORT = `1.0`
| NW_FORMAT = ``{`0`:` `[``[``'``name``'``,` <type 'str'>`,` True`]``,` `[``'``dist``'``,` <type `...``
| __package__ = ``'``ete2.parser``'``

Function Details | [hide private]

### read_newick(newick, root_node=None, format=0) | source code
Reads a newick tree from either a string or a file, and returns an ETE tree structure. A previously existent node object can be passed as the root of the tree, which means that all its new children will belong to the same class as the root(This allows to work with custom TreeNode objects). You can also take advantage from this behaviour to concatenate several tree structures.

### _parse_extra_features(node, NHX_string) | source code
Reads node's extra data form its NHX string. NHX uses this format: [&&NHX:prop1=value1:prop2=value2]

Variables Details | [hide private]

  ### NW_FORMAT Value:
      {0: [['name', <type 'str'>, True],
           ['dist', <type 'float'>, True],
           ['support', <type 'float'>, True],
           ['dist', <type 'float'>, True]],
       1: [['name', <type 'str'>, True],
           ['dist', <type 'float'>, True],
           ['name', <type 'str'>, True],
           ['dist', <type 'float'>, True]],
      ...