-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathMakefile.jinja2
1468 lines (1235 loc) · 77.7 KB
/
Makefile.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{#-
Jinja2 Template for Makefile
This file is a template that generates the Makefile.
This comment will not be included.
See: http://jinja.pocoo.org/docs/2.10/templates
-#}
# ----------------------------------------
# Makefile for {{ project.id }}
# Generated using ontology-development-kit
# ODK Version: {% if env is defined %}{{env['ODK_VERSION'] or "Unknown" }}{% else %}"Unknown"{% endif %}
# ----------------------------------------
# IMPORTANT: DO NOT EDIT THIS FILE. To override default make goals, use {{ project.id }}.Makefile instead
{{ project.custom_makefile_header }}
{%- if project.config_hash %}
# Fingerprint of the configuration file when this Makefile was last generated
CONFIG_HASH= {{ project.config_hash }}
{% endif %}
# ----------------------------------------
# Standard Constants
# ----------------------------------------
# these can be overwritten on the command line
OBOBASE= http://purl.obolibrary.org/obo
URIBASE= {{ project.uribase }}
ONT= {{ project.id }}
ONTBASE= {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}
EDIT_FORMAT= {{ project.edit_format|default('owl') }}
SRC = $(ONT)-edit.$(EDIT_FORMAT)
MAKE_FAST= $(MAKE) IMP=false PAT=false COMP=false MIR=false
CATALOG= {{ project.catalog_file }}
ROBOT= robot --catalog $(CATALOG)
REASONER= {{ project.reasoner }}
{% if project.owltools_memory|length %}OWLTOOLS_MEMORY= {{ project.owltools_memory }}{% endif %}
OWLTOOLS= {% if project.owltools_memory|length %}OWLTOOLS_MEMORY=$(OWLTOOLS_MEMORY) {% endif %}owltools --use-catalog
RELEASEDIR= ../..
DOCSDIR= ../../docs
REPORTDIR= reports
TEMPLATEDIR= ../templates
TMPDIR= tmp
MIRRORDIR= mirror
IMPORTDIR= imports
SUBSETDIR= subsets
SCRIPTSDIR= ../scripts
UPDATEREPODIR= target
SPARQLDIR = ../sparql
COMPONENTSDIR = {{ project.components.directory|default('components') }}
{%- if project.robot_report.custom_profile %}
ROBOT_PROFILE = profile.txt
{%- endif %}
REPORT_FAIL_ON = {{ project.robot_report.fail_on|default('None') }}
REPORT_LABEL = {% if project.robot_report.use_labels|default(true) %}-l true{% endif %}
REPORT_PROFILE_OPTS = {% if project.robot_report.custom_profile %}--profile $(ROBOT_PROFILE){% endif %}
OBO_FORMAT_OPTIONS = {{ project.obo_format_options }}
SPARQL_VALIDATION_CHECKS = {% for x in project.robot_report.custom_sparql_checks|default(['owldef-self-reference', 'iri-range', 'label-with-iri', 'multiple-replaced_by']) %}{{ x }} {% endfor %}
SPARQL_EXPORTS = {% for x in project.robot_report.custom_sparql_exports|default(['basic-report', 'class-count-by-prefix', 'edges', 'xrefs', 'obsoletes', 'synonyms']) %}{{ x }} {% endfor %}
ODK_VERSION_MAKEFILE = {% if env is defined %}{{env['ODK_VERSION'] or "Unknown" }}{% else %}"Unknown"{% endif %}
RELAX_OPTIONS = --include-subclass-of true
TODAY ?= $(shell date +%Y-%m-%d)
OBODATE ?= $(shell date +'%d:%m:%Y %H:%M')
VERSION= $(TODAY)
ANNOTATE_ONTOLOGY_VERSION = annotate -V $(ONTBASE)/releases/$(VERSION)/$@ --annotation owl:versionInfo $(VERSION)
ANNOTATE_CONVERT_FILE = annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) convert -f {{ project.import_component_format|default('ofn') }} --output [email protected] && mv [email protected] $@
OTHER_SRC = {% if project.use_dosdps -%}$(PATTERNDIR)/definitions.owl {% endif -%}{% if project.components is defined -%}{% for component in project.components.products -%}$(COMPONENTSDIR)/{{ component.filename }} {% endfor -%}{% endif %}
ONTOLOGYTERMS = $(TMPDIR)/ontologyterms.txt
EDIT_PREPROCESSED = $(TMPDIR)/$(ONT)-preprocess.owl
{%- if project.use_context %}
CONTEXT_FILE = config/context.json
{%- if 'db' in project.export_formats %}
CONTEXT_FILE_CSV = $(TMPDIR)/context.csv
{%- endif %}
{%- endif %}
{%- if project.use_dosdps %}
PATTERNDIR= ../patterns
PATTERN_TESTER= dosdp validate -i
DOSDPT= dosdp-tools
PATTERN_RELEASE_FILES= $(PATTERNDIR)/definitions.owl $(PATTERNDIR)/pattern.owl
{% endif %}
{%- if project.use_mappings %}
MAPPINGDIR= {% if project.sssom_mappingset_group is not none %}{{project.sssom_mappingset_group.directory|default("../mappings")}}{% endif %}
MAPPING_TESTER= sssom validate
SSSOMPY= sssom
MAPPINGS= {% if project.sssom_mappingset_group is not none %}{%- for mapping in project.sssom_mappingset_group.products %}{{ mapping.id }} {% endfor %}{% endif %}
MAPPING_RELEASE_FILES= $(foreach n,$(MAPPINGS), $(MAPPINGDIR)/$(n).sssom.tsv)
{% endif %}
{%- if project.use_translations %}
TRANSLATIONSDIR= {% if project.babelon_translation_group is not none %}{{project.babelon_translation_group.directory|default("../translations")}}{% endif %}
BABELONPY= babelon -q
TRANSLATIONS_OWL= {%- for translation in project.babelon_translation_group.products %}$(TRANSLATIONSDIR)/{{ translation.id }}.babelon.owl {% if translation.include_robot_template_synonyms %} $(TRANSLATIONSDIR)/{{ translation.id }}.synonyms.owl {% endif %}{% endfor %}
TRANSLATIONS_TSV= {%- for translation in project.babelon_translation_group.products %}$(TRANSLATIONSDIR)/{{ translation.id }}-preprocessed.babelon.tsv {% endfor %}
TRANSLATION_FILES= {%- if project.babelon_translation_group is not none %}{% if project.babelon_translation_group.release_merged_translations %}$(TRANSLATIONSDIR)/$(ONT)-all.babelon.tsv $(TRANSLATIONSDIR)/$(ONT)-all.babelon.json{% endif %}{% endif %}
{% endif %}
FORMATS = $(sort {% for format in project.export_formats %} {{ format }}{% endfor %} owl)
FORMATS_INCL_TSV = $(sort $(FORMATS) tsv)
RELEASE_ARTEFACTS = $(sort {% for release in project.release_artefacts %}{% if release.startswith('custom-') %}{{ release | replace("custom-","")}}{% else %}$(ONT)-{{ release }}{% endif %} {% endfor %})
ifeq ($(ODK_DEBUG),yes)
ODK_DEBUG_FILE = debug.log
SHELL = $(SCRIPTSDIR)/run-command.sh
endif
# ----------------------------------------
# Workflow control
# ----------------------------------------
# Set any of the following variables to false to completely disable the
# corresponding workflows.
# Refresh of mirrors (and all remote resources more generally)
MIR = true
# Re-generation of import modules
IMP = true
# Re-generation of "large" import modules
# Note that IMP=false takes precedence over IMP_LARGE=true, that is,
# IMP=false disables the generation of all import modules, large or not.
IMP_LARGE = true
# Re-generation of component modules
COMP = true
# Re-generation of pattern-derived files
PAT = true
# ----------------------------------------
# Top-level targets
# ----------------------------------------
.PHONY: .FORCE
.PHONY: all
all: all_odk
.PHONY: all_odk
all_odk: odkversion{% if project.config_hash %} config_check{% endif %} test custom_reports all_assets{% if project.release_diff %} release_diff{% endif %}
.PHONY: test
test: odkversion {% if project.use_dosdps %}dosdp_validation {% endif %}reason_test sparql_test robot_reports {% if project.robot_report.ensure_owl2dl_profile|default(true) %}$(REPORTDIR)/validate_profile_owl2dl_$(ONT).owl.txt{% endif %}
echo "Finished running all tests successfully."
.PHONY: test
test_fast:
$(MAKE_FAST) test
.PHONY: release_diff
release_diff: $(REPORTDIR)/release-diff.md
.PHONY: reason_test
reason_test: $(EDIT_PREPROCESSED)
$(ROBOT) reason --input $< --reasoner $(REASONER) --equivalent-classes-allowed {{ project.allow_equivalents }} \
--exclude-tautologies {{ project.exclude_tautologies }} --output test.owl && rm test.owl
.PHONY: odkversion
odkversion:
@echo "ODK Makefile $(ODK_VERSION_MAKEFILE)"
@odk-info --tools
{%- if project.config_hash %}
.PHONY: config_check
config_check:
@if [ "$$(tr -d '\r' < $(ONT)-odk.yaml | sha256sum | cut -c1-64)" = "$(CONFIG_HASH)" ]; then \
echo "Repository is up-to-date." ; else \
echo "Your ODK configuration has changed since this Makefile was generated. You may need to run 'make update_repo'." ; fi
{% endif %}
$(TMPDIR) $(REPORTDIR) $(MIRRORDIR) $(IMPORTDIR) $(COMPONENTSDIR) $(SUBSETDIR):
mkdir -p $@
# ----------------------------------------
# ODK-managed ROBOT plugins
# ----------------------------------------
# Make sure ROBOT knows where to find plugins
export ROBOT_PLUGINS_DIRECTORY=$(TMPDIR)/plugins
# Override this rule in {{ project.id }}.Makefile to install custom plugins
.PHONY: custom_robot_plugins
custom_robot_plugins:
{% if project.robot_plugins is defined %}
.PHONY: extra_robot_plugins
extra_robot_plugins: {% for plugin in project.robot_plugins.plugins %} $(ROBOT_PLUGINS_DIRECTORY)/{{ plugin.name }}.jar {% endfor %}
{% endif %}
# Install all ROBOT plugins to the runtime plugins directory
.PHONY: all_robot_plugins
all_robot_plugins: $(foreach plugin,$(notdir $(wildcard /tools/robot-plugins/*.jar)),$(ROBOT_PLUGINS_DIRECTORY)/$(plugin)) \
$(foreach plugin,$(notdir $(wildcard ../../plugins/*.jar)),$(ROBOT_PLUGINS_DIRECTORY)/$(plugin)) \
custom_robot_plugins {% if project.robot_plugins is defined %}extra_robot_plugins {% endif %} \
# Default rule to install plugins
$(ROBOT_PLUGINS_DIRECTORY)/%.jar:
@mkdir -p $(ROBOT_PLUGINS_DIRECTORY)
@if [ -f ../../plugins/$*.jar ]; then \
ln ../../plugins/$*.jar $@ ; \
elif [ -f /tools/robot-plugins/$*.jar ]; then \
cp /tools/robot-plugins/$*.jar $@ ; \
fi
# Specific rules for supplementary plugins defined in configuration
{% if project.robot_plugins is defined %}{% for plugin in project.robot_plugins.plugins %}
$(ROBOT_PLUGINS_DIRECTORY)/{{ plugin.name }}.jar:
{%- if plugin.mirror_from %}
curl -L -o $@ {{ plugin.mirror_from }}
{%- else %}
echo "ERROR: No URL has been provided for this plugin; you must install it yourself by overwriting this rule in {{ project.id }}.Makefile!" && false
{% endif %}
{% endfor %}{% endif %}
# ----------------------------------------
# Release assets
# ----------------------------------------
MAIN_PRODUCTS = $(sort $(foreach r,$(RELEASE_ARTEFACTS), $(r)) $(ONT))
MAIN_GZIPPED = {% if project.gzip_main %}$(foreach f,$(FORMATS), $(ONT).$(f).gz){% endif %}
MAIN_FILES = $(foreach n,$(MAIN_PRODUCTS), $(foreach f,$(FORMATS), $(n).$(f))) $(MAIN_GZIPPED)
SRCMERGED = $(TMPDIR)/merged-$(ONT)-edit.ofn
.PHONY: all_main
all_main: $(MAIN_FILES)
# ----------------------------------------
# Import assets
# ----------------------------------------
{% if project.import_group is defined %}
IMPORTS = {% for imp in project.import_group.products %} {{ imp.id }}{% endfor %}
{% else %}
IMPORTS =
{% endif %}
IMPORT_ROOTS = {% if project.import_group.use_base_merging %} $(IMPORTDIR)/merged_import{% else %}$(patsubst %, $(IMPORTDIR)/%_import, $(IMPORTS)){% endif %}
IMPORT_OWL_FILES = $(foreach n,$(IMPORT_ROOTS), $(n).owl)
{%- if project.import_group.export_obo %}
IMPORT_OBO_FILES = $(foreach n,$(IMPORT_ROOTS), $(n).obo)
IMPORT_FILES = $(IMPORT_OWL_FILES) $(IMPORT_OBO_FILES)
{% else %}
IMPORT_FILES = $(IMPORT_OWL_FILES)
{% endif %}
.PHONY: all_imports
all_imports: $(IMPORT_FILES)
# ----------------------------------------
# Subset assets
# ----------------------------------------
{% if project.subset_group is defined %}
SUBSETS = {% for x in project.subset_group.products %} {{ x.id }}{% endfor %}
{% else %}
SUBSETS =
{% endif %}
SUBSET_ROOTS = $(patsubst %, $(SUBSETDIR)/%, $(SUBSETS))
SUBSET_FILES = $(foreach n,$(SUBSET_ROOTS), $(foreach f,$(FORMATS_INCL_TSV), $(n).$(f)))
.PHONY: all_subsets
all_subsets: $(SUBSET_FILES)
# ----------------------------------------
# Mapping assets
# ----------------------------------------
{% if project.sssom_mappingset_group is defined %}
MAPPINGS = {% for x in project.sssom_mappingset_group.products %} {{ x.id }}{% endfor %}
{% if project.sssom_mappingset_group.released_products is defined %}
RELEASED_MAPPINGS = {% for x in project.sssom_mappingset_group.released_products %} {{ x.id }}{% endfor %}{% endif %}
{% else %}
MAPPINGS =
{% endif %}
MAPPING_FILES = $(foreach p, $(MAPPINGS), $(MAPPINGDIR)/$(p).sssom.tsv)
RELEASED_MAPPING_FILES = $(foreach p, $(RELEASED_MAPPINGS), $(MAPPINGDIR)/$(p).sssom.tsv)
.PHONY: all_mappings
all_mappings: $(MAPPING_FILES)
# ----------------------------------------
# QC Reports & Utilities
# ----------------------------------------
OBO_REPORT = {% for x in project.robot_report.report_on|default(["edit"]) %} {% if x=="edit" %}$(SRC){% else %}{{ x }}{% endif %}-obo-report{% endfor %}
REPORTS = $(OBO_REPORT)
REPORT_FILES = $(patsubst %, $(REPORTDIR)/%.tsv, $(REPORTS))
.PHONY: robot_reports
robot_reports: $(REPORT_FILES)
.PHONY: all_reports
all_reports: custom_reports robot_reports
# ----------------------------------------
# ROBOT OWL Profile checking
# ----------------------------------------
# The merge step is necessary to avoid undeclared entity violations.
$(REPORTDIR)/validate_profile_owl2dl_%.txt: % | $(REPORTDIR) $(TMPDIR)
$(ROBOT) merge -i $< convert -f ofn -o $(TMPDIR)/validate.ofn
$(ROBOT) validate-profile --profile DL -i $(TMPDIR)/validate.ofn -o $@ || { cat $@ && exit 1; }
.PRECIOUS: $(REPORTDIR)/validate_profile_owl2dl_%.txt
validate_profile_%: $(REPORTDIR)/validate_profile_owl2dl_%.txt
echo "$* profile validation completed."
# ----------------------------------------
# Sparql queries: Q/C
# ----------------------------------------
# these live in the ../sparql directory, and have suffix -violation.sparql
# adding the name here will make the violation check live.
SPARQL_VALIDATION_QUERIES = $(foreach V,$(SPARQL_VALIDATION_CHECKS),$(SPARQLDIR)/$(V)-violation.sparql)
sparql_test: {% for x in project.robot_report.sparql_test_on|default(["edit"]) %} {% if x=="edit" %}$(SRCMERGED){% else %}{{ x }}{% endif %}{% endfor %} | $(REPORTDIR)
ifneq ($(SPARQL_VALIDATION_QUERIES),)
{% for x in project.robot_report.sparql_test_on|default(["edit"]) -%}
{%- if x=="edit" -%}
{% set input = "$(SRCMERGED)"%}
{%- else -%}
{% set input = x %}
{% endif %}
$(ROBOT) verify -i {{ input }} --queries $(SPARQL_VALIDATION_QUERIES) -O $(REPORTDIR)
{%- endfor %}
endif
# ----------------------------------------
# ROBOT report
# ----------------------------------------
$(REPORTDIR)/$(SRC)-obo-report.tsv: $(SRCMERGED) | $(REPORTDIR)
$(ROBOT) report -i $< $(REPORT_LABEL) $(REPORT_PROFILE_OPTS) --fail-on $(REPORT_FAIL_ON) {% if project.robot_report.use_base_iris %}{% if project.namespaces is not none %}{% for iri in project.namespaces %}--base-iri {{ iri }} {% endfor -%}{% else %}--base-iri $(URIBASE)/{{ project.id.upper() }}_ --base-iri $(URIBASE)/{{ project.id }} {% endif -%}{% endif -%} --print 5 -o $@
$(REPORTDIR)/%-obo-report.tsv: % | $(REPORTDIR)
$(ROBOT) report -i $< $(REPORT_LABEL) $(REPORT_PROFILE_OPTS) --fail-on $(REPORT_FAIL_ON) {% if project.robot_report.use_base_iris %}{% if project.namespaces is not none %}{% for iri in project.namespaces %}--base-iri {{ iri }} {% endfor %}{% else %}--base-iri $(URIBASE)/{{ project.id.upper() }}_ --base-iri $(URIBASE)/{{ project.id }} {% endif %}{% endif -%} --print 5 -o $@
check_for_robot_updates:
{%- if project.robot_report.custom_profile %}
@cut -f2 "/tools/robot_report_profile.txt" | sort > $(TMPDIR)/sorted_tsv2.txt
@cut -f2 "$(ROBOT_PROFILE)" | sort > $(TMPDIR)/sorted_tsv1.txt
@comm -23 $(TMPDIR)/sorted_tsv2.txt $(TMPDIR)/sorted_tsv1.txt > $(TMPDIR)/missing.txt
@echo "Missing tests:"
@cat $(TMPDIR)/missing.txt
@rm $(TMPDIR)/sorted_tsv1.txt $(TMPDIR)/sorted_tsv2.txt $(TMPDIR)/missing.txt $(TMPDIR)/report_profile_robot.txt
{%- else %}
echo "You are not using a custom profile, so you are getting the joy of the latest ROBOT report!"
{% endif %}
# ----------------------------------------
# Release assets
# ----------------------------------------
ASSETS = \
$(IMPORT_FILES) \
$(MAIN_FILES) \{% if project.use_dosdps %}
$(PATTERN_RELEASE_FILES) \{% endif %}{% if project.use_translations %}
$(TRANSLATION_FILES) \{% endif %}
$(REPORT_FILES) \
$(SUBSET_FILES) \
$(MAPPING_FILES)
RELEASE_ASSETS = \
$(MAIN_FILES) {% if project.import_group is defined %}{% if project.import_group.release_imports %}$(IMPORT_FILES) {% endif %}{% endif %}\
$(SUBSET_FILES){% if project.robot_report.release_reports %} \
$(REPORT_FILES){% endif %}
.PHONY: all_assets
all_assets: $(ASSETS) {% if project.ensure_valid_rdfxml %}check_rdfxml_assets{% endif %}
.PHONY: show_assets
show_assets:
echo $(ASSETS)
du -sh $(ASSETS)
check_rdfxml_%: %
@check-rdfxml {% if project.extra_rdfxml_checks %}--jena --rdflib{% endif %} $<
.PHONY: check_rdfxml_assets
check_rdfxml_assets: $(foreach product,$(MAIN_PRODUCTS),check_rdfxml_$(product).owl)
# ----------------------------------------
# Release Management
# ----------------------------------------
{% if 'basic' in project.release_artefacts or project.primary_release == 'basic' -%}
KEEPRELATIONS=keeprelations.txt
{% endif -%}
CLEANFILES=$(MAIN_FILES) $(SRCMERGED) $(EDIT_PREPROCESSED)
# This should be executed by the release manager whenever time comes to make a release.
# It will ensure that all assets/files are fresh, and will copy to release folder
.PHONY: prepare_release
prepare_release: all_odk
rsync -R $(RELEASE_ASSETS) $(RELEASEDIR) &&\{% if project.sssom_mappingset_group is defined %}{% if project.sssom_mappingset_group.released_products is defined %}
mkdir -p $(RELEASEDIR)/mappings && cp -rf $(RELEASED_MAPPING_FILES) $(RELEASEDIR)/mappings &&\{% endif %}{% endif %}{% if project.use_dosdps %}
mkdir -p $(RELEASEDIR)/patterns && cp -rf $(PATTERN_RELEASE_FILES) $(RELEASEDIR)/patterns &&\{% endif %}
rm -f $(CLEANFILES) &&\
echo "Release files are now in $(RELEASEDIR) - now you should commit, push and make a release \
on your git hosting site such as GitHub or GitLab"
.PHONY: prepare_initial_release
prepare_initial_release: all_assets
rsync -R $(RELEASE_ASSETS) $(RELEASEDIR) &&\{% if project.sssom_mappingset_group is defined %}{% if project.sssom_mappingset_group.released_products is defined %}
mkdir -p $(RELEASEDIR)/mappings && cp -rf $(RELEASED_MAPPING_FILES) $(RELEASEDIR)/mappings &&\{% endif %}{% endif %}{% if project.use_dosdps %}
mkdir -p $(RELEASEDIR)/patterns && cp -rf $(PATTERN_RELEASE_FILES) $(RELEASEDIR)/patterns &&\{% endif %}
rm -f $(patsubst %, ./%, $(CLEANFILES)) &&\
cd $(RELEASEDIR) && git add $(RELEASE_ASSETS)
.PHONY: prepare_release_fast
prepare_release_fast:
$(MAKE) prepare_release IMP=false PAT=false MIR=false COMP=false
CURRENT_RELEASE=$(ONTBASE).owl
$(TMPDIR)/current-release.owl:
wget $(CURRENT_RELEASE) -O $@
$(REPORTDIR)/release-diff.md: $(ONT).owl $(TMPDIR)/current-release.owl
$(ROBOT) diff --labels true --left $(TMPDIR)/current-release.owl --right $(ONT).owl -f markdown -o $@
# ------------------------
# Imports: Seeding system
# ------------------------
# seed.txt contains all referenced entities
IMPORTSEED=$(TMPDIR)/seed.txt
PRESEED=$(TMPDIR)/pre_seed.txt
$(SRCMERGED): $(EDIT_PREPROCESSED) $(OTHER_SRC)
$(ROBOT) remove --input $< --select imports --trim false \
merge $(patsubst %, -i %, $(OTHER_SRC)) -o $@
$(EDIT_PREPROCESSED): $(SRC)
$(ROBOT) convert --input $< --format ofn --output $@
$(PRESEED): $(SRCMERGED)
$(ROBOT) query -f csv -i $< --query ../sparql/terms.sparql [email protected] &&\
cat [email protected] | sort | uniq > $@
{% if 'basic' in project.release_artefacts or 'simple' in project.release_artefacts or 'simple-non-classified' in project.release_artefacts or project.primary_release == 'basic' or project.primary_release == 'simple-non-classified' or project.primary_release == 'simple' -%}
SIMPLESEED=$(TMPDIR)/simple_seed.txt
$(SIMPLESEED): $(SRCMERGED) $(ONTOLOGYTERMS)
$(ROBOT) query -f csv -i $< --query ../sparql/simple-seed.sparql [email protected] &&\
cat [email protected] $(ONTOLOGYTERMS) | sort | uniq > $@ &&\
echo "http://www.geneontology.org/formats/oboInOwl#SubsetProperty" >> $@ &&\
echo "http://www.geneontology.org/formats/oboInOwl#SynonymTypeProperty" >> $@
{% endif -%}
{% if project.use_custom_import_module %}
IMPORT_MODULE_TEMPLATE=$(TEMPLATEDIR)/external_import.tsv
IMPORT_MODULE_SIGNATURE=$(TMPDIR)/external_import_terms.txt
IMPORT_MODULE=$(IMPORTDIR)/external_import.owl
$(IMPORT_MODULE): $(IMPORT_MODULE_TEMPLATE) | $(TMPDIR)
$(ROBOT) template --template $< {% if project.use_context %}--add-prefixes $(CONTEXT_FILE) {% endif %}\
--ontology-iri "$(ONTBASE)/external_import.owl" \
convert -f {{ project.import_component_format|default('ofn') }} \
--output $@
$(IMPORT_MODULE_SIGNATURE): $(IMPORT_MODULE) | $(TMPDIR)
$(ROBOT) query -f csv -i $< --query ../sparql/terms.sparql [email protected] &&\
cat [email protected] | sort | uniq > $@
{% endif %}
ALLSEED = $(PRESEED) {% if project.use_dosdps %} $(TMPDIR)/all_pattern_terms.txt {% endif %}\
{% if project.use_custom_import_module %} $(IMPORT_MODULE_SIGNATURE) {% endif %}
$(IMPORTSEED): $(ALLSEED) | $(TMPDIR)
if [ $(IMP) = true ]; then cat $(ALLSEED) | sort | uniq > $@; fi
{% if project.import_group is defined -%}
ANNOTATION_PROPERTIES={% for p in project.import_group.annotation_properties %}{{ p }} {% endfor %}
# ----------------------------------------
# Import modules
# ----------------------------------------
# Most ontologies are modularly constructed using portions of other ontologies
# These live in the imports/ folder
# This pattern uses ROBOT to generate an import module
ifeq ($(IMP),true)
# Should be able to drop this if robot can just take a big messy list of terms as input.
$(IMPORTDIR)/%_terms_combined.txt: $(IMPORTSEED) $(IMPORTDIR)/%_terms.txt
cat $^ | grep -v ^# | sort | uniq > $@
{% if project.import_group.use_base_merging %}
ALL_TERMS_COMBINED = $(patsubst %, $(IMPORTDIR)/%_terms_combined.txt, $(IMPORTS))
$(IMPORTDIR)/merged_terms_combined.txt: $(ALL_TERMS_COMBINED)
cat $^ | grep -v ^# | sort | uniq > $@
{% if 'slme' == project.import_group.module_type %}
$(IMPORTDIR)/merged_import.owl: $(MIRRORDIR)/merged.owl $(IMPORTDIR)/merged_terms_combined.txt
$(ROBOT) merge -i $< \{% if project.import_group.exclude_iri_patterns is not none %}
{% for pattern in project.import_group.exclude_iri_patterns %}remove --select "{{ pattern }}" {% endfor %} \{% endif %}
extract -T $(IMPORTDIR)/merged_terms_combined.txt --force true --copy-ontology-annotations true --individuals {{ project.import_group.slme_individuals }} --method {{ project.import_group.module_type_slme }} \
remove $(patsubst %, --term %, $(ANNOTATION_PROPERTIES)) -T $(IMPORTDIR)/merged_terms_combined.txt --select complement --select annotation-properties \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE)
{% else %}
$(IMPORTDIR)/merged_import.owl: $(MIRRORDIR)/merged.owl $(IMPORTDIR)/merged_terms_combined.txt
echo "ERROR: You have configured your default module type to be {{project.import_group.module_type}}; this behavior needs to be overwritten in {{ project.id }}.Makefile!" && false
{% endif %}
{% endif %}
{% if 'slme' == project.import_group.module_type %}
$(IMPORTDIR)/%_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/%.owl{% endif %} $(IMPORTDIR)/%_terms_combined.txt
$(ROBOT) query -i $< --update ../sparql/preprocess-module.ru \
extract -T $(IMPORTDIR)/$*_terms_combined.txt --force true --copy-ontology-annotations true --individuals {{ project.import_group.slme_individuals }} --method {{ project.import_group.module_type_slme }} \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE)
{% elif 'minimal' == project.import_group.module_type %}
$(IMPORTDIR)/%_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/%.owl{% endif %} $(IMPORTDIR)/%_terms_combined.txt
$(ROBOT) query -i $< --update ../sparql/preprocess-module.ru \
extract -T $(IMPORTDIR)/$*_terms_combined.txt --force true --copy-ontology-annotations true --method BOT \
remove --base-iri $(OBOBASE)"/$(shell echo $* | tr a-z A-Z)_" --axioms external --preserve-structure false --trim false \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
remove $(patsubst %, --term %, $(ANNOTATION_PROPERTIES)) -T $(IMPORTDIR)/$*_terms_combined.txt --select complement --select "classes individuals annotation-properties" \
$(ANNOTATE_CONVERT_FILE)
{% elif 'mirror' == project.import_group.module_type %}
$(IMPORTDIR)/%_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/%.owl{% endif %} $(IMPORTDIR)/%_terms_combined.txt
$(ROBOT) merge -i $< query --update ../sparql/preprocess-module.ru --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE)
{% elif 'filter' == project.import_group.module_type %}
$(IMPORTDIR)/%_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/%.owl{% endif %} $(IMPORTDIR)/%_terms_combined.txt
$(ROBOT) merge -i $< \
query --update ../sparql/preprocess-module.ru \
remove --base-iri $(OBOBASE)"/$(shell echo $* | tr a-z A-Z)_" --axioms external --preserve-structure false --trim false \
remove $(patsubst %, --term %, $(ANNOTATION_PROPERTIES)) -T $(IMPORTDIR)/$*_terms_combined.txt --select complement \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE)
{% elif 'custom' == project.import_group.module_type %}
$(IMPORTDIR)/%_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/%.owl{% endif %}
echo "ERROR: You have configured your default module type to be custom; this behavior needs to be overwritten in {{ project.id }}.Makefile!" && false
{% endif %}
.PRECIOUS: $(IMPORTDIR)/%_import.owl
{% if project.import_group.export_obo %}
# convert imports to obo.
# this can be useful for spot-checks and diffs.
# we set strict mode to false by default. For discussion see https://github.com/owlcs/owlapi/issues/752
$(IMPORTDIR)/%_import.obo: $(IMPORTDIR)/%_import.owl
$(ROBOT) convert --check false -i $< -f obo -o [email protected] && mv [email protected] $@
{% endif -%}
{%- for ont in project.import_group.products -%}
{% if ont.is_large or ont.module_type is not none %}
## Module for ontology: {{ ont.id }}
{% if ont.is_large -%}
ifeq ($(IMP_LARGE),true)
{% endif -%}
{% if (ont.is_large and ('slme' == ont.module_type or (ont.module_type is none and 'slme' == project.import_group.module_type))) or ('fast_slme' == ont.module_type) or (ont.module_type is none and 'fast_slme' == project.import_group.module_type) %}
$(IMPORTDIR)/{{ ont.id }}_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/{{ ont.id }}.owl{% endif %} $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt
$(ROBOT) extract -i $< -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --force true --copy-ontology-annotations true --individuals {% if ont.module_type is none %}{{ project.import_group.slme_individuals }} --method {{ project.import_group.module_type_slme }}{% else %}{{ ont.slme_individuals }} --method {{ ont.module_type_slme }}{% endif %} \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE)
{% elif ('slme' == ont.module_type) or (ont.module_type is none and 'slme' == project.import_group.module_type) %}
$(IMPORTDIR)/{{ ont.id }}_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/{{ ont.id }}.owl{% endif %} $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt
$(ROBOT) query -i $< --update ../sparql/preprocess-module.ru \
extract -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --copy-ontology-annotations true --force true --individuals {% if ont.module_type is none %}{{ project.import_group.slme_individuals }} --method {{ project.import_group.module_type_slme }}{% else %}{{ ont.slme_individuals }} --method {{ ont.module_type_slme }}{% endif %} \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE)
{% elif ('filter' == ont.module_type) or (ont.module_type is none and 'filter' == project.import_group.module_type) %}
$(IMPORTDIR)/{{ ont.id }}_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/{{ ont.id }}.owl{% endif %} $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt
$(ROBOT) {% if ont.is_large %}extract -i $< -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --copy-ontology-annotations true --force true --method BOT \{% else %}query -i $< --update ../sparql/preprocess-module.ru \
extract -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --copy-ontology-annotations true --force true --method BOT \{% endif %}
remove {% if ont.base_iris is not none %}{% for iri in ont.base_iris %}--base-iri {{ iri }} {% endfor %}{% else %}--base-iri $(OBOBASE)/{{ ont.id.upper() }} {% endif %}--axioms external --preserve-structure false --trim false \
remove $(patsubst %, --term %, $(ANNOTATION_PROPERTIES)) {% if ont.annotation_properties is defined %}{% for p in ont.annotation_properties %}--term {{ p }} {% endfor %}{% endif %} -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --select complement \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE)
{% elif ('mirror' == ont.module_type) or (ont.module_type is none and 'mirror' == project.import_group.module_type) %}
$(IMPORTDIR)/{{ ont.id }}_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/{{ ont.id }}.owl{% endif %} $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt
$(ROBOT) merge -i $< {% if not ont.is_large %}query --update ../sparql/preprocess-module.ru --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru {% endif %} \
$(ANNOTATE_CONVERT_FILE)
{% elif ('minimal' == ont.module_type) or (ont.module_type is none and 'minimal' == project.import_group.module_type) %}
$(IMPORTDIR)/{{ ont.id }}_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% else %}$(MIRRORDIR)/{{ ont.id }}.owl{% endif %} $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt
$(ROBOT) {% if ont.is_large %}extract -i $< -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --copy-ontology-annotations true --force true --method BOT \{% else %}query -i $< --update ../sparql/preprocess-module.ru \
extract -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --copy-ontology-annotations true --force true --method BOT \{% endif %}
remove {% if ont.base_iris is not none %}{% for iri in ont.base_iris %}--base-iri {{iri}} {% endfor %}{% else %}--base-iri $(OBOBASE)/{{ ont.id.upper() }} {% endif %}--axioms external --preserve-structure false --trim false \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru \
remove $(patsubst %, --term %, $(ANNOTATION_PROPERTIES)) {% if ont.annotation_properties is defined %}{% for p in ont.annotation_properties %}--term {{ p }} {% endfor %}{% endif %} -T $(IMPORTDIR)/{{ ont.id }}_terms_combined.txt --select complement --select "classes individuals annotation-properties" \
$(ANNOTATE_CONVERT_FILE)
{% elif ('custom' == ont.module_type) or (ont.module_type is none and 'custom' == project.import_group.module_type) %}
$(IMPORTDIR)/{{ ont.id }}_import.owl: {% if project.import_group.use_base_merging %}$(MIRRORDIR)/merged.owl{% elif 'no_mirror' != ont.mirror_type %}$(MIRRORDIR)/{{ ont.id }}.owl{% endif %}
echo "ERROR: You have configured your default module type to be custom; this behavior needs to be overwritten in {{ project.id }}.Makefile!" && false
{%- endif %}
{% if ont.is_large -%}
endif # IMP_LARGE=true
{% endif -%}
{%- endif %}
{%- endfor %}
endif # IMP=true
.PHONY: refresh-imports
refresh-imports:
$(MAKE) IMP=true MIR=true PAT=false IMP_LARGE=true all_imports -B
.PHONY: no-mirror-refresh-imports
no-mirror-refresh-imports:
$(MAKE) IMP=true MIR=false PAT=false IMP_LARGE=true all_imports -B
.PHONY: refresh-imports-excluding-large
refresh-imports-excluding-large:
$(MAKE) IMP=true MIR=true PAT=false IMP_LARGE=false all_imports -B
.PHONY: refresh-%
refresh-%:
$(MAKE) IMP=true IMP_LARGE=true MIR=true PAT=false $(IMPORTDIR)/$*_import.owl -B
.PHONY: no-mirror-refresh-%
no-mirror-refresh-%:
$(MAKE) IMP=true IMP_LARGE=true MIR=false PAT=false $(IMPORTDIR)/$*_import.owl -B
{%- endif %}
{% if project.components is not none %}
# ----------------------------------------
# Components
# ----------------------------------------
# Some ontologies contain external and internal components. A component is included in the ontology in its entirety.
ifeq ($(COMP),true)
.PHONY: all_components
all_components: $(OTHER_SRC)
.PHONY: recreate-components
recreate-components:
$(MAKE) COMP=true IMP=false MIR=true PAT=true IMP_LARGE=false all_components -B
.PHONY: no-mirror-recreate-components
no-mirror-recreate-components:
$(MAKE) COMP=true IMP=false MIR=false PAT=true IMP_LARGE=false all_components -B
.PHONY: recreate-%
recreate-%:
$(MAKE) COMP=true IMP=false IMP_LARGE=false MIR=true PAT=true $(COMPONENTSDIR)/$*.owl -B
.PHONY: no-mirror-recreate-%
no-mirror-recreate-%:
$(MAKE) COMP=true IMP=false IMP_LARGE=false MIR=false PAT=true $(COMPONENTSDIR)/$*.owl -B
$(COMPONENTSDIR)/%.owl: | $(COMPONENTSDIR)
test -f $@ || touch $@
.PRECIOUS: $(COMPONENTSDIR)/%.owl
{% for component in project.components.products %}
{% if component.source is not none %}
ifeq ($(MIR),true)
.PHONY: component-download-{{ component.filename }}
component-download-{{ component.filename }}: | $(TMPDIR)
$(ROBOT) merge -I {{ component.source }} \{%- if component.make_base %}
remove {% if component.base_iris is not none %}{% for iri in component.base_iris %}--base-iri {{iri}} {% endfor %}{% else %}--base-iri $(OBOBASE)/{{ project.id.upper() }} {% endif %}--axioms external --preserve-structure false --trim false \{% endif %}
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) -o $(TMPDIR)/[email protected]
$(COMPONENTSDIR)/{{ component.filename }}: component-download-{{ component.filename }}
if cmp -s $(TMPDIR)/component-download-{{ component.filename }}.owl $(TMPDIR)/component-download-{{ component.filename }}.tmp.owl ; then echo "Component identical."; \
else echo "Component is different, updating." &&\
cp $(TMPDIR)/component-download-{{ component.filename }}.owl $(TMPDIR)/component-download-{{ component.filename }}.tmp.owl &&\
$(ROBOT) annotate -i $(TMPDIR)/component-download-{{ component.filename }}.owl --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) -o $@; fi
.PRECIOUS: $(COMPONENTSDIR)/{{ component.filename }}
endif # MIR=true
{% elif component.use_template %}
$(COMPONENTSDIR)/{{ component.filename }}:{% if component.templates is not none %}{% for template in component.templates %} $(TEMPLATEDIR)/{{ template }}{% endfor %}{% else %} $(TEMPLATEDIR)/{{ component.filename.split('.') | first }}.tsv{% endif %}
$(ROBOT) template {% if component.template_options is not none %}{{ component.template_options }}{% endif %} \
$(patsubst %, --template %, $^) \
$(ANNOTATE_CONVERT_FILE)
.PRECIOUS: $(COMPONENTSDIR)/{{ component.filename }}
{% elif component.use_mappings %}
$(COMPONENTSDIR)/{{ component.filename }}:{% if component.mappings is not none %}{% for mapping in component.mappings %} $(MAPPINGDIR)/{{ mapping }}{% endfor %}{% else %} $(MAPPINGDIR)/{{ component.filename.split('.') | first }}sssom.tsv{% endif %}
$(SSSOMPY) merge $^ --output $(TMPDIR)/{{ component.filename }}-merged.sssom.tsv &&\
$(SSSOMPY) convert $(TMPDIR)/{{ component.filename }}-merged.sssom.tsv {{ component.sssom_tool_options }} --output $(TMPDIR)/{{ component.filename }}-converted.sssom.owl &&\
$(ROBOT) merge -i $(TMPDIR)/{{ component.filename }}-converted.sssom.owl \
$(ANNOTATE_CONVERT_FILE)
.PRECIOUS: $(COMPONENTSDIR)/{{ component.filename }}
{% endif -%}
{% endfor -%}
endif # COMP=true
{% endif -%}
{% if project.import_group is defined -%}
# ----------------------------------------
# Mirroring upstream ontologies
# ----------------------------------------
ifeq ($(MIR),true)
{% for ont in project.import_group.products %}
## ONTOLOGY: {{ ont.id }}
{% if ont.description -%}
## {{ ont.description }}
{% endif -%}
{%- if ont.mirror_type != 'no_mirror' -%}
.PHONY: mirror-{{ ont.id }}
.PRECIOUS: $(MIRRORDIR)/{{ ont.id }}.owl
{%- endif -%}
{%- if ont.is_large %}
ifeq ($(IMP_LARGE),true)
{%- endif %}
{%- if ont.mirror_from %}
mirror-{{ ont.id }}: | $(TMPDIR)
$(ROBOT) {% if ont.make_base or 'base' == ont.mirror_type %}remove -I {{ ont.mirror_from }} {% if ont.base_iris is not none %}{% for iri in ont.base_iris %}--base-iri {{iri}} {% endfor %}{% else %}--base-iri $(OBOBASE)/{{ ont.id.upper() }} {% endif %} --axioms external --preserve-structure false --trim false{% else %}convert -I {{ ont.mirror_from }}{% endif %} -o $(TMPDIR)/[email protected]
{%- elif ont.use_base %}
{%- if ont.use_gzipped %}
mirror-{{ ont.id }}: | $(TMPDIR)
curl -L $(OBOBASE)/{{ ont.id }}/{{ ont.id }}-base.owl.gz --create-dirs -o $(MIRRORDIR)/{{ ont.id }}-base.owl.gz --retry {{project.import_group.mirror_retry_download}} --max-time {{ project.import_group.mirror_max_time_download }} && \
$(ROBOT) {% if ont.make_base or 'base' == ont.mirror_type %}remove -i $(MIRROR_DIR)/{{ ont.id }}-base.owl.gz {% if ont.base_iris is not none %}{% for iri in ont.base_iris %}--base-iri {{iri}} {% endfor %}{ else %}--base-iri $(OBOBASE)/{{ ont.id.upper() }} {% endif %} --axioms external --preserve-structure false --trim false{% else %}convert -i $(MIRRORDIR)/{{ ont.id }}-base.owl.gz{% endif %} -o $(TMPDIR)/[email protected]
{%- else %}
mirror-{{ ont.id }}: | $(TMPDIR)
curl -L $(OBOBASE)/{{ ont.id }}/{{ ont.id }}-base.owl --create-dirs -o $(TMPDIR)/{{ ont.id }}-download.owl --retry {{ project.import_group.mirror_retry_download }} --max-time {{ project.import_group.mirror_max_time_download }} && \
$(ROBOT) convert -i $(TMPDIR)/{{ ont.id }}-download.owl -o $(TMPDIR)/[email protected]
{%- endif %}
{%- else %}
{%- if ont.use_gzipped %}
mirror-{{ ont.id }}: | $(TMPDIR)
curl -L $(OBOBASE)/{{ ont.id }}.owl.gz --create-dirs -o $(MIRRORDIR)/{{ ont.id }}.owl.gz --retry {{ project.import_group.mirror_retry_download }} --max-time {{ project.import_group.mirror_max_time_download }} && \
$(ROBOT) {% if ont.make_base or 'base' == ont.mirror_type %}remove -i $(MIRRORDIR)/{{ ont.id }}.owl.gz {% if ont.base_iris is not none %}{% for iri in ont.base_iris %}--base-iri {{iri}} {% endfor %}{% else %}--base-iri $(OBOBASE)/{{ ont.id.upper() }} {% endif %}--axioms external --preserve-structure false --trim false{% else %}convert -i $(MIRRORDIR)/{{ ont.id }}.owl.gz{% endif %} -o $(TMPDIR)/[email protected]
{%- elif 'custom' == ont.mirror_type %}
$(MIRRORDIR)/{{ ont.id }}.owl:
echo "ERROR: You have configured your default mirror type to be custom; this behavior needs to be overwritten in {{ project.id }}.Makefile!" && false
{%- elif 'no_mirror' == ont.mirror_type -%}
## You have configured your default mirror type to no_mirror.
{%- else %}
mirror-{{ ont.id }}: | $(TMPDIR)
curl -L $(OBOBASE)/{{ ont.id }}.owl --create-dirs -o $(TMPDIR)/{{ ont.id }}-download.owl --retry {{ project.import_group.mirror_retry_download }} --max-time {{ project.import_group.mirror_max_time_download }} && \
$(ROBOT) {% if ont.make_base or 'base' == ont.mirror_type %}remove -i $(TMPDIR)/{{ ont.id }}-download.owl {% if ont.base_iris is not none %}{% for iri in ont.base_iris %}--base-iri {{iri}} {% endfor %}{% else %}--base-iri $(OBOBASE)/{{ ont.id.upper() }} {% endif %}--axioms external --preserve-structure false --trim false{% else %}convert -i $(TMPDIR)/{{ ont.id }}-download.owl{% endif %} -o $(TMPDIR)/[email protected]
{%- endif %}
{%- endif %}
{%- if ont.is_large %}
endif
{%- endif %}
{% endfor -%}
{% if project.import_group.use_base_merging %}
ALL_MIRRORS = $(patsubst %, $(MIRRORDIR)/%.owl, $(IMPORTS))
MERGE_MIRRORS = true
ifeq ($(MERGE_MIRRORS),true)
$(MIRRORDIR)/merged.owl: $(ALL_MIRRORS)
$(ROBOT) merge $(patsubst %, -i %, $^) {% if project.import_group.annotate_defined_by %}--annotate-defined-by true{% endif %} {% if project.import_group.base_merge_drop_equivalent_class_axioms %}remove --axioms equivalent --preserve-structure false {% endif %}-o $@
.PRECIOUS: $(MIRRORDIR)/merged.owl
endif
{% endif %}
$(MIRRORDIR)/%.owl: mirror-% | $(MIRRORDIR)
if [ -f $(TMPDIR)/mirror-$*.owl ]; then if cmp -s $(TMPDIR)/mirror-$*.owl $@ ; then echo "Mirror identical, ignoring."; else echo "Mirrors different, updating." &&\
cp $(TMPDIR)/mirror-$*.owl $@; fi; fi
endif # MIR=true
{% endif %}
{% if project.subset_group is defined %}
# ----------------------------------------
# Subsets
# ----------------------------------------
$(SUBSETDIR)/%.tsv: $(SUBSETDIR)/%.owl
$(ROBOT) query -f tsv -i $< -s ../sparql/labels.sparql $@
.PRECIOUS: $(SUBSETDIR)/%.tsv
$(SUBSETDIR)/%.owl: $(ONT).owl | $(SUBSETDIR)
$(OWLTOOLS) $< --extract-ontology-subset --fill-gaps --subset $* -o [email protected] && mv [email protected] $@ &&\
$(ROBOT) annotate --input $@ --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) -o [email protected] && mv [email protected] $@
.PRECIOUS: $(SUBSETDIR)/%.owl
{% if 'obo' in project.export_formats %}
$(SUBSETDIR)/%.obo: $(SUBSETDIR)/%.owl
$(ROBOT) convert --input $< --check false -f obo $(OBO_FORMAT_OPTIONS) -o [email protected] && grep -v ^owl-axioms [email protected] > $@ && rm [email protected]
{% endif -%}
{% if 'ttl' in project.export_formats %}
$(SUBSETDIR)/%.ttl: $(SUBSETDIR)/%.owl
$(ROBOT) convert --input $< --check false -f ttl -o [email protected] && mv [email protected] $@
{% endif -%}
{% if 'json' in project.export_formats %}
$(SUBSETDIR)/%.json: $(SUBSETDIR)/%.owl
$(ROBOT) convert --input $< --check false -f json -o [email protected] &&\
mv [email protected] $@
{% endif -%}
{% endif %}
# ---------------------------------------------
# Sparql queries: Table exports / Query Reports
# ---------------------------------------------
SPARQL_EXPORTS_ARGS = $(foreach V,$(SPARQL_EXPORTS),-s $(SPARQLDIR)/$(V).sparql $(REPORTDIR)/$(V).tsv)
# This combines all into one single command
.PHONY: custom_reports
custom_reports: $(EDIT_PREPROCESSED) | $(REPORTDIR)
ifneq ($(SPARQL_EXPORTS_ARGS),)
$(ROBOT) query -f tsv --use-graphs true -i $< $(SPARQL_EXPORTS_ARGS)
endif
{%- if project.use_dosdps %}
# ----------------------------------------
# DOSDP Templates/Patterns
# ----------------------------------------
ifeq ($(PAT),true)
ALL_PATTERN_FILES=$(wildcard $(PATTERNDIR)/dosdp-patterns/*.yaml)
ALL_PATTERN_NAMES=$(strip $(patsubst %.yaml,%, $(notdir $(wildcard $(PATTERNDIR)/dosdp-patterns/*.yaml))))
PATTERN_CLEAN_FILES=../patterns/all_pattern_terms.txt \
$(DOSDP_OWL_FILES_DEFAULT) $(DOSDP_TERM_FILES_DEFAULT) \{% if project.pattern_pipelines_group is defined %}
{% for pipeline in project.pattern_pipelines_group.products -%}
$(DOSDP_OWL_FILES_{{ pipeline.id.upper() }}) $(DOSDP_TERM_FILES_{{ pipeline.id.upper() }}) {% endfor %}{% endif %}
# Note to future generations: prepending ./ is a safety measure to ensure that
# the environment does not malicously set `PATTERN_CLEAN_FILES` to `\`.
.PHONY: pattern_clean
pattern_clean:
rm -f $(PATTERN_CLEAN_FILES)
.PHONY: patterns
patterns dosdp:
echo "Validating all DOSDP templates"
$(MAKE) dosdp_validation
echo "Building $(PATTERNDIR)/definitions.owl"
$(MAKE) $(PATTERNDIR)/pattern.owl $(PATTERNDIR)/definitions.owl
# DOSDP Template Validation
$(TMPDIR)/pattern_schema_checks: $(ALL_PATTERN_FILES) | $(TMPDIR)
$(PATTERN_TESTER) $(PATTERNDIR)/dosdp-patterns/ && touch $@
.PHONY: pattern_schema_checks
pattern_schema_checks dosdp_validation: $(TMPDIR)/pattern_schema_checks
.PHONY: update_patterns
update_patterns: download_patterns
if [ -n "$$(find $(TMPDIR) -type f -path '$(TMPDIR)/dosdp/*.yaml')" ]; then cp -r $(TMPDIR)/dosdp/*.yaml $(PATTERNDIR)/dosdp-patterns; fi
# This command is a workaround for the absence of -N and -i in wget of alpine (the one ODK depend on now).
# It downloads all patterns specified in external.txt
.PHONY: download_patterns
download_patterns:
rm -f $(TMPDIR)/dosdp/*.yaml.1 || true
if [ -s $(PATTERNDIR)/dosdp-patterns/external.txt ]; then wget -i $(PATTERNDIR)/dosdp-patterns/external.txt --backups=1 -P $(TMPDIR)/dosdp; fi
rm -f $(TMPDIR)/dosdp/*.yaml.1 || true
$(PATTERNDIR)/dospd-patterns/%.yml: download_patterns
if cmp -s $(TMPDIR)/dosdp-$*.yml $@ ; then echo "DOSDP templates identical."; else echo "DOSDP templates different, updating." &&\
cp $(TMPDIR)/dosdp-$*.yml $@; fi
# DOSDP Template: Pipelines
# Each pipeline gets its own directory structure
# DOSDP default pipeline
DOSDP_TSV_FILES_DEFAULT = $(wildcard $(PATTERNDIR)/data/default/*.tsv)
DOSDP_PATTERN_NAMES_DEFAULT = $(strip $(patsubst %.tsv, %, $(notdir $(DOSDP_TSV_FILES_DEFAULT))))
DOSDP_OWL_FILES_DEFAULT = $(foreach name, $(DOSDP_PATTERN_NAMES_DEFAULT), $(PATTERNDIR)/data/default/$(name).ofn)
DOSDP_TERM_FILES_DEFAULT = $(foreach name, $(DOSDP_PATTERN_NAMES_DEFAULT), $(PATTERNDIR)/data/default/$(name).txt)
DOSDP_YAML_FILES_DEFAULT = $(foreach name, $(DOSDP_PATTERN_NAMES_DEFAULT), $(PATTERNDIR)/dosdp-patterns/$(name).yaml)
$(DOSDP_OWL_FILES_DEFAULT): $(EDIT_PREPROCESSED) $(DOSDP_TSV_FILES_DEFAULT) $(ALL_PATTERN_FILES)
if [ "${DOSDP_PATTERN_NAMES_DEFAULT}" ]; then $(DOSDPT) generate --catalog=$(CATALOG) \
--infile=$(PATTERNDIR)/data/default/ --template=$(PATTERNDIR)/dosdp-patterns --batch-patterns="$(DOSDP_PATTERN_NAMES_DEFAULT)" \
--ontology=$< {{ project.dosdp_tools_options }} --outfile=$(PATTERNDIR)/data/default; fi
.PHONY: dosdp-docs-default
dosdp-docs-default: $(EDIT_PREPROCESSED) $(DOSDP_TSV_FILES_DEFAULT) $(DOSDP_YAML_FILES_DEFAULT)
mkdir -p $(DOCSDIR)/patterns/default
$(DOSDPT) docs {{ project.dosdp_tools_options }} --catalog=$(CATALOG) \
--ontology=$< \
--infile=$(PATTERNDIR)/data/default \
--template=$(PATTERNDIR)/dosdp-patterns \
--batch-patterns="$(DOSDP_PATTERN_NAMES_DEFAULT)" \
--outfile=$(DOCSDIR)/patterns/default{% if project.repo_url %} \
--data-location-prefix={{ project.repo_url }}/src/patterns/data/default{% elif project.github_org and project.repo %} \
--data-location-prefix=https://github.com/{{ project.github_org }}/{{ project.repo }}/tree/{{ project.git_main_branch }}/src/patterns/data/default{% endif %}
{% if project.pattern_pipelines_group is defined %}
{% for pipeline in project.pattern_pipelines_group.products %}
# DOSDP {{ pipeline.id }} pipeline
DOSDP_TSV_FILES_{{ pipeline.id.upper() }} = $(wildcard $(PATTERNDIR)/data/{{ pipeline.id }}/*.tsv)
DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }} = $(strip $(patsubst %.tsv, %, $(notdir $(DOSDP_TSV_FILES_{{ pipeline.id.upper() }}))))
DOSDP_OWL_FILES_{{ pipeline.id.upper() }} = $(foreach name, $(DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }}), $(PATTERNDIR)/data/{{ pipeline.id }}/$(name).ofn)
DOSDP_TERM_FILES_{{ pipeline.id.upper() }} = $(foreach name, $(DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }}), $(PATTERNDIR)/data/{{ pipeline.id }}/$(name).txt)
DOSDP_YAML_FILES_{{ pipeline.id.upper() }} = $(foreach name, $(DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }}), $(PATTERNDIR)/dosdp-patterns/$(name).yaml)
$(DOSDP_OWL_FILES_{{ pipeline.id.upper() }}): $(EDIT_PREPROCESSED) $(DOSDP_TSV_FILES_{{ pipeline.id.upper() }}) $(ALL_PATTERN_FILES)
if [ "${DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }}}" ]; then $(DOSDPT) generate --catalog=$(CATALOG) \
--infile=$(PATTERNDIR)/data/{{ pipeline.id }} --template=$(PATTERNDIR)/dosdp-patterns/ --batch-patterns="$(DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }})" \
--ontology=$< {{ pipeline.dosdp_tools_options }} --outfile=$(PATTERNDIR)/data/{{ pipeline.id }}; fi
.PHONY: dosdp-docs-{{ pipeline.id }}
dosdp-docs-{{ pipeline.id }}: $(EDIT_PREPROCESSED) $(DOSDP_TSV_FILES_{{ pipeline.id.upper() }}) $(DOSDP_YAML_FILES_{{ pipeline.id.upper() }})
mkdir -p $(DOCSDIR)/patterns/{{ pipeline.id }}
$(DOSDPT) docs {{ pipeline.dosdp_tools_options }} --catalog=$(CATALOG) \
--ontology=$< \
--infile=$(PATTERNDIR)/data/{{ pipeline.id }} \
--template=$(PATTERNDIR)/dosdp-patterns \
--batch-patterns="$(DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }})" \
--outfile=$(DOCSDIR)/patterns/{{ pipeline.id }}{% if project.repo_url %} \
--data-location-prefix={{ project.repo_url }}/src/patterns/data/{{ pipeline.id }}{% elif project.github_org and project.repo %} \
--data-location-prefix=https://github.com/{{ project.github_org }}/{{ project.repo }}/tree/{{ project.git_main_branch }}/src/patterns/data/{{ pipeline.id }}{% endif %}
{% endfor -%}
{% endif -%}
# Generate template file seeds
## Generate template file seeds
$(PATTERNDIR)/data/default/%.txt: $(PATTERNDIR)/dosdp-patterns/%.yaml $(PATTERNDIR)/data/default/%.tsv
$(DOSDPT) terms --infile=$(word 2, $^) --template=$< --obo-prefixes=true --outfile=$@
{% if project.pattern_pipelines_group is defined -%}
{% for pipeline in project.pattern_pipelines_group.products %}
$(PATTERNDIR)/data/{{ pipeline.id }}/%.txt: $(PATTERNDIR)/dosdp-patterns/%.yaml $(PATTERNDIR)/data/{{ pipeline.id }}/%.tsv
$(DOSDPT) terms --infile=$(word 2, $^) --template=$< --obo-prefixes=true --outfile=$@
{% endfor %}
{% if project.pattern_pipelines_group.matches is iterable -%}{% for matches in project.pattern_pipelines_group.matches %}
dosdp-matches-{{ matches.id }}: {{ matches.ontology }} $(ALL_PATTERN_FILES)
$(DOSDPT) query --ontology=$< --catalog=$(CATALOG) --reasoner=elk {{ matches.dosdp_tools_options }} \
--batch-patterns="$(ALL_PATTERN_NAMES)" --template="$(PATTERNDIR)/dosdp-patterns" --outfile="$(PATTERNDIR)/data/{{ matches.id }}/"
{% endfor %}{% endif -%}
{% endif -%}
# Generating the seed file from all the TSVs.
$(TMPDIR)/all_pattern_terms.txt: $(DOSDP_TERM_FILES_DEFAULT) {% if project.pattern_pipelines_group is defined %} {% for pipeline in project.pattern_pipelines_group.products %} $(DOSDP_TERM_FILES_{{ pipeline.id.upper() }}){% endfor %}{% endif %} $(TMPDIR)/pattern_owl_seed.txt
cat $^ | sort | uniq > $@
$(TMPDIR)/pattern_owl_seed.txt: $(PATTERNDIR)/pattern.owl
$(ROBOT) query --use-graphs true -f csv -i $< --query ../sparql/terms.sparql $@
# Pattern pipeline main targets: the generated OWL files
# Create pattern.owl, an ontology of all DOSDP patterns
$(PATTERNDIR)/pattern.owl: $(ALL_PATTERN_FILES)
$(DOSDPT) prototype --obo-prefixes true --template=$(PATTERNDIR)/dosdp-patterns --outfile=$@
# Generating the individual pattern modules and merging them into definitions.owl
$(PATTERNDIR)/definitions.owl: $(DOSDP_OWL_FILES_DEFAULT) {% if project.pattern_pipelines_group is defined %} {% for pipeline in project.pattern_pipelines_group.products %} $(DOSDP_OWL_FILES_{{ pipeline.id.upper() }}){% endfor %}{% endif %}
if [ "${DOSDP_PATTERN_NAMES_DEFAULT}" ] {% if project.pattern_pipelines_group is defined %} {% for pipeline in project.pattern_pipelines_group.products %} || [ "${DOSDP_PATTERN_NAMES_{{ pipeline.id.upper() }}}" ]{% endfor %}{% endif %} && [ $(PAT) = true ]; then $(ROBOT) merge $(addprefix -i , $^) \
annotate --ontology-iri $(ONTBASE)/patterns/definitions.owl --version-iri $(ONTBASE)/releases/$(TODAY)/patterns/definitions.owl \
--annotation owl:versionInfo $(VERSION) -o definitions.ofn && mv definitions.ofn $@; fi
else # PAT=false
# Even if pattern generation is disabled, we still extract a seed from definitions.owl
$(TMPDIR)/all_pattern_terms.txt: $(PATTERNDIR)/definitions.owl
$(ROBOT) query --use-graphs true -f csv -i $< --query $(SPARQLDIR)/terms.sparql $@
endif
{% endif %}
{%- if project.use_mappings %}
# ----------------------------------------
# SSSOM Mapping Files
# ----------------------------------------
validate-sssom-%:
tsvalid $(MAPPINGDIR)/$*.sssom.tsv --comment "#"
sssom validate $(MAPPINGDIR)/$*.sssom.tsv
{%- if project.sssom_mappingset_group is not none %}
{%- for mapping in project.sssom_mappingset_group.products %}
{% if mapping.maintenance == "extract" %}
$(TMPDIR)/{{ mapping.id }}.obographs.json: {% if mapping.source_file is not none %}{{ mapping.source_file }}{% else %}$(EDIT_PREPROCESSED){% endif %}
$(ROBOT) annotate --input $< --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \
convert --check false -f json -o [email protected] &&\
mv [email protected] $@
$(MAPPINGDIR)/{{ mapping.id }}.sssom.tsv: $(TMPDIR)/{{ mapping.id }}.obographs.json
sssom parse $< -I obographs-json {{ mapping.sssom_tool_options }} -o $@
{%- elif mapping.maintenance == "manual" %}
# This mappingset is manually curated, so we only check that the file actually exists.
$(MAPPINGDIR)/{{ mapping.id }}.sssom.tsv:
test -f $@
{%- elif mapping.maintenance == "mirror" %}
ifeq ($(MIR),true)
$(MAPPINGDIR)/{{ mapping.id }}.sssom.tsv:
wget "{{ mapping.mirror_from }}" -O $@
endif
{%- endif %}
{%- endfor %}
{%- endif %}
validate_mappings:
$(MAKE_FAST) $(foreach n,$(MAPPINGS), validate-sssom-$(n))
{% endif %}
{%- if project.use_translations %}
# ----------------------------------------
# Babelon Translation Files
# ----------------------------------------
{%- if project.babelon_translation_group is not none %}
TRANSLATIONS_ADAPTER={{ project.babelon_translation_group.oak_adapter|default('pronto:$(ONT).obo') }}
TRANSLATIONS_ONTOLOGY={{ project.babelon_translation_group.translate_ontology|default('$(ONT).obo') }}