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

Module _io

source code

I/O function wrappers for phylogenetic tree formats.

This API follows the same semantics as Biopython's SeqIO and AlignIO.

Functions [hide private]
 
parse(file, format, **kwargs)
Iteratively parse a file and return each of the trees it contains.
source code
 
read(file, format, **kwargs)
Parse a file in the given format and return a single tree.
source code
 
write(trees, file, format, **kwargs)
Write a sequence of trees to file in the given format.
source code
 
convert(in_file, in_format, out_file, out_format, parse_args={}, **kwargs)
Convert between two tree file formats.
source code
Variables [hide private]
  supported_formats = {'cdao': <module 'Bio.Phylo.CDAOIO' from '...
  __package__ = 'Bio.Phylo'
Function Details [hide private]

parse(file, format, **kwargs)

source code 

Iteratively parse a file and return each of the trees it contains.

If a file only contains one tree, this still returns an iterable object that contains one element.

Example

>>> trees = parse('../../Tests/PhyloXML/apaf.xml', 'phyloxml')
>>> for tree in trees:
...     print(tree.rooted)
True

read(file, format, **kwargs)

source code 

Parse a file in the given format and return a single tree.

Raises a ValueError if there are zero or multiple trees -- if this occurs, use parse instead to get the complete sequence of trees.


Variables Details [hide private]

supported_formats

Value:
{'cdao': <module 'Bio.Phylo.CDAOIO' from '/home/tra/biopython-1.64/usr\
/local/lib/python2.7/dist-packages/Bio/Phylo/CDAOIO.pyc'>,
 'newick': <module 'Bio.Phylo.NewickIO' from '/home/tra/biopython-1.64\
/usr/local/lib/python2.7/dist-packages/Bio/Phylo/NewickIO.pyc'>,
 'nexml': <module 'Bio.Phylo.NeXMLIO' from '/home/tra/biopython-1.64/u\
sr/local/lib/python2.7/dist-packages/Bio/Phylo/NeXMLIO.pyc'>,
 'nexus': <module 'Bio.Phylo.NexusIO' from '/home/tra/biopython-1.64/u\
sr/local/lib/python2.7/dist-packages/Bio/Phylo/NexusIO.pyc'>,
...