Bio.Phylo.CDAOIO module

I/O function wrappers for the RDF/CDAO file format.

This is an RDF format that conforms to the Comparative Data Analysis Ontology (CDAO). See:

This module requires the librdf Python bindings (

The CDAOIO.Parser, in addition to parsing text files, can also parse directly from a triple store that implements the Redland storage interface; similarly, the CDAOIO.Writer can store triples in a triple store instead of serializing them to a file.


Resolve URI for librdf.


Format label for librdf.

Bio.Phylo.CDAOIO.parse(handle, **kwargs)

Iterate over the trees in a CDAO file handle.


generator of Bio.Phylo.CDAO.Tree objects.

Bio.Phylo.CDAOIO.write(trees, handle, plain=False, **kwargs)

Write a trees in CDAO format to the given file handle.


number of trees written.

class Bio.Phylo.CDAOIO.Parser(handle=None)

Bases: object

Parse a CDAO tree given a file handle.

__init__(self, handle=None)

Initialize CDAO tree parser.

classmethod from_string(treetext)

Instantiate the class from the given string.

parse(self, **kwargs)

Parse the text stream this object was initialized with.

parse_handle_to_graph(self, rooted=False, parse_format='turtle', context=None, **kwargs)

Parse self.handle into RDF model self.model.

parse_graph(self, graph=None, context=None)

Iterate over RDF model yielding CDAO.Tree instances.

new_clade(self, node)

Return a CDAO.Clade object for a given named node.

get_node_info(self, graph, context=None)

Create a dictionary containing information about all nodes in the tree.

parse_children(self, node)

Traverse the tree to create a nested clade structure.

Return a CDAO.Clade, and calls itself recursively for each child, traversing the entire tree and creating a nested structure of CDAO.Clade objects.

class Bio.Phylo.CDAOIO.Writer(trees)

Bases: object

Based on the writer in Bio.Nexus.Trees (str, to_string).

prefixes = {'cdao': '', 'obo': '', 'owl': '', 'rdf': '', 'rdfs': ''}
__init__(self, trees)

Initialize parameters for writing a CDAO tree.

write(self, handle, tree_uri='', record_complete_ancestry=False, rooted=False, **kwargs)

Write this instance’s trees to a file handle.

add_stmt_to_handle(self, handle, stmt)

Add URI prefix to handle.

process_clade(self, clade, parent=None, root=False)

Recursively generate triples describing a tree of clades.