Skip to content

Commit a8230e7

Browse files
authored
Merge pull request #18 from INCATools/orcidio-support
Add basic support for ORCIDIO.
2 parents ac5c30a + c973b3d commit a8230e7

6 files changed

Lines changed: 76 additions & 3 deletions

File tree

src/incatools/odk/model.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,16 @@ class OntologyProject(JsonSchemaMixin):
11431143
release_diff: bool = False
11441144
"""Generates a diff with the previous release."""
11451145

1146+
orcidio_support: bool = False
1147+
"""Enables the automatic production of an ORCIDIO import module.
1148+
1149+
If enabled, this option will cause the build pipeline to (1) scan
1150+
the ontology for references to ORCID identifiers in all IRI-valued
1151+
annotations, and (2) create a orcidio_import.owl import module
1152+
containing all ORCIDIO individuals corresponding to the referenced
1153+
ORCID identifiers.
1154+
"""
1155+
11461156
robot: RobotOptionsGroup = field(default_factory=lambda: RobotOptionsGroup())
11471157
"""ROBOT-related options."""
11481158

src/incatools/odk/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
SSSOM_SOURCE = "https://github.com/gouttegd/sssom-java/releases/download/sssom-java-1.11.2/sssom-cli-1.11.2.jar"
2525
DOSDP_SOURCE = "https://github.com/INCATools/dosdp-tools/releases/download/v0.20.0/dosdp-tools-0.20.0.tgz"
2626
RELGR_SOURCE = "https://github.com/INCATools/relation-graph/releases/download/v2.3.4/relation-graph-cli-2.3.4.tgz"
27-
ODK_PLUGIN_SOURCE = "https://github.com/INCATools/odk-robot-plugin/releases/download/odk-robot-plugin-0.3.1/odk.jar"
27+
ODK_PLUGIN_SOURCE = "https://github.com/INCATools/odk-robot-plugin/releases/download/odk-robot-plugin-0.3.3/odk.jar"
2828
SSSOM_PLUGIN_SOURCE = "https://github.com/gouttegd/sssom-java/releases/download/sssom-java-1.11.2/sssom-robot-plugin-1.11.2.jar"
2929
OBO_EPM_SOURCE = "https://raw.githubusercontent.com/biopragmatics/bioregistry/main/exports/contexts/obo.epm.json"
3030

src/incatools/odk/template.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ def update_import_declarations(self) -> None:
394394
cmd += f" --add {base}/patterns/definitions.owl"
395395
if self.project.import_pattern_ontology:
396396
cmd += f" --add {base}/patterns/pattern.owl"
397+
if self.project.orcidio_support:
398+
cmd += f" --add {base}/imports/orcidio_import.owl"
397399

398400
if self.project.edit_format == "owl":
399401
cmd += f" convert -f ofn -o {self.project.id}-edit.owl"

