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__
(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': '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__
(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.
-