Package: oaklib
Ontology Access Kit (OAK)Python lib for common ontology operations over a variety of backends.OAK provides a collection ofinterfacesfor various ontology operations, including:look up basic featuresof an ontology element, such as its label, definition, relationships, or aliasessearch an ontology for a termvalidate an ontologymodify or delete termsgenerate and visualize subgraphsidentify lexical matches and export as SSSOM mapping tablesperform more advanced operations, such as graph traversal, OWL axiom processing, or text annotationThese interfaces areseparatedfrom any particular backend, for which there a number of differentadapters.
This means the same Python API and command line can be used regardless of whether the ontology:is served by a remote API such as OLS or BioPortalis present locally on the filesystem in owl, obo, obojson, or sqlite formatsis to be downloaded from a remote repository such as the OBO libraryis queried from a remote database, including SPARQL endpoints (Ontobee/Ubergraph), A SQL database, a Solr/ES endpointDocumentation:incatools.github.io/ontology-access-kitPresentations:Using the OAK command lineOBO Academy 2023Introduction to OAKOAK workshop 2022ContributingSee the contribution guidelines atCONTRIBUTING.md.
All contributors are expected to uphold ourCode of Conduct.Usagefromoaklibimportget_adapter# connect to the CL sqlite database adapter# (will first download if not already downloaded)adapter=get_adapter("sqlite:obo:cl")NEURON="CL:0000540"print('## Basic info')print(f'ID:{NEURON}')print(f'Label:{adapter.label(NEURON)}')foraliasinadapter.entity_aliases(NEURON):print(f'Alias:{alias}')print('## Relationships (direct)')forrelationshipinadapter.relationships([NEURON]):print(f' *{relationship.predicate}->{relationship.object}"{adapter.label(relationship.object)}"')print('## Ancestors (over IS_A and PART_OF)')fromoaklib.datamodels.vocabularyimportIS_A,PART_OFfromoaklib.interfacesimportOboGraphInterfaceifnotisinstance(adapter,OboGraphInterface):raiseValueError('This adapter does not support graph operations')forancestorinadapter.ancestors(NEURON,predicates=[IS_A,PART_OF]):print(f' * ANCESTOR: "{adapter.label(ancestor)}"')For more examples, seedemo notebooktutorial part 2Command LineSee:CLI docsExample notebooksSearchUse the pronto backend to fetch and parse an ontology from the OBO library, then use thesearchcommandrunoak-iobolibrary:pato.obosearchosmolReturns:PATO:0001655 ! osmolarity
PATO:0001656 ! decreased osmolarity
PATO:0001657 ! increased osmolarity
PATO:0002027 ! osmolality
PATO:0002028 ! decreased osmolality
PATO:0002029 ! increased osmolality
PATO:0045034 ! normal osmolality
PATO:0045035 ! normal osmolarityQC and ValidationPerform validation on PR using sqlite/rdftab instance:runoak-isqlite:../semantic-sql/db/pr.dbvalidateList all termsList all terms obolibrary has for mondorunoak-iobolibrary:mondo.obotermsLexical indexMake a lexical index of all terms in Mondo:runoak-iobolibrary:mondo.obolexmatch-Lmondo.index.yamlSearchSearching over OBO using ontobee:runoak-iontobee:searchtentacleyields:http://purl.obolibrary.org/obo/CEPH_0000256 ! tentacle
http://purl.obolibrary.org/obo/CEPH_0000257 ! tentacle absence
http://purl.obolibrary.org/obo/CEPH_0000258 ! tentacle pad
...Searching over a broader set of ontologies in bioportal (requires API KEY)
(https://www.bioontology.org/wiki/BioPortal_Help#Getting_an_API_key)runoakset-apikeybioportalYOUR-KEY-HERE
runoak-ibioportal:searchtentacleyields:BTO:0001357 ! tentacle
http://purl.jp/bio/4/id/200906071014668510 ! tentacle
CEPH:0000256 ! tentacle
http://www.projecthalo.com/aura#Tentacle ! Tentacle
CEPH:0000256 ! tentacle
...Alternatively, you can add "BIOPORTAL_API_KEY" to your environment variables.Searching over more limited set of ontologies in Ubergraph:runoak-v-iubergraph:searchtentacleyieldsUBERON:0013206 ! nasal tentacleAnnotating Textsrunoak-ibioportal:annotateneuronfromCA4regionofhippocampusofmouseyields:object_id:CL:0000540object_label:neuronobject_source:https://data.bioontology.org/ontologies/NIFDYSmatch_type:PREFsubject_start:1subject_end:6subject_label:NEURONobject_id:http://www.co-ode.org/ontologies/galen#Neuronobject_label:Neuronobject_source:https://data.bioontology.org/ontologies/GALENmatch_type:PREFsubject_start:1subject_end:6subject_label:NEURON...MappingCreate a SSSOM mapping file for a set of ontologies:robotmerge-Ihttp://purl.obolibrary.org/obo/hp.owl-Ihttp://purl.obolibrary.org/obo/mp.owlconvert--checkfalse-ohp-mp.obo
runoaklexmatch-ihp-mp.obo-ohp-mp.sssom.tsvVisualization of ancestor graphsUse the sqlite backend to visualize graph up from 'vacuole' using test ontology sqlite:runoak-isqlite:tests/input/go-nucleus.dbvizGO:0005773Same using ubergraph, restricting to is-a and part-ofrunoak-iubergraph:vizGO:0005773-pi,BFO:0000050Same using pronto, fetching ontology from obolibraryrunoak-iobolibrary:go.obovizGO:0005773ConfigurationOAK usespystowfor caching. By default,
this goes inside~/.data/, but can be configured followingthese instructions.