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): """ For a given gene(s), summarize its annotations over a defined set of slim """ args = self.function_parser.parse_args() slim = args.get('slim') del args['slim'] subjects = args.get('subject') del args['subject'] # Note that GO currently uses UniProt as primary ID for some sources: https://github.com/biolink/biolink-api/issues/66 # https://github.com/monarch-initiative/dipper/issues/461 sg_dev = SciGraph(get_biolink_config()['scigraph_data']['url']) subjects = [ x.replace('WormBase:', 'WB:') if 'WormBase:' in x else x for x in subjects ] slimmer_subjects = [] for s in subjects: if 'HGNC:' in s or 'NCBIGene:' in s or 'ENSEMBL:' in s: prots = identifier_converter.convert_gene_to_protein(s) if len(prots) == 0: prots = [s] slimmer_subjects += prots else: slimmer_subjects.append(s) results = map2slim(subjects=slimmer_subjects, slim=slim, object_category='function', user_agent=USER_AGENT, **args) # To the fullest extent possible return HGNC ids checked = {} for result in results: for association in result['assocs']: taxon = association['subject']['taxon']['id'] proteinId = association['subject']['id'] if taxon == 'NCBITaxon:9606' and proteinId.startswith( 'UniProtKB:'): if proteinId not in checked: genes = identifier_converter.convert_protein_to_gene( proteinId) for gene in genes: if gene.startswith('HGNC'): association['subject']['id'] = gene checked[proteinId] = gene else: association['subject']['id'] = checked[proteinId] return results
def __init__(self): self.scigraph = SciGraph(get_biolink_config()['scigraph_data']['url'])
import logging from flask import request from flask_restplus import Resource, inputs from biolink.datamodel.serializers import bbop_graph, bio_object from biolink.error_handlers import NoResultFoundException, UnhandledException from scigraph.scigraph_util import SciGraph from scigraph.model.BBOPGraph import BBOPGraph from biolink.api.restplus import api from biolink.settings import get_biolink_config log = logging.getLogger(__name__) sg_data = SciGraph(get_biolink_config()['scigraph_data']['url']) sg_ont = SciGraph(get_biolink_config()['scigraph_ontology']['url']) @api.doc(params={'id': 'CURIE e.g. HP:0000465'}) class NodeResource(Resource): @api.marshal_list_with(bio_object) def get(self, id): """ Returns a graph node. A node is an abstract representation of some kind of entity. The entity may be a physical thing such as a patient, a molecular entity such as a gene or protein, or a conceptual entity such as a class from an ontology. """ graph = sg_data.bioobject(id) return graph
import logging from flask import request from flask_restplus import Resource, inputs from biolink.datamodel.serializers import association, bbop_graph, bio_object from biolink.error_handlers import NoResultFoundException from scigraph.scigraph_util import SciGraph from scigraph.model.BBOPGraph import BBOPGraph from biolink.api.restplus import api from biolink.settings import get_biolink_config log = logging.getLogger(__name__) sg = SciGraph(get_biolink_config()['scigraph_data']['url']) @api.doc(params={'id': 'CURIE e.g. HP:0000465'}) class NodeResource(Resource): @api.marshal_list_with(bio_object) def get(self, id): """ Returns a graph node. A node is an abstract representation of some kind of entity. The entity may be a physical thing such as a patient, a molecular entity such as a gene or protein, or a conceptual entity such as a class from an ontology. """ graph = sg.bioobject(id) return graph @api.doc(params={'id': 'CURIE e.g. HP:0000465'})
import logging from ontobio.ontol_factory import OntologyFactory from biolink.settings import get_biolink_config cfg = get_biolink_config() omap = {} def get_ontology(id): handle = id for c in cfg['ontologies']: if c['id'] == id: logging.info("getting handle for id: {} from cfg".format(id)) handle = c['handle'] if handle not in omap: logging.info("Creating a new ontology object for {}".format(handle)) ofa = OntologyFactory() omap[handle] = ofa.create(handle) else: logging.info("Using cached for {}".format(handle)) return omap[handle]
default=False, help='Should only the longest entity be returned for an overlapping group') parser.add_argument('include_abbreviation', type=inputs.boolean, default=False, help='Should abbreviations be included') parser.add_argument('include_acronym', type=inputs.boolean, default=False, help='Should acronyms be included') parser.add_argument('include_numbers', type=inputs.boolean, default=False, help='Should numbers be included') scigraph = SciGraph(get_biolink_config()['scigraph_ontology']['url']) def parse_args_for_annotator(parser): """ Convenience method for parsing and preparing parameters for SciGraph annotator """ args = parser.parse_args() if 'include_category' in args: val = args.pop('include_category') args['includeCat'] = val if 'exclude_category' in args: val = args.pop('exclude_category') args['excludeCat'] = val if 'min_length' in args: val = args.pop('min_length')