Skip to content

Commit 6699d52

Browse files
committed
removing mireot adding new import params
allowing is_large, use_base, use_gzipped on imports fixes #396
1 parent 6c1ed28 commit 6699d52

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

odk/odk.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ class ImportProduct(Product):
104104

105105
mirror_from: Optional[Url] = None
106106
"""if specified this URL is used rather than the default OBO PURL for the main OWL product"""
107+
108+
is_large: bool = False
109+
"""if large, ODK may take measures to reduce the memory footprint of the import."""
110+
111+
use_base: bool = False
112+
"""if use_base is true, try use the base IRI instead of normal one to mirror from."""
113+
114+
use_gzipped: bool = False
115+
"""if use_gzipped is true, try use the base IRI instead of normal one to mirror from."""
107116

108117
@dataclass_json
109118
@dataclass
@@ -228,7 +237,7 @@ class ImportGroup(ProductGroup):
228237
"""all import products"""
229238

230239
module_type : str = "slme"
231-
"""Module type. Supported: slme, mireot, minimal, custom"""
240+
"""Module type. Supported: slme, minimal, custom"""
232241

233242
module_type_slme : str = "BOT"
234243
"""SLME module type. Supported: BOT, TOP, STAR"""

template/src/ontology/Makefile.jinja2

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,6 @@ imports/%_import.owl: mirror/%.owl imports/%_terms_combined.txt
254254
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/postprocess-module.ru \
255255
remove --term rdfs:label -T imports/$*_terms_combined.txt --select complement --select "classes individuals annotation-properties" \
256256
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@.tmp.owl && mv $@.tmp.owl $@; fi
257-
{% elif 'mireot' == project.import_group.module_type %}
258-
imports/%_import.owl: mirror/%.owl imports/%_terms_combined.txt
259-
if [ $(IMP) = true ]; then $(ROBOT) query -i $< --update ../sparql/preprocess-module.ru \
260-
extract -L imports/$*_terms_combined.txt -U imports/$*_terms_combined.txt --force true --copy-ontology-annotations true --method MIREOT \
261-
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/postprocess-module.ru \
262-
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@.tmp.owl && mv $@.tmp.owl $@; fi
263257
{% elif 'custom' == project.import_group.module_type %}
264258
imports/%_import.owl: mirror/%.owl
265259
echo "ERROR: You have configured your default module type to be custom; this behavior needs to be overwritten in {{ project.id }}.Makefile!" && false
@@ -272,7 +266,29 @@ imports/%_import.owl: mirror/%.owl
272266
imports/%_import.obo: imports/%_import.owl
273267
if [ $(IMP) = true ]; then $(ROBOT) convert --check false -i $< -f obo -o $@.tmp.obo && mv $@.tmp.obo $@; fi
274268
{% endif -%}
275-
{% endif %}
269+
270+
{%- for ont in project.import_group.products -%}
271+
{% if ont.is_large -%}
272+
## Special treatment for large ontology: {{ ont.id }}
273+
{% if 'slme' == project.import_group.module_type %}
274+
imports/{{ ont.id }}_import.owl: mirror/{{ ont.id }}.owl imports/{{ ont.id }}_terms_combined.txt
275+
if [ $(IMP) = true ]; then $(ROBOT) extract -i $< -T imports/{{ ont.id }}_terms_combined.txt --force true --method {{ project.import_group.module_type_slme }} \
276+
query --update ../sparql/inject-subset-declaration.ru \
277+
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@.tmp.owl && mv $@.tmp.owl $@; fi
278+
{% elif 'minimal' == project.import_group.module_type %}
279+
imports/{{ ont.id }}_import.owl: mirror/{{ ont.id }}.owl imports/{{ ont.id }}_terms_combined.txt
280+
if [ $(IMP) = true ]; then $(ROBOT) extract -i $< -T imports/{{ ont.id }}_terms_combined.txt --force true --method BOT \
281+
remove --base-iri $(URIBASE)"/$(shell echo {{ ont.id }} | tr a-z A-Z)_" --axioms external --preserve-structure false --trim false \
282+
query --update ../sparql/inject-subset-declaration.ru \
283+
remove --term rdfs:label -T imports/{{ ont.id }}_terms_combined.txt --select complement --select "classes individuals annotation-properties" \
284+
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@.tmp.owl && mv $@.tmp.owl $@; fi
285+
{% elif 'custom' == project.import_group.module_type %}
286+
imports/{{ ont.id }}_import.owl: mirror/{{ ont.id }}.owl
287+
echo "ERROR: You have configured your default module type to be custom; this behavior needs to be overwritten in {{ project.id }}.Makefile!" && false
288+
{%- endif %}
289+
{%- endif %}
290+
{%- endfor %}
291+
{%- endif %}
276292

277293
{% if project.components is not none %}
278294
# ----------------------------------------
@@ -319,13 +335,27 @@ mirror/{{ ont.id }}.trigger: $(SRC)
319335
mirror/{{ ont.id }}.trigger:
320336
touch $@
321337
{% endif -%}
322-
{% if ont.mirror_from %}
338+
339+
{%- if ont.mirror_from %}
323340
mirror/{{ ont.id }}.owl: mirror/{{ ont.id }}.trigger
324341
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I {{ ont.mirror_from }} -o $@.tmp.owl && mv $@.tmp.owl $@; fi
325-
{% else %}
342+
{%- elif ont.use_base %}
343+
{%- if ont.use_gzipped %}
344+
mirror/{{ ont.id }}.owl: mirror/{{ ont.id }}.trigger
345+
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I $(URIBASE)/{{ ont.id }}/{{ ont.id }}-base.owl.gz -o $@.tmp.owl && mv $@.tmp.owl $@; fi
346+
{%- else %}
347+
mirror/{{ ont.id }}.owl: mirror/{{ ont.id }}.trigger
348+
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I $(URIBASE)/{{ ont.id }}/{{ ont.id }}-base.owl -o $@.tmp.owl && mv $@.tmp.owl $@; fi
349+
{%- endif %}
350+
{%- else %}
351+
{%- if ont.use_gzipped %}
352+
mirror/{{ ont.id }}.owl: mirror/{{ ont.id }}.trigger
353+
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I $(URIBASE)/{{ ont.id }}.owl.gz -o $@.tmp.owl && mv $@.tmp.owl $@; fi
354+
{%- else %}
326355
mirror/{{ ont.id }}.owl: mirror/{{ ont.id }}.trigger
327356
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I $(URIBASE)/{{ ont.id }}.owl -o $@.tmp.owl && mv $@.tmp.owl $@; fi
328-
{% endif %}
357+
{%- endif %}
358+
{%- endif %}
329359
.PRECIOUS: mirror/%.owl
330360
{% endfor -%}
331361
{% endif %}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
id: modmini
2+
title: "Test ROBOT extract minimal with base and large option"
3+
github_org: INCATools
4+
repo: ontology-development-kit
5+
edit_format: obo
6+
export_formats:
7+
- owl
8+
- obo
9+
- json
10+
import_group:
11+
products:
12+
- id: ro
13+
use_base: TRUE
14+
- id: pato
15+
is_large: TRUE
16+
module_type: minimal
17+

0 commit comments

Comments
 (0)