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

Module PhyloXMLIO

source code

PhyloXML reader/parser, writer, and associated functions.

Instantiates tree elements from a parsed PhyloXML file, and constructs an XML file from a Bio.Phylo.PhyloXML object.

About capitalization:

Classes [hide private]
  PhyloXMLError
Exception raised when PhyloXML object construction cannot continue.
  Parser
Methods for parsing all phyloXML nodes from an XML stream.
  Writer
Methods for serializing a PhyloXML object to XML.
Functions [hide private]
 
register_namespace(prefix, uri) source code
 
read(file)
Parse a phyloXML file or stream and build a tree of Biopython objects.
source code
 
parse(file)
Iterate over the phylogenetic trees in a phyloXML file.
source code
 
write(obj, file, encoding='utf-8', indent=True)
Write a phyloXML file.
source code
 
_local(tag)
Extract the local tag from a namespaced tag name.
source code
 
_split_namespace(tag)
Split a tag into namespace and local tag strings.
source code
 
_ns(tag, namespace='http://www.phyloxml.org')
Format an XML tag with the given namespace.
source code
 
_get_child_as(parent, tag, construct)
Find a child node by tag, and pass it through a constructor.
source code
 
_get_child_text(parent, tag, construct=<type 'unicode'>)
Find a child node by tag; pass its text through a constructor.
source code
 
_get_children_as(parent, tag, construct)
Find child nodes by tag; pass each through a constructor.
source code
 
_get_children_text(parent, tag, construct=<type 'unicode'>)
Find child nodes by tag; pass each node's text through a constructor.
source code
 
_indent(elem, level=0)
Add line breaks and indentation to ElementTree in-place.
source code
 
_str2bool(text) source code
 
_dict_str2bool(dct, keys) source code
 
_int(text) source code
 
_float(text) source code
 
_collapse_wspace(text)
Replace all spans of whitespace with a single space character.
source code
 
_replace_wspace(text)
Replace tab, LF and CR characters with spaces, but don't collapse.
source code
 
_serialize(value)
Convert a Python primitive to a phyloXML-compatible Unicode string.
source code
 
_clean_attrib(obj, attrs)
Create a dictionary from an object's specified, non-None attributes.
source code
 
_handle_complex(tag, attribs, subnodes, has_text=False) source code
 
_handle_simple(tag) source code
Variables [hide private]
  NAMESPACES = {'phy': 'http://www.phyloxml.org'}
  DEFAULT_ENCODING = 'utf-8'
  __package__ = 'Bio.Phylo'
  prefix = 'phy'
  uri = 'http://www.phyloxml.org'
Function Details [hide private]

read(file)

source code 

Parse a phyloXML file or stream and build a tree of Biopython objects.

The children of the root node are phylogenies and possibly other arbitrary (non-phyloXML) objects.

Returns:
a single Bio.Phylo.PhyloXML.Phyloxml object.

parse(file)

source code 

Iterate over the phylogenetic trees in a phyloXML file.

This ignores any additional data stored at the top level, but may be more memory-efficient than the read function.

Returns:
a generator of Bio.Phylo.PhyloXML.Phylogeny objects.

write(obj, file, encoding='utf-8', indent=True)

source code 
Write a phyloXML file.
Parameters:
  • obj - an instance of Phyloxml, Phylogeny or BaseTree.Tree, or an iterable of either of the latter two. The object will be converted to a Phyloxml object before serialization.
  • file - either an open handle or a file name.

_get_child_as(parent, tag, construct)

source code 

Find a child node by tag, and pass it through a constructor.

Returns None if no matching child is found.

_get_child_text(parent, tag, construct=<type 'unicode'>)

source code 

Find a child node by tag; pass its text through a constructor.

Returns None if no matching child is found.

_get_children_as(parent, tag, construct)

source code 

Find child nodes by tag; pass each through a constructor.

Returns an empty list if no matching child is found.

_get_children_text(parent, tag, construct=<type 'unicode'>)

source code 

Find child nodes by tag; pass each node's text through a constructor.

Returns an empty list if no matching child is found.

_indent(elem, level=0)

source code 

Add line breaks and indentation to ElementTree in-place.

Sources:

_collapse_wspace(text)

source code 

Replace all spans of whitespace with a single space character.

Also remove leading and trailing whitespace. See "Collapse Whitespace Policy" in the phyloXML spec glossary: http://phyloxml.org/documentation/version_100/phyloxml.xsd.html#Glossary

_replace_wspace(text)

source code 

Replace tab, LF and CR characters with spaces, but don't collapse.

See "Replace Whitespace Policy" in the phyloXML spec glossary: http://phyloxml.org/documentation/version_100/phyloxml.xsd.html#Glossary