def subontology(self, nodes=None, minimal=False, relations=None): """ Return a new ontology that is an extract of this one Arguments --------- - nodes: list list of node IDs to include in subontology. If None, all are used - relations: list list of relation IDs to include in subontology. If None, all are used """ g = None if nodes is not None: g = self.subgraph(nodes) else: g = self.get_graph() if minimal: from ontobio.slimmer import get_minimal_subgraph g = get_minimal_subgraph(g, nodes) ont = Ontology(graph=g, xref_graph=self.xref_graph) # TODO - add metadata if relations is not None: g = ont.get_filtered_graph(relations) ont = Ontology(graph=g, xref_graph=self.xref_graph) return ont
def render(ont, query_ids, args): """ Writes or displays graph """ if args.slim.find('m') > -1: logging.info("SLIMMING") g = get_minimal_subgraph(g, query_ids) w = GraphRenderer.create(args.to) if args.outfile is not None: w.outfile = args.outfile w.write(ont, query_ids=query_ids, container_predicates=args.container_properties)
def show_graph(g, nodes, query_ids, args): """ Writes graph """ if args.graph.find('m') > -1: logging.info("SLIMMING") g = get_minimal_subgraph(g, query_ids) w = GraphRenderer.create(args.to) if args.outfile is not None: w.outfile = args.outfile logging.info("Writing subg from " + str(g)) w.write(g, query_ids=query_ids, container_predicates=args.container_properties)
def render(ont, query_ids, args): """ Writes or displays graph """ if args.slim.find('m') > -1: logging.info("SLIMMING") g = get_minimal_subgraph(g, query_ids) w = GraphRenderer.create(args.to) if args.showdefs: w.config.show_text_definition = True if args.render: if 'd' in args.render: logging.info("Showing text defs") w.config.show_text_definition = True if args.outfile is not None: w.outfile = args.outfile w.write(ont, query_ids=query_ids, container_predicates=args.container_properties)