diff --git a/src/incatools/odk/model.py b/src/incatools/odk/model.py index 4216f8e..c326cf4 100644 --- a/src/incatools/odk/model.py +++ b/src/incatools/odk/model.py @@ -548,6 +548,12 @@ def derive_fields(self, project: OntologyProject) -> None: self.import_names.append("merged") for p in self.products: + if p.id == "orcidio" and p.module_type is None: + p.module_type = "orcidio" + if p.module_type == "orcidio": + p.exclude_from_merge = True + if p.mirror_from is None: + p.mirror_from = "https://w3id.org/orcidio/orcidio.owl" if p.module_type is None: # Use group-level module type p.module_type = self.module_type @@ -1195,16 +1201,6 @@ class OntologyProject(JsonSchemaMixin): release_diff: bool = False """Generates a diff with the previous release.""" - orcidio_support: bool = False - """Enables the automatic production of an ORCIDIO import module. - - If enabled, this option will cause the build pipeline to (1) scan - the ontology for references to ORCID identifiers in all IRI-valued - annotations, and (2) create a orcidio_import.owl import module - containing all ORCIDIO individuals corresponding to the referenced - ORCID identifiers. - """ - robot: RobotOptionsGroup = field(default_factory=lambda: RobotOptionsGroup()) """ROBOT-related options.""" diff --git a/src/incatools/odk/template.py b/src/incatools/odk/template.py index a48b80b..ed42d9e 100644 --- a/src/incatools/odk/template.py +++ b/src/incatools/odk/template.py @@ -391,8 +391,6 @@ def update_import_declarations(self) -> None: cmd += f" --add {base}/patterns/definitions.owl" if self.project.import_pattern_ontology: cmd += f" --add {base}/patterns/pattern.owl" - if self.project.orcidio_support: - cmd += f" --add {base}/imports/orcidio_import.owl" if self.project.edit_format == "owl": cmd += f" convert -f ofn -o {self.project.id}-edit.owl" diff --git a/src/incatools/odk/templates/_dynamic_files.jinja2 b/src/incatools/odk/templates/_dynamic_files.jinja2 index bcbea78..b25922e 100644 --- a/src/incatools/odk/templates/_dynamic_files.jinja2 +++ b/src/incatools/odk/templates/_dynamic_files.jinja2 @@ -28,9 +28,6 @@ format-version: 1.2 import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/{{ name }}_import.owl {% endfor -%} {% endif -%} -{% if project.orcidio_support -%} -import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl -{% endif -%} {% if project.components is defined -%} {% for component in project.components.products -%} import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/components/{{ component.filename }} @@ -85,9 +82,6 @@ Ontology(<{{ project.uribase }}/{{ project.id }}.owl> Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/{{ name }}_import.owl>) {% endfor -%} {% endif -%} -{% if project.orcidio_support -%} -Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl>) -{% endif -%} {% if project.components is defined -%} {% for component in project.components.products -%} Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/components/{{ component.filename }}>) @@ -230,24 +224,11 @@ Ontology(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ pr -#} {% for imp in project.import_group.products -%} +{% if imp.module_type != "orcidio" -%} ^^^ src/ontology/imports/{{ imp.id }}_terms.txt +{% endif -%} {% endfor -%} {% endif %}{# ! project.import_group is defined -#} -{% if project.orcidio_support -%} -^^^ src/ontology/imports/orcidio_import.owl -Prefix(:=<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl>) -Prefix(obo:=) -Prefix(owl:=) -Prefix(rdf:=) -Prefix(xml:=) -Prefix(xsd:=) -Prefix(rdfs:=) -Prefix(oboInOwl:=) - -Ontology(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/orcidio_import.owl> -# This is a placeholder, it will be regenerated when makefile is first executed. -) -{% endif -%} {# Metadata files. diff --git a/src/incatools/odk/templates/src/ontology/Makefile.jinja2 b/src/incatools/odk/templates/src/ontology/Makefile.jinja2 index fa8989c..863d99a 100644 --- a/src/incatools/odk/templates/src/ontology/Makefile.jinja2 +++ b/src/incatools/odk/templates/src/ontology/Makefile.jinja2 @@ -766,6 +766,19 @@ $(IMPORTDIR)/{{ ont.id }}_import.owl: $(MIRRORDIR)/{{ ont.id }}.owl $(IMPORTDIR) --select complement \ --select "classes individuals annotation-properties" \ $(ANNOTATE_CONVERT_FILE) +{% elif "orcidio" == ont.module_type -%} +# By default, an ORCIDIO module is seeded from ORCID references in ALL +# IRI-valued annotations in the ontology, regardless of the annotation +# property. To seed only from annotations using specific properties, +# override the following variable with the desired list of properties. +ORCIDIO_PROPERTIES = + +$(IMPORTDIR)/{{ ont.id }}_import.owl: $(SRCMERGED) $(MIRRORDIR)/{{ ont.id }}.owl | all_robot_plugins + $(ROBOT) odk:extract-orcids --input $(SRCMERGED) \ + --orcid-file $(MIRRORDIR)/{{ ont.id }}.owl \ + $(foreach p, $(ORCIDIO_PROPERTIES), --property $(p)) \ + $(ANNOTATE_CONVERT_FILE) + {% elif 'custom' -%} $(IMPORTDIR)/{{ ont.id }}_import.owl: {% if "no_mirror" != ont.mirror_type %}$(MIRRORDIR)/{{ ont.id }}.owl{% endif %} @echo "ERROR: You have configured {{ ont.id }} as a custom module;" @@ -787,8 +800,7 @@ $(IMPORTDIR)/%_import.obo: $(IMPORTDIR)/%_import.owl endif # IMP=true .PHONY: all_imports -all_imports: $(IMPORT_FILES){# -#} - {% if project.orcidio_support %} $(IMPORTDIR)/orcidio_import.owl{% endif %} +all_imports: $(IMPORT_FILES) .PHONY: refresh-imports refresh-imports: @@ -925,49 +937,6 @@ no-mirror-recreate-%: {% endif %}{# ! project.components is not none -#} -{% if project.orcidio_support -%} -# ---------------------------------------- -# Special components -# ---------------------------------------- - -# ORCIDIO module -# ---------------------------------------- - -# By default, the ORCIDIO module is seeded from ORCID references in ALL -# IRI-valued annotations in the ontology, regardless of the annotation -# property. To seed only from annotations using specific properties, -# override the following variable with the desired list of properties. -ORCIDIO_PROPERTIES = - -ifeq ($(IMP),true) -$(IMPORTDIR)/orcidio_import.owl: $(SRCMERGED) $(MIRRORDIR)/orcidio.owl | all_robot_plugins - $(ROBOT) odk:extract-orcids --input $(SRCMERGED) \ - --orcid-file $(MIRRORDIR)/orcidio.owl \ - $(foreach p, $(ORCIDIO_PROPERTIES), --property $(p)) \ - $(ANNOTATE_CONVERT_FILE) - -endif - -ifeq ($(MIR),true) -.PHONY: download-mirror-orcidio -download-mirror-orcidio: | $(TMPDIR) $(MIRRORDIR) - @odk-helper download --output $(TMPDIR)/$@.owl \ - --reference $(MIRRORDIR)/orcidio.owl \ - {% if project.import_group is defined -%} - --max-retry {{ project.import_group.mirror_retry_download }} \ - {% endif -%} - https://w3id.org/orcidio/orcidio.owl - -$(MIRRORDIR)/orcidio.owl: download-mirror-orcidio - @if [ -f $(TMPDIR)/download-mirror-orcidio.owl ]; then \ - cp $(TMPDIR)/download-mirror-orcidio.owl $@ ; \ - fi - -endif - - -{% endif %}{# !project.orcidio_support -#} - {% if project.use_mappings or project.bridge_group is not none -%} # ---------------------------------------- # Mappings and bridges @@ -1889,9 +1858,6 @@ ASSETS = $(MAIN_FILES){# -#} {% if project.import_group is not none %} \ $(IMPORT_FILES){# -#} {% endif -%} - {% if project.orcidio_support %} \ - $(IMPORTDIR)/orcidio_import.owl{# -#} - {% endif -%} {% if project.use_dosdps %} \ $(PATTERN_RELEASE_FILES){# -#} {% endif -%} diff --git a/src/incatools/odk/templates/src/ontology/catalog-v001.xml.jinja2 b/src/incatools/odk/templates/src/ontology/catalog-v001.xml.jinja2 index 05ae1a6..2fff554 100644 --- a/src/incatools/odk/templates/src/ontology/catalog-v001.xml.jinja2 +++ b/src/incatools/odk/templates/src/ontology/catalog-v001.xml.jinja2 @@ -7,9 +7,6 @@ {%- endfor %} {%- endif %} -{%- if project.orcidio_support %} - -{%- endif %} {%- if project.components is defined %} {%- for component in project.components.products %} diff --git a/tests/configs/test-module-orcidio-with-base-merging.yaml b/tests/configs/test-module-orcidio-with-base-merging.yaml new file mode 100644 index 0000000..de47c88 --- /dev/null +++ b/tests/configs/test-module-orcidio-with-base-merging.yaml @@ -0,0 +1,12 @@ +id: modorcid +title: Test ORCIDIO import module type +github_org: INCATools +report_fail_on: ERROR +repo: modorcid +import_group: + use_base_merging: true + products: + - id: ro + - id: bfo + - id: pato + - id: orcidio diff --git a/tests/configs/test-module-orcidio.yaml b/tests/configs/test-module-orcidio.yaml new file mode 100644 index 0000000..07e841c --- /dev/null +++ b/tests/configs/test-module-orcidio.yaml @@ -0,0 +1,11 @@ +id: modorcid +title: Test ORCIDIO import module type +github_org: INCATools +report_fail_on: ERROR +repo: modorcid +import_group: + products: + - id: ro + - id: bfo + - id: pato + - id: orcidio