def parse_graph(self, graph=None, context=None): """Iterate over RDF model yielding CDAO.Tree instances.""" if graph is None: graph = self.graph # look up branch lengths/TUs for all nodes self.get_node_info(graph, context=context) for root_node in self.tree_roots: clade = self.parse_children(root_node) yield CDAO.Tree(root=clade, rooted=self.rooted)
def new_clade(self, node): '''Returns a CDAO.Clade object for a given named node.''' result = self.node_info[node] kwargs = {} if 'branch_length' in result: kwargs['branch_length'] = result['branch_length'] if 'label' in result: kwargs['name'] = result['label'].replace('_', ' ') if 'confidence' in result: kwargs['confidence'] = result['confidence'] clade = CDAO.Clade(**kwargs) return clade
def parse_graph(self, graph=None, context=None): '''Generator that yields CDAO.Tree instances from an RDF model.''' if graph is None: graph = self.graph # look up branch lengths/TUs for all nodes self.get_node_info(graph, context=context) for root_node in self.tree_roots: clade = self.parse_children(root_node) yield CDAO.Tree(root=clade, rooted=self.rooted)
def new_clade(self, node): """Return a CDAO.Clade object for a given named node.""" result = self.node_info[node] kwargs = {} if "branch_length" in result: kwargs["branch_length"] = result["branch_length"] if "label" in result: kwargs["name"] = result["label"].replace("_", " ") if "confidence" in result: kwargs["confidence"] = result["confidence"] clade = CDAO.Clade(**kwargs) return clade
def parse_model(self, model=None, context=None): '''Generator that yields CDAO.Tree instances from an RDF model.''' if model is None: model = self.model if not context is None: context = RDF.Node(RDF.Uri(context)) # look up branch lengths/TUs for all nodes self.get_node_info(model, context=context) for root_node in self.tree_roots: clade = self.parse_children(root_node) yield CDAO.Tree(root=clade, rooted=self.rooted)