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: http://evolutionaryontology.org/cdao

This module requires the librdf Python bindings (http://www.librdf.org)

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.

Bio.Phylo.CDAOIO.qUri(x)

Resolve URI for librdf.

Bio.Phylo.CDAOIO.format_label(x)

Format label for librdf.

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

Iterate over the trees in a CDAO file handle.

Returns:

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.

Returns:

number of trees written.

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

Bases: object

Parse a CDAO tree given a file handle.

__init__(handle=None)

Initialize CDAO tree parser.

classmethod from_string(treetext)

Instantiate the class from the given string.

parse(**kwargs)

Parse the text stream this object was initialized with.

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

Parse self.handle into RDF model self.model.

parse_graph(graph=None, context=None)

Iterate over RDF model yielding CDAO.Tree instances.

new_clade(node)

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

get_node_info(graph, context=None)

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

parse_children(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': 'http://purl.obolibrary.org/obo/cdao.owl#', 'obo': 'http://purl.obolibrary.org/obo/', 'owl': 'http://www.w3.org/2002/07/owl#', 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#'}
__init__(trees)

Initialize parameters for writing a CDAO tree.

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

Write this instance’s trees to a file handle.

add_stmt_to_handle(handle, stmt)

Add URI prefix to handle.

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

Recursively generate triples describing a tree of clades.