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 classesPhyloxml means the top-level class used by
PhyloXMLIO.read
(but notBio.Phylo.read
!), containing a list of Phylogenies (objects derived fromBaseTree.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=DEFAULT_ENCODING, indent=True)
Write a phyloXML file.
- Parameters
- obj
an instance of
Phyloxml
,Phylogeny
orBaseTree.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__(file)
Initialize the class.
- read()
Parse the phyloXML file and create a single Phyloxml object.
- parse()
Parse the phyloXML file incrementally and return each phylogeny.
- other(elem, namespace, localtag)
Create an Other object, a non-phyloXML element.
- accession(elem)
Create accession object.
- annotation(elem)
Create annotation object.
- binary_characters(elem)
Create binary characters object.
- clade_relation(elem)
Create clade relationship object.
- color(elem)
Create branch color object.
- confidence(elem)
Create confidence object.
- date(elem)
Create date object.
- distribution(elem)
Create geographic distribution object.
- domain(elem)
Create protein domain object.
- domain_architecture(elem)
Create domain architecture object.
- events(elem)
Create events object.
- id(elem)
Create identifier object.
- mol_seq(elem)
Create molecular sequence object.
- point(elem)
Create point object, coordinates of a point.
- polygon(elem)
Create polygon object, list of points.
- property(elem)
Create properties from external resources.
- reference(elem)
Create literature reference object.
- sequence_relation(elem)
Create sequence relationship object, relationship between two sequences.
- uri(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__(phyloxml)
Build an ElementTree from a PhyloXML object.
- write(file, encoding=DEFAULT_ENCODING, indent=True)
Write PhyloXML to a file.
- phyloxml(obj)
Convert phyloxml to Etree element.
- other(obj)
Convert other to Etree element.
- phylogeny(obj)
Serialize a phylogeny and its subnodes, in order.
- clade(obj)
Serialize a clade and its subnodes, in order.
- accession(obj)
Serialize a accession and its subnodes, in order.
- annotation(obj)
Serialize a annotation and its subnodes, in order.
- binary_characters(obj)
Serialize a binary_characters node and its subnodes.
- clade_relation(obj)
Serialize a clade_relation and its subnodes, in order.
- color(obj)
Serialize a color and its subnodes, in order.
- confidence(obj)
Serialize a confidence and its subnodes, in order.
- date(obj)
Serialize a date and its subnodes, in order.
- distribution(obj)
Serialize a distribution and its subnodes, in order.
- domain(obj)
Serialize a domain node.
- domain_architecture(obj)
Serialize a domain_architecture and its subnodes, in order.
- events(obj)
Serialize a events and its subnodes, in order.
- id(obj)
Serialize a id and its subnodes, in order.
- mol_seq(obj)
Serialize a mol_seq and its subnodes, in order.
- node_id(obj)
Serialize a node_id and its subnodes, in order.
- point(obj)
Serialize a point and its subnodes, in order.
- polygon(obj)
Serialize a polygon and its subnodes, in order.
- property(obj)
Serialize a property and its subnodes, in order.
- reference(obj)
Serialize a reference and its subnodes, in order.
- sequence(obj)
Serialize a sequence and its subnodes, in order.
- sequence_relation(obj)
Serialize a sequence_relation and its subnodes, in order.
- taxonomy(obj)
Serialize a taxonomy and its subnodes, in order.
- uri(obj)
Serialize a uri and its subnodes, in order.
- alt(obj)
Serialize a simple alt node.
- branch_length(obj)
Serialize a simple branch_length node.
- lat(obj)
Serialize a simple lat node.
- long(obj)
Serialize a simple long node.
- maximum(obj)
Serialize a simple maximum node.
- minimum(obj)
Serialize a simple minimum node.
- value(obj)
Serialize a simple value node.
- width(obj)
Serialize a simple width node.
- blue(obj)
Serialize a simple blue node.
- duplications(obj)
Serialize a simple duplications node.
- green(obj)
Serialize a simple green node.
- losses(obj)
Serialize a simple losses node.
- red(obj)
Serialize a simple red node.
- speciations(obj)
Serialize a simple speciations node.
- bc(obj)
Serialize a simple bc node.
- code(obj)
Serialize a simple code node.
- common_name(obj)
Serialize a simple common_name node.
- desc(obj)
Serialize a simple desc node.
- description(obj)
Serialize a simple description node.
- location(obj)
Serialize a simple location node.
- name(obj)
Serialize a simple name node.
- rank(obj)
Serialize a simple rank node.
- scientific_name(obj)
Serialize a simple scientific_name node.
- symbol(obj)
Serialize a simple symbol node.
- synonym(obj)
Serialize a simple synonym node.
- type(obj)
Serialize a simple type node.