src/incatools/odk/templates/_dynamic_files.jinja2

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ proj
3232
{% endfor -%}
3333
{% endif -%}
3434
{% endif -%}
35+
{% if project.orcidio_support -%}
36+
import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl
37+
{% endif -%}
3538
{% if project.components is defined -%}
3639
{% for component in project.components.products -%}
3740
import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/components/{{ component.filename }}
@@ -89,7 +92,10 @@ Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ proj
8992
Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/{{ imp.id }}_import.owl>)
9093
{% endfor -%}
9194
{% endif -%}
92-
{% endif %}
95+
{% endif -%}
96+
{% if project.orcidio_support -%}
97+
Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl>)
98+
{% endif -%}
9399
{% if project.components is defined -%}
94100
{% for component in project.components.products -%}
95101
Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/components/{{ component.filename }}>)
@@ -256,6 +262,21 @@ Ontology(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ pr
256262
^^^ src/ontology/imports/{{ imp.id }}_terms.txt
257263
{% endfor -%}
258264
{% endif %}{# ! project.import_group is defined -#}
265+
{% if project.orcidio_support -%}
266+
^^^ src/ontology/imports/orcidio_import.owl
267+
Prefix(:=<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl>)
268+
Prefix(obo:=<http://purl.obolibrary.org/obo/>)
269+
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
270+
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
271+
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
272+
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
273+
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
274+
Prefix(oboInOwl:=<http://www.geneontology.org/formats/oboInOwl#>)
275+
276+
Ontology(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl>
277+
# This is a placeholder, it will be regenerated when makefile is first executed.
278+
)
279+
{% endif -%}
259280
{#
260281
261282
Metadata files.

src/incatools/odk/templates/src/ontology/Makefile.jinja2

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ IMPORTS = {% for imp in project.import_group.products %} {{ imp.id }}{% endfor %
249249
{% else %}
250250
IMPORTS =
251251
{% endif %}
252-
IMPORT_ROOTS = {% if project.import_group.use_base_merging %} $(IMPORTDIR)/merged_import{% else %}$(patsubst %, $(IMPORTDIR)/%_import, $(IMPORTS)){% endif %}
252+
IMPORT_ROOTS = {% if project.import_group.use_base_merging %} $(IMPORTDIR)/merged_import{% else %}$(patsubst %, $(IMPORTDIR)/%_import, $(IMPORTS)){% endif %}{% if project.orcidio_support %} $(IMPORTDIR)/orcidio_import{% endif %}
253253
IMPORT_OWL_FILES = $(foreach n,$(IMPORT_ROOTS), $(n).owl)
254254
{%- if project.import_group.export_obo %}
255255
IMPORT_OBO_FILES = $(foreach n,$(IMPORT_ROOTS), $(n).obo)
@@ -786,6 +786,43 @@ no-mirror-refresh-%:
786786

787787
{% endif %}{# !project.import_group is defined -#}
788788

789+
{% if project.orcidio_support -%}
790+
# ----------------------------------------
791+
# ORCIDIO module
792+
# ----------------------------------------
793+
794+
# By default, the ORCIDIO module is seeded from ORCID references in ALL
795+
# IRI-valued annotations in the ontology, regardless of the annotation
796+
# property. To seed only from annotations using specific properties,
797+
# override the following variable with the desired list of properties.
798+
ORCIDIO_PROPERTIES =
799+
800+
ifeq ($(IMP),true)
801+
$(IMPORTDIR)/orcidio_import.owl: $(SRCMERGED) $(MIRRORDIR)/orcidio.owl | all_robot_plugins
802+
$(ROBOT) odk:extract-orcids --input $(SRCMERGED) \
803+
--orcid-file $(MIRRORDIR)/orcidio.owl \
804+
$(foreach p, $(ORCIDIO_PROPERTIES),--property $(p)) \
805+
$(ANNOTATE_CONVERT_FILE)
806+
807+
endif
808+
809+
ifeq ($(MIR),true)
810+
.PHONY: download-mirror-orcidio
811+
download-mirror-orcidio: | $(TMPDIR) $(MIRRORDIR)
812+
@odk-helper download --output $(TMPDIR)/$@.owl \
813+
--reference $(MIRRORDIR)/orcidio.owl{% if project.import_group is defined %} \
814+
--max-retry {{ project.import_group.mirror_retry_download }}{% endif %} \
815+
https://w3id.org/orcidio/orcidio.owl
816+
817+
$(MIRRORDIR)/orcidio.owl: download-mirror-orcidio
818+
@if [ -f $(TMPDIR)/download-mirror-orcidio.owl ]; then \
819+
cp $(TMPDIR)/download-mirror-orcidio.owl $@ ; \
820+
fi
821+
822+
endif
823+
824+
{% endif -%}
825+
789826
{% if project.components is not none -%}
790827
# ----------------------------------------
791828
# Components

src/incatools/odk/templates/src/ontology/catalog-v001.xml.jinja2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
{%- endfor %}
1212
{%- endif %}
1313
{%- endif %}
14+
{%- if project.orcidio_support %}
15+
<uri name="{{project.uribase}}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl" uri="imports/orcidio_import.owl"/>
16+
{%- endif %}
1417
{%- if project.components is defined %}
1518
{%- for component in project.components.products %}
1619
<uri name="{{project.uribase}}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/components/{{component.filename}}" uri="components/{{component.filename}}"/>

0 commit comments

Comments
 (0)