Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial robot template implementation. #722

Merged
merged 9 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/packages/implementations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ Implementations (also known as *adapters*) implement one or more :ref:`interface
gilda
aggregator
pantherdb
robot-template
llm
85 changes: 85 additions & 0 deletions docs/packages/implementations/robot-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
.. _robot_template_implementation:

ROBOT Template Adapter
=============

.. warning::

This is experimental and incomplete.

This is an extension of the abstract :ref:`TabularInterface` adapter that provides
access to a collection of `ROBOT templates <http://robot.obolibrary.org/template>`_.

Note that it does *NOT* use the ROBOT tool itself to access these, it uses custom
code that only implements a portion of the spec.

One of the main driving use cases here is to enable KGCL commands with ontologies that use ROBOT
templates.

For example, the `OBI templates folder on GitHub <https://github.com/obi-ontology/obi/tree/016ca67c7e6f31a048780cee56afde24d4af7125/src/ontology/templates>`_
contains a collection of ROBOT templates.

- assays.tsv
- biobank-specimens.tsv
- ...

Assuming these are in a local path ``my/path/templates``, you can use a selector:

.. code-block:: bash

runoak -i robottemplate:my/path/templates COMMAND ...

Or in python:

.. code-block:: python

from oaklib import get_adapter
adapter = get_adapter('robottemplate:my/path/templatestemplates')

Note that this does NOT trigger compilation of the templates into OWL - this implementation works
on the templates as a collection of TSVs, facilitating update operations.

Command Line Examples
----------------------

From here we assume your templates are in a local folder ``./templates``.

Basic operations
~~~~~~~~~~~~~~~~

Currently very few operations are supported, but you can do basic things like:

.. code-block:: bash

runoak -i robottemplate:templates info OBI:0002516

Returns:

- OBI:0002516 ! brain specimen

Or limited search:

runoak -i robottemplate:templates info l~brain

Returns:

- OBI:0002516 ! brain specimen
- OBI:0003357 ! brain region atlas image data set
- ...

Applying KGCL commands
~~~~~~~~~~~~~~~~~~~~~~~

You can also apply KGCL commands:

.. code-block:: bash

runoak -i robottemplate:templates apply \
"rename OBI:0002516 from 'brain specimen' to 'brain sample'" -o new_templates

This will create a new copy of all templates in ``new_templates``, with the label
column modified in biobank-specimens.tsv

.. warning::

only a small subset of KGCL is implemented so far.
2 changes: 2 additions & 0 deletions src/oaklib/datamodels/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
HAS_NARROW_SYNONYM = omd.slots.has_narrow_synonym.curie
HAS_RELATED_SYNONYM = omd.slots.has_related_synonym.curie
SKOS_ALT_LABEL = "skos:altLabel"
IAO_ALTERNATIVE_LABEL = "IAO:0000118"
SYNONYM_PREDICATES = [
HAS_RELATED_SYNONYM,
HAS_NARROW_SYNONYM,
HAS_EXACT_SYNONYM,
HAS_BROAD_SYNONYM,
SKOS_ALT_LABEL,
IAO_ALTERNATIVE_LABEL,
]

SCOPE_TO_SYNONYM_PRED_MAP = {
Expand Down
2 changes: 2 additions & 0 deletions src/oaklib/implementations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
)
from oaklib.implementations.sparql.sparql_implementation import SparqlImplementation
from oaklib.implementations.sqldb.sql_implementation import SqlImplementation
from oaklib.implementations.tabular.robot_template_implementation import RobotTemplateImplementation
from oaklib.implementations.translator.translator_implementation import (
TranslatorImplementation,
)
Expand Down Expand Up @@ -97,6 +98,7 @@
"GildaImplementation",
"LLMImplementation",
"KGXImplementation",
"RobotTemplateImplementation",
"UniprotImplementation",
"TranslatorImplementation",
"OakMetaModelImplementation",
Expand Down
Empty file.
Loading
Loading