https://github.com/cthoyt/ontology-access-kit

Ontology Access Kit

https://github.com/cthoyt/ontology-access-kit

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Ontology Access Kit

Basic Info
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Fork of INCATools/ontology-access-kit
Created about 4 years ago · Last pushed about 2 years ago
Metadata Files
Readme Contributing License Code of conduct

README.md

Ontology Access Kit (OAK)

Python lib for common ontology operations over a variety of backends.

PyPI version badge Downloads DOI Contributor Covenant

OAK provides a collection of interfaces for various ontology operations, including:

  • look up basic features of an ontology element, such as its label, definition, relationships, or aliases
  • search an ontology for a term
  • validate an ontology
  • modify or delete terms
  • generate and visualize subgraphs
  • identify lexical matches and export as SSSOM mapping tables
  • perform more advanced operations, such as graph traversal, OWL axiom processing, or text annotation

These interfaces are separated from any particular backend, for which there a number of different adapters. 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 BioPortal
  • is present locally on the filesystem in owl, obo, obojson, or sqlite formats
  • is to be downloaded from a remote repository such as the OBO library
  • is queried from a remote database, including SPARQL endpoints (Ontobee/Ubergraph), A SQL database, a Solr/ES endpoint

Documentation:

Contributing

See the contribution guidelines at CONTRIBUTING.md. All contributors are expected to uphold our Code of Conduct.

Usage

```python from oaklib import get_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)}')

for alias in adapter.entity_aliases(NEURON): print(f'Alias: {alias}')

print('## Relationships (direct)') for relationship in adapter.relationships([NEURON]): print(f' * {relationship.predicate} -> {relationship.object} "{adapter.label(relationship.object)}"')

print('## Ancestors (over ISA and PARTOF)') from oaklib.datamodels.vocabulary import ISA, PARTOF from oaklib.interfaces import OboGraphInterface

if not isinstance(adapter, OboGraphInterface): raise ValueError('This adapter does not support graph operations')

for ancestor in adapter.ancestors(NEURON, predicates=[ISA, PARTOF]): print(f' * ANCESTOR: "{adapter.label(ancestor)}"') ```

For more examples, see

Command Line

See:

  • CLI docs
  • [Example notebooks](https://github.com/INCATools/ontology-access-kit/tree/main/notebooks/Commands

Search

Use the pronto backend to fetch and parse an ontology from the OBO library, then use the search command

bash runoak -i obolibrary:pato.obo search osmol

Returns:

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 osmolarity

QC and Validation

Perform validation on PR using sqlite/rdftab instance:

bash runoak -i sqlite:../semantic-sql/db/pr.db validate

List all terms

List all terms obolibrary has for mondo

bash runoak -i obolibrary:mondo.obo terms

Lexical index

Make a lexical index of all terms in Mondo:

bash runoak -i obolibrary:mondo.obo lexmatch -L mondo.index.yaml

Search

Searching over OBO using ontobee:

bash runoak -i ontobee: search tentacle

yields:

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/BioPortalHelp#GettinganAPIkey)

bash runoak set-apikey bioportal YOUR-KEY-HERE runoak -i bioportal: search tentacle

yields:

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 "BIOPORTALAPIKEY" to your environment variables.

Searching over more limited set of ontologies in Ubergraph:

bash runoak -v -i ubergraph: search tentacle

yields UBERON:0013206 ! nasal tentacle

Annotating Texts

bash runoak -i bioportal: annotate neuron from CA4 region of hippocampus of mouse

yields:

```yaml objectid: CL:0000540 objectlabel: neuron objectsource: https://data.bioontology.org/ontologies/NIFDYS matchtype: PREF subjectstart: 1 subjectend: 6 subject_label: NEURON

objectid: http://www.co-ode.org/ontologies/galen#Neuron objectlabel: Neuron objectsource: https://data.bioontology.org/ontologies/GALEN matchtype: PREF subjectstart: 1 subjectend: 6 subject_label: NEURON

... ```

Mapping

Create a SSSOM mapping file for a set of ontologies:

bash robot merge -I http://purl.obolibrary.org/obo/hp.owl -I http://purl.obolibrary.org/obo/mp.owl convert --check false -o hp-mp.obo runoak lexmatch -i hp-mp.obo -o hp-mp.sssom.tsv

Visualization of ancestor graphs

Use the sqlite backend to visualize graph up from 'vacuole' using test ontology sqlite:

bash runoak -i sqlite:tests/input/go-nucleus.db viz GO:0005773

img

Same using ubergraph, restricting to is-a and part-of

bash runoak -i ubergraph: viz GO:0005773 -p i,BFO:0000050

Same using pronto, fetching ontology from obolibrary

bash runoak -i obolibrary:go.obo viz GO:0005773

Configuration

OAK uses pystow for caching. By default, this goes inside ~/.data/, but can be configured following these instructions.

Owner

  • Name: Charles Tapley Hoyt
  • Login: cthoyt
  • Kind: user
  • Location: Bonn, Germany
  • Company: RWTH Aachen University

GitHub Events

Total
Last Year

Dependencies

.github/workflows/doc_pages.yaml actions
  • JamesIves/github-pages-deploy-action v4.3.0 composite
  • actions/checkout main composite
  • actions/setup-python v3 composite
  • snok/install-poetry v1.3 composite
.github/workflows/main.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v4.3.0 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3.1.1 composite
.github/workflows/pypi-publish.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish v1.2.2 composite
  • snok/install-poetry v1.3.1 composite
poetry.lock pypi
  • 275 dependencies
pyproject.toml pypi
  • Sphinx >=6.1.3 develop
  • coverage ^6.3.2 develop
  • jupyter >=1.0.0 develop
  • linkml ^1.5.5 develop
  • myst-parser >=1.0.0 develop
  • pandas >=1.5.1 develop
  • pytest ^7.1.3 develop
  • sphinx-click >=4.4.0 develop
  • sphinx-copybutton 0.5.1 develop
  • sphinx-rtd-theme ^1.0.0 develop
  • sphinxcontrib-mermaid ^0.8.1 develop
  • SPARQLWrapper *
  • SQLAlchemy >=1.4.32
  • airium >=0.2.5
  • appdirs >=1.4.4
  • class-resolver >=0.4.2
  • click *
  • curies >=0.5.5
  • eutils >=0.6.0
  • funowl >=0.2.0
  • gilda >=1.0.0
  • kgcl-rdflib 0.5.0
  • kgcl-schema 0.6.0
  • lark >=1.1.2
  • linkml-renderer >=0.3.0
  • linkml-runtime >=1.5.3
  • llm *
  • ndex2 ^3.5.0
  • networkx >=2.7.1
  • ols-client >=0.1.1
  • ontoportal-client >=0.0.3
  • prefixmaps >=0.1.2
  • pronto >=2.5.0
  • pydantic *
  • pysolr ^3.9.0
  • pystow >=0.5.0
  • python >=3.9,<4.0.0
  • ratelimit >=2.2.1
  • requests-cache ^1.0.1
  • semsimian 0.2.1
  • semsql >=0.3.1
  • sssom >=0.3.38
  • sssom-schema >=0.11.0
  • urllib3 < 2