Package Bio :: Package Phylo :: Module NewickIO
[hide private]
[frames] | no frames]

Module NewickIO

source code

I/O function wrappers for the Newick file format.

See: http://evolution.genetics.washington.edu/phylip/newick_doc.html

Classes [hide private]
  NewickError
Exception raised when Newick object construction cannot continue.
  Parser
Parse a Newick tree given a file handle.
  Writer
Based on the writer in Bio.Nexus.Trees (str, to_string).
Functions [hide private]
 
parse(handle, **kwargs)
Iterate over the trees in a Newick file handle.
source code
 
write(trees, handle, plain=False, **kwargs)
Write a trees in Newick format to the given file handle.
source code
 
_parse_confidence(text) source code
 
_format_comment(text) source code
 
_get_comment(clade) source code
Variables [hide private]
  tokens = [('\\(', 'open parens'), ('\\)', 'close parens'), ('[...
  tokenizer = re.compile(r'(\(|\)|[^\s\(\)\[\]\':;,]+|:[0-9]*\.?...
  token_dict = {'close parens': re.compile(r'\)'), 'comma': re.c...
  __package__ = 'Bio.Phylo'
Function Details [hide private]

parse(handle, **kwargs)

source code 
Iterate over the trees in a Newick file handle.
Returns:
generator of Bio.Phylo.Newick.Tree objects.

write(trees, handle, plain=False, **kwargs)

source code 
Write a trees in Newick format to the given file handle.
Returns:
number of trees written.

Variables Details [hide private]

tokens

Value:
[('\\(', 'open parens'),
 ('\\)', 'close parens'),
 ('[^\\s\\(\\)\\[\\]\\\'\\:\\;\\,]+', 'unquoted node label'),
 ('\\:[0-9]*\\.?[0-9]+([eE][+-]?[0-9]+)?', 'edge length'),
 ('\\,', 'comma'),
 ('\\[(\\\\.|[^\\]])*\\]', 'comment'),
 ('\\\'(\\\\.|[^\\\'])*\\\'', 'quoted node label'),
 ('\\;', 'semicolon'),
...

tokenizer

Value:
re.compile(r'(\(|\)|[^\s\(\)\[\]\':;,]+|:[0-9]*\.?[0-9]+([eE][\+-]?[0-\
9]+)?|,|\[(\\.|[^\]])*\]|\'(\\.|[^\'])*\'|;|\n)')

token_dict

Value:
{'close parens': re.compile(r'\)'),
 'comma': re.compile(r','),
 'comment': re.compile(r'\[(\\.|[^\]])*\]'),
 'edge length': re.compile(r':[0-9]*\.?[0-9]+([eE][\+-]?[0-9]+)?'),
 'newline': re.compile(r'\n'),
 'open parens': re.compile(r'\('),
 'quoted node label': re.compile(r'\'(\\.|[^\'])*\''),
 'semicolon': re.compile(r';'),
...