Package: ontquery
ontquerya framework querying ontology termsInstallationOntquery supports two different use cases each with their own installation instructions.By default ontquery installs only the stripped down core libraries so that it can be embedded an reused in
other applications that need to reduce their dependnecies. For this use case packages can include ontquery
as a dependency in their package requirements without any special changes e.g.ontquery>=0.0.6.The second use case enables remote services via a plugin infrastructure.
To install this version you should install or require using thepip extras syntaxe.g.pip install "ontquery[services]".SciCrunch api keyIf you don't have your own SciGraph instance you will need a SciCunch API key in order to run the demos (e.g.python __init__.py).To do this go to SciCrunch andregister for an accountand thenget an api key.You can then set theSCICRUNCH_API_KEYenvironment variable.
For example in bashexport SCICRUNCH_API_KEY=my-api-key.Seehttps://github.com/tgbugs/ontquery/blob/db8cad7463704bce9010651c3744452aa5370114/ontquery/__init__.py#L557-L558for how to pass the key in.SciGraphRemote UsagefromontqueryimportOntQuery,OntTerm,OntCuriesfromontquery.plugins.namespaces.nifstdimportCURIE_MAPfromontquery.plugins.services.scigraphimportSciGraphRemotecuries=OntCuries(CURIE_MAP)query=OntQuery(SciGraphRemote(),instrumented=OntTerm)OntTerm.query=querylist(query('mouse'))3 potential matches are shown:Query{'term':'mouse','limit':10}returnedmorethanoneresult.Pleasereview.OntTerm('NCBITaxon:10090',label='Mus musculus',synonyms=['mouse','house mouse','mice C57BL/6xCBA/CaJ hybrid','Mus muscaris'])OntTerm('NCBITaxon:10088',label='Mus <mouse, genus>',synonyms=['mouse','Mus','mice'])OntTerm('BIRNLEX:167',label='Mouse',synonyms=['mouse','Mus musculus','house mouse'])The one we are looking for isMus musculus, and we can select that withOntTerm('NCBITaxon:10090', label='Mus musculus')or withOntTerm(curie='NCBITaxon:10090').This workflow works for a variety of categories:species (e.g. 'mouse', 'rat', 'rhesus macaque')brain area (e.g. 'hippocampus', 'CA1', 'S1')cell type (e.g. 'mossy cell', 'pyramidal cell')institution (e.g. 'UC San Francisco', 'Brown University')disease (e.g. "Parkinson's Disease", 'ALS')Building for releasepython setup.py sdist --release && python setup.py bdist_wheel --universal --releaseBuilding a release requires a working install of pyontutils in order to build the
scigraph client library. The--releasetells setup to build the scigraph client.Related issueshttps://github.com/NeurodataWithoutBorders/nwb-schema/issues/1#issuecomment-368741867https://github.com/NeurodataWithoutBorders/nwb-schema/issues/1#issuecomment-369215854InterlexRemote Notesilx_id and any key that takes a uri value can also be given a curie of that uri or a fragment and it will still work.InterLexRemote UsageTo access InterLex programatically you can setSCICRUNCH_API_KEYor
you can setINTERLEX_API_KEYeither will work, butINTERLEX_API_KEYhas priority if both are set.Importing:fromontquery.interleximportinterlex_clientSetup forTEST:This Should be used to test if your code works firstilx_cli=interlex_client('test3.scicrunch.org')Setup forPRODUCTION:ilx_cli=interlex_client('scicrunch.org')Adding Entity Needed:added_entity_data=ilx_cli.add_entity(label='',type='',# term, fde, cde, pde, relationship, annotation)Adding Entity Exampleadded_entity_data=ilx_cli.add_entity(label='Label of entity you wish to create',type='A type that should be one of the following: term, relationship, annotation, cde, fde, pde',# subThingOf can take either iri or curie form of IDsubThingOf='http://uri.interlex.org/base/ilx_0108124',# superclass or subClassOf ILX IDdefinition='Entities definition',comment='A comment to help understand entity',synonyms=['synonym1',{'literal':'synonym2','type':'hasExactSynonym'},'etc'],# exisiting IDs are List[dict] with keys iri & curieexisting_ids=[{'iri':'https://example.org/example_1','curie':'EXAMPLE:1'}],cid=504,# community IDpredicates={# annotation_entity_ilx_id : 'annotation_value','http://uri.interlex.org/base/tmp_0381624':'PMID:12345',# annotation# relationship_entity_ilx_id : 'entity2_ilx_id','http://uri.interlex.org/base/ilx_0112772':'http://uri.interlex.org/base/ilx_0100001',# relationship})Updating Entity Exampleupdated_entity=update_entity(ilx_id='ilx_1234567',label='Brain',type='term',# options: term, pde, fde, cde, annotation, or relationshipdefinition='Official definition for entity.',comment='Additional casual notes for the next person.',superclass='ilx_1234567',add_synonyms=[{'literal':'Better Brains',# label of synonym'type':'obo:hasExactSynonym',# Often predicate defined in ref ontology.}],delete_synonyms=[{'literal':'Brains',# label of synonym'type':'obo:hasExactSynonym',# Often predicate defined in ref ontology.}],add_existing_ids=[{'iri':'http://purl.obolibrary.org/obo/UBERON_0000956','curie':'UBERON:0000956',# Obeys prefix:id structure.'preferred':'1',# Can be 0 or 1 with a type of either str or int.}],delet_existing_ids=[{'iri':'http://purl.obolibrary.org/obo/UBERON_0000955','curie':'UBERON:0000955',# Obeys prefix:id structure.}],cid='504',# SPARC Community,status='0',# remove delete)