def preload_ontologies(): ontologies = settings.get_biolink_config().get('ontologies') for ontology in ontologies: handle = ontology['handle'] if ontology['pre_load']: log.info("Loading {}".format(ontology['id'])) get_ontology(handle)
def get(self): """ Summary statistics for objects associated """ args = parser.parse_args() M = GolrFields() ont = None ocat = args.get('object_category') ontid = args.get('ontology') if ontid is None: if ocat == 'function': ontid = 'go' if ocat == 'phenotype': # TODO: other phenotype ontologies ontid = 'hp' print("Loading: {}".format(ontid)) ont = get_ontology(ontid) taxid = args.get('taxon') max_p_value = float(args.max_p_value) subjects = args.get('subject') background = args.get('background') afactory = AssociationSetFactory() aset = afactory.create(ontology=ont, subject_category='gene', object_category=ocat, taxon=taxid) enr = aset.enrichment_test(subjects=subjects, threshold=max_p_value, labels=True) return {'results': enr}
def get(self, ontology, node): """ Extract a subgraph from an ontology """ args = parser.parse_args() qnodes = [node] if args.cnode is not None: qnodes += args.cnode factory = OntologyFactory() ont = get_ontology(ontology) #subont = ont.subontology([id], relations=args.relations) relations = args.relation print("Traversing: {} using {}".format(qnodes,relations)) nodes = ont.traverse_nodes(qnodes, up=True, down=False, relations=relations) subont = ont.subontology(nodes, relations=relations) ojr = OboJsonGraphRenderer(include_meta=args.include_meta) json_obj = ojr.to_json(subont) # TODO: remove this next release of ontobio if not args.include_meta: for g in json_obj['graphs']: for n in g['nodes']: n['meta']={} return json_obj
def get(self, ontology): """ TEST """ ont = get_ontology(ontology) return {'z': 'foo', 'nodes': len(ont.nodes())}
def post(self, ontology, node): """ Extract a subgraph from an ontology """ args = parser.parse_args() qnodes = [node] if args.cnode is not None: qnodes += args.cnode ont = get_ontology(ontology) relations = args.relation log.info("Traversing: {} using {}".format(qnodes, relations)) nodes = ont.traverse_nodes(qnodes, up=args.include_ancestors, down=args.include_descendants, relations=relations) subont = ont.subontology(nodes, relations=relations) ojr = OboJsonGraphRenderer() json_obj = ojr.to_json(subont, include_meta=args.include_meta) return json_obj
def get(self, ontology, node): """ Extract a subgraph from an ontology """ args = parser.parse_args() qnodes = [node] if args.cnode is not None: qnodes += args.cnode factory = OntologyFactory() ont = get_ontology(ontology) relations = args.relation print("Traversing: {} using {}".format(qnodes,relations)) nodes = ont.traverse_nodes(qnodes, up=args.include_ancestors, down=args.include_descendants, relations=relations) subont = ont.subontology(nodes, relations=relations) # TODO: meta is included regardless of whether include_meta is True or False ojr = OboJsonGraphRenderer(include_meta=args.include_meta) json_obj = ojr.to_json(subont) return json_obj
def get(self, id): """ Extract a subgraph from an ontology term """ args = subgraph_params.parse_args() qnodes = [id] if args.cnode is not None: qnodes += args.cnode # COMMENT: based on the CURIE of the id, we should be able to find out the ontology automatically ont = get_ontology("go") relations = args.relation print("Traversing: {} using {}".format(qnodes, relations)) nodes = ont.traverse_nodes(qnodes, up=args.include_ancestors, down=args.include_descendants, relations=relations) subont = ont.subontology(nodes, relations=relations) # TODO: meta is included regardless of whether include_meta is True or False ojr = OboJsonGraphRenderer(include_meta=args.include_meta) json_obj = ojr.to_json(subont, include_meta=args.include_meta) return json_obj