Bio.Phylo.PhyloXMLIO module

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:
  • phyloXML means the file format specification

  • PhyloXML means the Biopython module Bio.Phylo.PhyloXML and its classes

  • Phyloxml means the top-level class used by PhyloXMLIO.read (but not Bio.Phylo.read!), containing a list of Phylogenies (objects derived from BaseTree.Tree)

exception Bio.Phylo.PhyloXMLIO.PhyloXMLError

Bases: Exception

Exception raised when PhyloXML object construction cannot continue.

XML syntax errors will be found and raised by the underlying ElementTree module; this exception is for valid XML that breaks the phyloXML specification.

Bio.Phylo.PhyloXMLIO.read(file)

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.

Bio.Phylo.PhyloXMLIO.parse(file)

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.

Bio.Phylo.PhyloXMLIO.write(obj, file, encoding='unicode', indent=True)

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.

class Bio.Phylo.PhyloXMLIO.Parser(file)

Bases: object

Methods for parsing all phyloXML nodes from an XML stream.

To minimize memory use, the tree of ElementTree parsing events is cleared after completing each phylogeny, clade, and top-level ‘other’ element. Elements below the clade level are kept in memory until parsing of the current clade is finished – this shouldn’t be a problem because clade is the only recursive element, and non-clade nodes below this level are of bounded size.

__init__(self, file)

Initialize the class.

read(self)

Parse the phyloXML file and create a single Phyloxml object.

parse(self)

Parse the phyloXML file incrementally and return each phylogeny.

other(self, elem, namespace, localtag)

Create an Other object, a non-phyloXML element.

accession(self, elem)

Create accession object.

annotation(self, elem)

Create annotation object.

binary_characters(self, elem)

Create binary characters object.

clade_relation(self, elem)

Create clade relationship object.

color(self, elem)

Create branch color object.

confidence(self, elem)

Create confidence object.

date(self, elem)

Create date object.

distribution(self, elem)

Create geographic distribution object.

domain(self, elem)

Create protein domain object.

domain_architecture(self, elem)

Create domain architecture object.

events(self, elem)

Create events object.

id(self, elem)

Create identifier object.

mol_seq(self, elem)

Create molecular sequence object.

point(self, elem)

Create point object, coordinates of a point.

polygon(self, elem)

Create polygon object, list of points.

property(self, elem)

Create properties from external resources.

reference(self, elem)

Create literature reference object.

sequence_relation(self, elem)

Create sequence relationship object, relationship between two sequences.

uri(self, elem)

Create uri object, expected to be a url.

class Bio.Phylo.PhyloXMLIO.Writer(phyloxml)

Bases: object

Methods for serializing a PhyloXML object to XML.

__init__(self, phyloxml)

Build an ElementTree from a PhyloXML object.

write(self, file, encoding='unicode', indent=True)

Write PhyloXML to a file.

phyloxml(self, obj)

Convert phyloxml to Etree element.

other(self, obj)

Convert other to Etree element.

phylogeny(self, obj)

Serialize a phylogeny and its subnodes, in order.

clade(self, obj)

Serialize a clade and its subnodes, in order.

accession(self, obj)

Serialize a accession and its subnodes, in order.

annotation(self, obj)

Serialize a annotation and its subnodes, in order.

binary_characters(self, obj)

Serialize a binary_characters node and its subnodes.

clade_relation(self, obj)

Serialize a clade_relation and its subnodes, in order.

color(self, obj)

Serialize a color and its subnodes, in order.

confidence(self, obj)

Serialize a confidence and its subnodes, in order.

date(self, obj)

Serialize a date and its subnodes, in order.

distribution(self, obj)

Serialize a distribution and its subnodes, in order.

domain(self, obj)

Serialize a domain node.

domain_architecture(self, obj)

Serialize a domain_architecture and its subnodes, in order.

events(self, obj)

Serialize a events and its subnodes, in order.

id(self, obj)

Serialize a id and its subnodes, in order.

mol_seq(self, obj)

Serialize a mol_seq and its subnodes, in order.

node_id(self, obj)

Serialize a node_id and its subnodes, in order.

point(self, obj)

Serialize a point and its subnodes, in order.

polygon(self, obj)

Serialize a polygon and its subnodes, in order.

property(self, obj)

Serialize a property and its subnodes, in order.

reference(self, obj)

Serialize a reference and its subnodes, in order.

sequence(self, obj)

Serialize a sequence and its subnodes, in order.

sequence_relation(self, obj)

Serialize a sequence_relation and its subnodes, in order.

taxonomy(self, obj)

Serialize a taxonomy and its subnodes, in order.

uri(self, obj)

Serialize a uri and its subnodes, in order.

alt(self, obj)

Serialize a simple alt node.

branch_length(self, obj)

Serialize a simple branch_length node.

lat(self, obj)

Serialize a simple lat node.

long(self, obj)

Serialize a simple long node.

maximum(self, obj)

Serialize a simple maximum node.

minimum(self, obj)

Serialize a simple minimum node.

value(self, obj)

Serialize a simple value node.

width(self, obj)

Serialize a simple width node.

blue(self, obj)

Serialize a simple blue node.

duplications(self, obj)

Serialize a simple duplications node.

green(self, obj)

Serialize a simple green node.

losses(self, obj)

Serialize a simple losses node.

red(self, obj)

Serialize a simple red node.

speciations(self, obj)

Serialize a simple speciations node.

bc(self, obj)

Serialize a simple bc node.

code(self, obj)

Serialize a simple code node.

common_name(self, obj)

Serialize a simple common_name node.

desc(self, obj)

Serialize a simple desc node.

description(self, obj)

Serialize a simple description node.

location(self, obj)

Serialize a simple location node.

name(self, obj)

Serialize a simple name node.

rank(self, obj)

Serialize a simple rank node.

scientific_name(self, obj)

Serialize a simple scientific_name node.

symbol(self, obj)

Serialize a simple symbol node.

synonym(self, obj)

Serialize a simple synonym node.

type(self, obj)

Serialize a simple type node.