generated from yshwetar/mondo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
1481 lines (1103 loc) · 64.8 KB
/
Makefile
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
OBOBASE= http://purl.obolibrary.org/obo
URIBASE= http://purl.obolibrary.org/obo
VERSION= $(TODAY)
ANNOTATION_PROPERTIES= rdfs:label IAO:0000115 IAO:0000116 IAO:0100001 owl:deprecated
ANNOTATE_ONTOLOGY_VERSION = annotate -V $(ONTBASE)/releases/$(VERSION)/$@ --annotation owl:versionInfo $(VERSION)
ANNOTATE_CONVERT_FILE = annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) convert -f ofn --output [email protected] && mv [email protected] $@
OBO=http://purl.obolibrary.org/obo
OIO=http://www.geneontology.org/formats/oboInOwl\#
RDFS=http://www.w3.org/2000/01/rdf-schema#
SKOS=http://www.w3.org/2004/02/skos/core\#
EFO=http://www.ebi.ac.uk/efo
ONT=mondo
ONTURI=$(OBO)/$(ONT)
ONTBASE=$(OBO)/$(ONT)
MIRRORDIR=mirror
IMPORTDIR=imports
SRC=$(ONT)-edit.obo
#RELEASEDIR=../../target/
CATALOG=catalog-v001.xml
ROBOT= robot --catalog $(CATALOG)
OWLTOOLS= owltools
USECAT= --use-catalog
SPARQLDIR = ../sparql
PATTERNDIR = ../patterns
TMPDIR = tmp
CONSTRUCTS= embedded-definition
INCLUDES_OWL = $(patsubst %,include-%.owl,$(CONSTRUCTS))
ISODATE:=`date +%Y-%m-%d`
TODAY ?= $(shell date +%Y-%m-%d)
OBODATE ?= $(shell date +'%d:%m:%Y %H:%M')
FMTS = obo owl json
obo-filter-axiom-header = grep -v ^owl-axioms:
OWL2OBO = $(ROBOT) convert -i $< -o [email protected] && grep -v ^owl-axioms: [email protected] > $@
PV_CC0 = http://purl.org/dc/terms/license https://creativecommons.org/publicdomain/zero/1.0/
# In converting to obo format, everything is assumed to have an OBO prefix.
# This perl corrects this.
# Longer term we need to eliminate passing through obo and/or fix the owlapi implementation to respect prefixes
FIX_URI_EXPR = 's@$(OBO)/EFO_@http://www.ebi.ac.uk/efo/EFO_@g; s@$(OBO)/UMLS_@http://linkedlifedata.com/resource/umls/id/@g'
# EFO uses different properties. The following command can be used on owltools
EFO2OBO_OPTS = --rename-entity $(EFO)/definition $(OBO)/IAO_0000115 \
--rename-entity $(EFO)/reason_for_obsolescence $(RDFS)comment \
--rename-entity $(EFO)/alternative_term $(OIO)hasExactSynonym\
--rename-entity $(OBO)/ECO_0000218 $(OIO)source
# EFO uses different prefixes in xrefs. We replace these with the following perl
# intended to be used within a perl -npe loop.
# In future we should use a more robust translation
EFO2OBO_PERL = 's@NCIt:@NCIT:@; s@MSH:@MESH:@; s@SNOMEDCT:@SCTID:@;'
OBOGREPL=../scripts/obo-grepl.pl
OBOGREP=../scripts/obo-grep.pl
ADDTOTBD=../scripts/add-to-tbd.pl
# ----------------------------------------
# Top-level targets
# ----------------------------------------
.PHONY: .FORCE
all: test all_artefacts mappings
echo "release finished"
# ----------------------------------------
# Artefacts
# ----------------------------------------
IMPORTS = uberon cl go pato envo ro hp mf ncbitaxon chebi ncit hgnc foodon so ecto omo chr hsapdv nbo maxo mfomd ncbigene
IMPORT_ROOTS = $(IMPORTDIR)/merged_import
IMPORT_OWL_FILES = $(foreach n,$(IMPORT_ROOTS), $(n).owl)
IMPORT_FILES = $(IMPORT_OWL_FILES)
.PHONY: all_imports
all_imports: $(IMPORT_FILES)
COMPONENTS = mondo-tags
COMPONENT_FILES = $(foreach n, $(COMPONENTS), components/$(n).owl)
SUBSETS = mondo-rare
SUBSET_ROOTS = $(patsubst %, subsets/%, $(SUBSETS))
SUBSET_FILES = $(foreach n,$(SUBSET_ROOTS), $(n).owl $(n).obo $(n).json $(n)_nodes.tsv $(n)_edges.tsv)
REPORTS = basic-report class-count-by-prefix edges xrefs obsoletes obsoletion-candidates synonyms class-stats root-classes superclass-count
REPORT_ARGS = $(foreach V,$(REPORTS),-s $(SPARQLDIR)/reports/$V.sparql reports/$V.tmp.tsv)
MAIN_REPORT_FILES = $(foreach V, $(REPORTS), reports/$V.tsv)
ADDITIONAL_REPORT_FILES = reports/semantic-xref-pairs.tsv
#ADDITIONAL_REPORT_FILES = reports/release/mondo-obo-report.yaml reports/release/mondo-owl-report.yaml reports/release/semantic-xref-pairs.tsv
REPORT_FILES = $(MAIN_REPORT_FILES) $(ADDITIONAL_REPORT_FILES)
MAIN_PRODUCTS = $(ONT) $(ONT)-base $(ONT)-simple
MAIN_FILES = $(foreach n,$(MAIN_PRODUCTS), $(n).owl $(n).obo $(n).json) $(ONT)_nodes.tsv $(ONT)_edges.tsv
EQUIVALENTS_FILES=imports/equivalencies
EQUIVALENTS = $(foreach n, $(EQUIVALENTS_FILES), $(n).owl $(n).obo $(n).json)
ARTEFACTS = \
$(IMPORT_FILES) \
$(MAIN_FILES) \
$(EQUIVALENTS) \
$(REPORT_FILES) \
$(COMPONENT_FILES) \
$(SUBSET_FILES)
REPORT_FILES_RELEASE = reports/mondo_release_diff_changed_terms.tsv \
reports/mondo_release_diff_new_terms.tsv \
reports/mondo_obsoletioncandidates.tsv
ASSETS = $(MAIN_FILES) $(SUBSET_FILES) $(EQUIVALENTS) \
../../README.md \
$(REPORT_FILES_RELEASE)
list_main_files:
echo $(MAIN_FILES)
list_artefacts:
echo $(ARTEFACTS)
du -sh $(ARTEFACTS)
%-DU:
@test -f $* && du -sh $* || echo "MISSING" $*
all_artefacts: all_reports $(ARTEFACTS)
all_release_reports: $(REPORT_FILES_RELEASE)
# ----------------------------------------
# Tests
# ----------------------------------------
#all: test all_imports all_reports all_equivalencies all_subsets imports/equivalencies.obo $(ONT).owl $(ONT).obo $(ONT).json pre/$(ONT).owl pre/$(ONT).obo pre/$(ONT).json extid/$(ONT).owl extid/$(ONT).obo extid/$(ONT).json $(ONT)-merged.owl
#TODO: roundtrip.obo seems unnecessary check.
test: sparql_test_edit roundtrip.obo debug.owl debug_inference_check.owl mondo-edit.owl sparql_test_main_obo test_nomerge
test: reports/robot-report-mondo-tags-reasoned.owl.tsv
# ----------------------------------------
# Staging releases
# ----------------------------------------
#prepare_release: $(ARTEFACTS)
# $(MAKE) mappings -B
# rsync -R $^ ../..
# note: only reports, imports
prepare_release_direct:
rsync -R $(ARTEFACTS) ../..
all_includes: $(INCLUDES_OWL)
#OSF_UPLOAD = $(HOME)/repos/osf-cli/venv/bin/osf -p 2qk53 upload
#osf_upload: prepare_release osf_upload_direct
#osf_upload_direct:
# cd ../.. && $(OSF_UPLOAD) -f -r target/ current/ && $(OSF_UPLOAD) -f -r target/ releases/$(ISODATE)
list_assets:
ls -alt $(ASSETS)
echo $(GHVERSION)
check_version_set:
@test $(GHVERSION)
# REMEMBER TO COMMIT/PUSH
# e.g. make deploy_release GHVERSION=v2018-10-26
# this will create the GH repo. Use --no-create if repo already created.
deploy_release: deploy_assets_direct
#deploy_assets_current see https://github.com/OBOFoundry/purl.obolibrary.org/pull/723
# deploys to a versioned released
deploy_assets_direct:
@test $(GHVERSION)
ls -alt $(ASSETS)
gh release create $(GHVERSION) --notes "TBD." --title "$(GHVERSION)" --draft $(ASSETS)
# ../utils/make-release-assets.py -c $(RELEASE_ASSETS_OPTS) --release $(GHVERSION) $(ASSETS)
# deploys to https://github.com/monarch-initiative/mondo/releases/tag/current
#deploy_assets_current:
# ls -alt $(ASSETS)
# ../utils/make-release-assets.py -c -f --release current $(ASSETS)
# ----------------------------------------
# Main release targets
# ----------------------------------------
ANN = annotate -V $(ONTURI)/releases/`date +%Y-%m-%d`/[email protected]
# the GITHUB_ACTION flag should be set to true to skip computationally intensive actions in the pipeline that are not necessary for QC, see filtered.obo
# Use sparingly
GITHUB_ACTION = false
filtered.obo: $(SRC)
perl -ne 'print unless (m@^xref: (Orphanet|OMIM|OMIMPS|DOID|EFO|NCIT|SCTID|MESH|UMLS|ICD10CM|icd11.foundation):@ && !(m@(obsoleteEquivalent|equivalentObsolete|equivalentTo|relatedTo|mondoIsNarrowerThanSource|directSiblingOf|mondoIsBroaderThanSource)@i))' $< | grep -v '^property_value: excluded_subClassOf' | egrep -v '^synonym: .*EXCLUDE' | egrep -v 'relationship: disease_has_basis_in_dysfunction_of (hgnc|HGNC|NCBIGene):' > [email protected] && mv [email protected] $@
perl -ne 'print if !(/^xref: (Orphanet|OMIM|OMIMPS|DOID):/ && !(/(obsoleteEquivalent|equivalentObsolete|equivalentTo|obsoleteEquivalentObsolete)/i))' $@ > [email protected] && mv [email protected] $@
if [ $(GITHUB_ACTION) = false ]; then $(ROBOT) query -i $@ --use-graphs false \
--update ../sparql/update/delete-axiom-annotations.ru \
--update ../sparql/update/delete-axiom-annotations-by-prefix.ru \
--update ../sparql/update/inject-cross-species-analog.ru \
remove --term-file config/remove-annotations-before-release.txt \
convert -f obo --check false -o [email protected] && mv [email protected] $@; fi
#egrep -v 'MONDO:(subClassOf|superClassOf|relatedTo)' $< > $@
skos.ttl: filtered.obo
../utils/mk-skos.pl $< > $@
# this appears to be problematic. not all declarations are restored on a save.
#REMOVE_DECLARATIONS = --remove-axioms -t Declaration
REMOVE_DECLARATIONS=
# necessary to remove stray declarations induced by obo2owl;
# we remove declaration axioms for ALL classes;
# all necessary ones are implicitly added back when converting back to OWL
# see: https://github.com/owlcs/owlapi/pull/761
filtered.owl: filtered.obo skos.ttl
owltools --use-catalog $< $(REMOVE_DECLARATIONS) skos.ttl --merge-support-ontologies -o $@
# perform reasoning on source
# PREVIOUS: SKIP FOR NOW: assume pre-asserted, but run reasoner to check
# note: $(ROBOT) will protect redundant annotated axioms
reasoned.owl: filtered.owl
$(ROBOT) reason -T true -x true -X true -i $< -r ELK relax reduce -p false -r ELK \
remove --term MONDO:0700097 --term OGMS:0000031 $(ANN) -o $@
#test: reasoned-plus-equivalents.owl
# merged = reasoned + equivalencies
reasoned-plus-equivalents.owl: reasoned.owl imports/equivalencies.owl
owltools --use-catalog $^ --merge-support-ontologies -o $@
#$(ROBOT) reason -i $@ --equivalent-classes-allowed asserted-only -o $(TMPDIR)/$@_test_equivalents.owl
# PRE-RELEASES: MONDO IDs primary
#
# by default we use Elk to perform a reason-relax-reduce chain
# after that we annotate the ontology with the release versionInfo
$(ONT).owl: reasoned.owl
$(ROBOT) merge -i $< annotate -V $(ONTURI)/releases/`date +%Y-%m-%d`/$(ONT).owl -o $@
$(ONT).obo: $(ONT).owl
$(ROBOT) annotate -i $< \
-V $(ONTURI)/releases/`date +%Y-%m-%d`/$(ONT).owl \
--ontology-iri $(OBO)/$(ONT).owl \
convert --check false -f obo -o [email protected] &&\
grep -v ^owl-axioms [email protected] > $@ && rm [email protected]
$(ONT).json: $(ONT).owl
$(ROBOT) convert --input $< --check false -f json -o [email protected] &&\
mv [email protected] $@
$(ONT)_nodes.tsv $(ONT)_edges.tsv: $(ONT).json
kgx transform --input-format obojson --output-format tsv --output $(ONT) $< && test -f $(ONT)_nodes.tsv
ONTOLOGYTERMS=$(TMPDIR)/mondo_classes.txt
$(ONTOLOGYTERMS): reasoned.owl
$(ROBOT) query -f csv -i $< --query ../sparql/signature/mondo-classes.sparql $@
SIMPLESEED=$(TMPDIR)/simple_seed.txt
$(SIMPLESEED): reasoned.owl $(ONTOLOGYTERMS)
$(ROBOT) query -f csv -i $< --query ../sparql/signature/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" >> $@
# foo-simple: (edit->reason,relax,reduce,drop imports, drop every axiom which contains an entity outside the "namespaces of interest")
# drop every axiom: filter --term-file keep_terms.txt --trim true
# remove --select imports --trim false
# NOTE FOR FUTURE: this is slightly different from the usual simple as it completely removes all
# Object properties from the ontology (remove --select object-properties).
$(ONT)-simple.owl: reasoned.owl $(OTHER_SRC) $(SIMPLESEED) $(IMPORT_FILES)
$(ROBOT) merge --input $< \
reason --equivalent-classes-allowed none --exclude-tautologies true --annotate-inferred-axioms true \
relax \
remove --axioms equivalent \
remove --select object-properties \
relax \
filter --term-file $(SIMPLESEED) --select "annotations ontology anonymous self" --trim true --signature true \
reduce \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru \
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output [email protected] && mv [email protected] $@
$(ONT)-simple.obo: $(ONT)-simple.owl
$(OWL2OBO)
$(ONT)-simple.json: $(ONT)-simple.owl
$(ROBOT) convert -i $< -o [email protected] && mv [email protected] $@
#$(ONT)-atomic.owl: $(ONT).owl
# owltools --use-catalog $< --remove-imports-declarations --set-ontology-id $(OBO)/$(ONT)/$@ -o [email protected] && mv [email protected] $@
# Component module.
# we remove imports and merge in additional assertions
# note: typically component is not pre-reasoned, but this is compex for mondo.
OTHER_SRC=imports/axioms.owl #components/mondo-tags.owl
# The --select "<http://purl.obolibrary.org/obo/BFO_*>" is due to a bug with the reason -x option
# Which is supposed to exclude external namespaces from reason, but does not. My guess:
# BFO namespace was needed for Object Properties.
$(ONT)-base.owl: reasoned.owl $(OTHER_SRC)
$(ROBOT) remove --input $< --select imports --trim false \
merge $(patsubst %, -i %, $(OTHER_SRC)) \
remove --select "<http://purl.obolibrary.org/obo/BFO_*>" --select classes \
annotate --annotation http://purl.org/dc/elements/1.1/type http://purl.obolibrary.org/obo/IAO_8000001 \
--ontology-iri $(ONTBASE)/$@ --version-iri $(ONTBASE)/releases/$(TODAY)/$@ \
--output [email protected] && mv [email protected] $@
$(ONT)-base.obo: $(ONT)-base.owl
$(OWL2OBO)
$(ONT)-base.json: $(ONT)-base.owl
$(ROBOT) convert -i $< -o [email protected] && mv [email protected] $@
#pre/$(ONT).%: $(ONT).%
# $(ROBOT) annotate -i $< -V $(ONTURI)/pre/$(ONT).owl -o $@
#pre/$(ONT).json: $(ONT).owl
# $(ROBOT) annotate -i $< -V $(ONTURI)/pre/$(ONT).owl -o $@
# CURRENT RELEASES: map back to clique leaders
#extid/mondo.owl: mondo.owl
# owltools --use-catalog $< --reasoner elk --merge-equivalence-sets -s NCIT 20 -s Orphanet 10 -s OMIM 8 -s EFO 6 -s DOID 5 -s MESH 4 -s MONDO 1 --remove-dangling -o $@
#extid/mondo.obo: extid/mondo.owl
# owltools --use-catalog $< --remove-imports-declarations --remove-dangling -o -f obo --no-check [email protected] && $(obo-filter-axiom-header) [email protected] > $@
#$(ONT)-basic.owl: $(ONT).owl
# owltools --use-catalog $< --remove-imports-declarations --remove-dangling -o $@
#$(ONT)-basic.obo: $(ONT)-basic.owl
# owltools --use-catalog $< -o -f obo $(ONT).obo.tmp && mv $(ONT).obo.tmp $@
%.json: %.owl
$(ROBOT) convert --input $< --check false -f json -o [email protected] &&\
mv [email protected] $@
# ensure that inference including equivalencies does not result in merging any classes in MONDO.
# if this fails, the resolution is to look for two MONDO classes with equivalence to the same external class
test_nomerge: mondo.owl
owltools --log-error --use-catalog $< --reasoner elk --merge-equivalence-sets -P MONDO -s MONDO 100 --remove-dangling -o $@
# ----------------------------------------
# Inference comparison
# ----------------------------------------
filtered-nr.obo: filtered.owl
$(ROBOT) relax -i $< reduce -p false -r ELK annotate -O $(OBO)/mondo/$@ -o [email protected] && owltools --use-catalog [email protected] --remove-axiom-annotations -o -f obo --no-check [email protected] && grep -v ^owl-axioms [email protected] | obo-grep.pl -r MONDO: - > $@
filtered-nr-reasoned.obo: filtered.owl
$(ROBOT) relax -i $< reduce -p false -r ELK reason -r ELK annotate -O $(OBO)/mondo/$@ -o [email protected] && owltools --use-catalog [email protected] --remove-axiom-annotations -o -f obo --no-check [email protected] && grep -v ^owl-axioms [email protected] | obo-grep.pl -r MONDO: - > $@
reports/reasoner-diff.obo: filtered-nr.obo filtered-nr-reasoned.obo
obo-simple-diff.pl -l $^ > $@
# ----------------------------------------
# CC-0 MINIMAL
# ----------------------------------------
all_subsets: $(SUBSET_FILES)
RARE_SUBSET_PRESERVED_RELATIONS=RO:0004003 RO:0000053
tmp/rare-subset-pre.owl: #$(SRC)
$(ROBOT) merge -i $(SRC) reason relax materialize $(patsubst %, --term %, $(RARE_SUBSET_PRESERVED_RELATIONS)) -o $@
# This gets us all the rare disease classes:
tmp/rare-seed-classes.txt: tmp/rare-subset-pre.owl
$(ROBOT) merge -i $< query --query ../sparql/signature/rare-subset.sparql $@
.PRECIOUS: tmp/rare-seed-classes.txt
# This gets us all the rare disease classes:
tmp/rare-seed-parents.txt: tmp/rare-subset-pre.owl
$(ROBOT) merge -i $< query --query ../sparql/signature/rare-subset-parents.sparql $@
.PRECIOUS: tmp/rare-seed-parents.txt
# This gets us all the entities linked to the rare disease classes
# Make sure you add the relationships you want to add to ../sparql/signature/rare-subset-related-entity.sparql
# AND config/rare_subset_relations.txt
tmp/rare-seed-entities.txt: tmp/rare-subset-pre.owl tmp/rare-seed-classes.txt
$(ROBOT) merge -i $< filter -T tmp/rare-seed-classes.txt --trim false query --query ../sparql/signature/rare-subset-related-entity.sparql $@
.PRECIOUS: tmp/rare-seed-entities.txt
# This merges thes seed together into one file (including rare disease classes _and_ related entities.)
tmp/rare-seed.txt: tmp/rare-seed-entities.txt tmp/rare-seed-classes.txt config/rare_subset_relations.txt tmp/rare-seed-parents.txt
cat $^ | sort | uniq > $@
.PRECIOUS: tmp/rare-seed.txt
subsets/mondo-rare.owl: $(ONT)-base.owl $(TMPDIR)/hgnc_import.owl tmp/rare-seed.txt | $(SUBSETDIR)
$(ROBOT) merge -i $< -i $(TMPDIR)/hgnc_import.owl extract --method subset -T tmp/rare-seed.txt --output $@ &&\
$(ROBOT) annotate --input $@ --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) -o [email protected] && mv [email protected] $@
.PRECIOUS: $(SUBSETDIR)/mondo-rare.owl
subsets/%.json: subsets/%.owl
$(ROBOT) convert -i $< -o $@
subsets/%_nodes.tsv subsets/%_edges.tsv: subsets/%.json
kgx transform --input-format obojson --output-format tsv --output subsets/$* $< && test -f subsets/$*_nodes.tsv
subsets/%.obo: subsets/%.owl
$(ROBOT) convert -i $< -o [email protected] && grep -v ^owl-axioms: [email protected] > $@ && rm [email protected]
rare_subset:
$(MAKE) IMP=false MIR=false COMP=false subsets/mondo-rare.owl subsets/mondo-rare.json subsets/mondo-rare.obo
# ----------------------------------------
# DOSDP Modules
# ----------------------------------------
all_mods: modules/disease_by_location.owl
modules/%.tsv: modules/%.csv
csv2tsv.py $< $@
modules/%.owl: modules/%.tsv
dosdp-tools --obo-prefixes --ontology=../ontology/mondo-edit.obo --template=../patterns/$*.yaml --outfile=$@ generate --infile=$<
###### BEGIN PARTIAL ODK MIGRATION ##############
$(TMPDIR) $(REPORTDIR) $(MIRRORDIR) $(IMPORTDIR) $(COMPONENTSDIR) $(SUBSETDIR):
mkdir -p $@
# ----------------------------------------
# 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
# 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
if [ $(IMP) = true ]; then cat $^ | grep -v ^# | sort | uniq > $@; fi
ALL_TERMS_COMBINED = $(patsubst %, $(IMPORTDIR)/%_terms_combined.txt, $(IMPORTS))
$(IMPORTDIR)/merged_terms_combined.txt: $(ALL_TERMS_COMBINED)
if [ $(IMP) = true ]; then cat $^ | grep -v ^# | sort | uniq > $@; fi
$(IMPORTDIR)/merged_import.owl: $(MIRRORDIR)/merged.owl $(IMPORTDIR)/merged_terms_combined.txt
if [ $(IMP) = true ]; then $(ROBOT) merge -i $< \
remove --select "<http://purl.obolibrary.org/obo/GOCHE_*>" remove --select "<http://purl.obolibrary.org/obo/NCBITaxon_Union_*>" remove --select "<http://www.informatics.jax.org/marker/MGI:*>" remove --select "<http://purl.obolibrary.org/obo/OBI_*>" remove --select "<http://purl.obolibrary.org/obo/CARO_*>" remove --select "<http://purl.obolibrary.org/obo/RnorDv_*>" remove --select "<http://purl.obolibrary.org/obo/PR_*>" remove --select "<http://purl.obolibrary.org/obo/PCO_*>" remove --select "<http://purl.obolibrary.org/obo/ExO_*>" remove --select "<http://purl.obolibrary.org/obo/FAO_*>" remove --select "<http://purl.obolibrary.org/obo/UPHENO_*>" remove --select "<http://purl.obolibrary.org/obo/COB_*>" remove --select "<http://purl.obolibrary.org/obo/MPATH_*>" remove --select "<http://purl.obolibrary.org/obo/PO_*>" remove --select "<http://purl.obolibrary.org/obo/ENVO_01001055*>" \
extract -T $(IMPORTDIR)/merged_terms_combined.txt --force true --copy-ontology-annotations true --individuals exclude --method BOT \
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); fi
$(IMPORTDIR)/%_import.owl: $(MIRRORDIR)/merged.owl $(IMPORTDIR)/%_terms_combined.txt
if [ $(IMP) = true ]; then $(ROBOT) query -i $< --update ../sparql/preprocess-module.ru \
extract -T $(IMPORTDIR)/$*_terms_combined.txt --force true --copy-ontology-annotations true --individuals exclude --method BOT \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
$(ANNOTATE_CONVERT_FILE); fi
.PRECIOUS: $(IMPORTDIR)/%_import.owl
.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
# ----------------------------------------
# Mirroring upstream ontologies
# ----------------------------------------
IMP=true # Global parameter to bypass import generation
MIR=true # Global parameter to bypass mirror generation
IMP_LARGE=true # Global parameter to bypass handling of large imports
## ONTOLOGY: uberon
.PHONY: mirror-uberon
.PRECIOUS: $(MIRRORDIR)/uberon.owl
mirror-uberon: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/uberon.owl --create-dirs -o $(MIRRORDIR)/uberon.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/uberon.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri http://purl.obolibrary.org/obo/UBERON_ --base-iri http://purl.obolibrary.org/obo/UBPROP_ --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: cl
.PHONY: mirror-cl
.PRECIOUS: $(MIRRORDIR)/cl.owl
mirror-cl: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/cl.owl --create-dirs -o $(MIRRORDIR)/cl.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/cl.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/CL --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: go
.PHONY: mirror-go
.PRECIOUS: $(MIRRORDIR)/go.owl
mirror-go: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/go.owl --create-dirs -o $(MIRRORDIR)/go.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/go.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/GO --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: pato
.PHONY: mirror-pato
.PRECIOUS: $(MIRRORDIR)/pato.owl
mirror-pato: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/pato.owl --create-dirs -o $(MIRRORDIR)/pato.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/pato.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/PATO --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: envo
.PHONY: mirror-envo
.PRECIOUS: $(MIRRORDIR)/envo.owl
mirror-envo: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/envo.owl --create-dirs -o $(MIRRORDIR)/envo.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/envo.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/ENVO --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: ro
.PHONY: mirror-ro
.PRECIOUS: $(MIRRORDIR)/ro.owl
mirror-ro: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/ro/ro-base.owl --create-dirs -o $(MIRRORDIR)/ro.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/ro.owl -o [email protected] && mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: hp
.PHONY: mirror-hp
.PRECIOUS: $(MIRRORDIR)/hp.owl
mirror-hp: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/hp.owl --create-dirs -o $(MIRRORDIR)/hp.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/hp.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/HP --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: mf
.PHONY: mirror-mf
.PRECIOUS: $(MIRRORDIR)/mf.owl
mirror-mf: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/mf.owl --create-dirs -o $(MIRRORDIR)/mf.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/mf.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/MF --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: ncbitaxon
.PHONY: mirror-ncbitaxon
.PRECIOUS: $(MIRRORDIR)/ncbitaxon.owl
mirror-ncbitaxon: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I http://purl.obolibrary.org/obo/ncbitaxon/subsets/taxslim.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri http://purl.obolibrary.org/obo/NCBITaxon_ --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: chebi
.PHONY: mirror-chebi
.PRECIOUS: $(MIRRORDIR)/chebi.owl
mirror-chebi: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I https://raw.githubusercontent.com/obophenotype/chebi_obo_slim/main/chebi_slim.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/CHEBI --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: ncit
.PHONY: mirror-ncit
.PRECIOUS: $(MIRRORDIR)/ncit.owl
mirror-ncit: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/ncit.owl --create-dirs -o $(MIRRORDIR)/ncit.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/ncit.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/NCIT --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: hgnc
.PHONY: mirror-hgnc
.PRECIOUS: $(MIRRORDIR)/hgnc.owl
mirror-hgnc: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/hgnc.owl --create-dirs -o $(MIRRORDIR)/hgnc.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/hgnc.owl -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: foodon
.PHONY: mirror-foodon
.PRECIOUS: $(MIRRORDIR)/foodon.owl
mirror-foodon: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/foodon.owl --create-dirs -o $(MIRRORDIR)/foodon.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/foodon.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/FOODON --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: so
.PHONY: mirror-so
.PRECIOUS: $(MIRRORDIR)/so.owl
mirror-so: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/so.owl --create-dirs -o $(MIRRORDIR)/so.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/so.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/SO --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: ecto
.PHONY: mirror-ecto
.PRECIOUS: $(MIRRORDIR)/ecto.owl
mirror-ecto: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/ecto.owl --create-dirs -o $(MIRRORDIR)/ecto.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/ecto.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/ECTO --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: omo
.PHONY: mirror-omo
.PRECIOUS: $(MIRRORDIR)/omo.owl
mirror-omo: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/omo.owl --create-dirs -o $(MIRRORDIR)/omo.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/omo.owl -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: chr
.PHONY: mirror-chr
.PRECIOUS: $(MIRRORDIR)/chr.owl
mirror-chr: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I https://raw.githubusercontent.com/monarch-initiative/monochrom/master/chr-base.owl -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: hsapdv
.PHONY: mirror-hsapdv
.PRECIOUS: $(MIRRORDIR)/hsapdv.owl
mirror-hsapdv: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/hsapdv.owl --create-dirs -o $(MIRRORDIR)/hsapdv.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/hsapdv.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri http://purl.obolibrary.org/obo/HsapDv_ --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: nbo
.PHONY: mirror-nbo
.PRECIOUS: $(MIRRORDIR)/nbo.owl
mirror-nbo: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/nbo.owl --create-dirs -o $(MIRRORDIR)/nbo.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/nbo.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/NBO --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: maxo
.PHONY: mirror-maxo
.PRECIOUS: $(MIRRORDIR)/maxo.owl
mirror-maxo: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/maxo.owl --create-dirs -o $(MIRRORDIR)/maxo.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/maxo.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/MAXO --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
## ONTOLOGY: mfomd
.PHONY: mirror-mfomd
.PRECIOUS: $(MIRRORDIR)/mfomd.owl
mirror-mfomd: | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L $(OBOBASE)/mfomd.owl --create-dirs -o $(MIRRORDIR)/mfomd.owl --retry 4 --max-time 400 &&\
$(ROBOT) convert -i $(MIRRORDIR)/mfomd.owl -o [email protected] && \
$(ROBOT) remove -i [email protected] --base-iri $(URIBASE)/MFOMD --axioms external --preserve-structure false --trim false -o [email protected] &&\
mv [email protected] $(TMPDIR)/[email protected]; fi
ALL_MIRRORS = $(patsubst %, $(MIRRORDIR)/%.owl, $(IMPORTS))
MERGE_MIRRORS = true
$(MIRRORDIR)/merged.owl: $(ALL_MIRRORS)
if [ $(IMP) = true ] && [ $(MERGE_MIRRORS) = true ]; then $(ROBOT) merge $(patsubst %, -i %, $^) remove --axioms equivalent --preserve-structure false -o $@; fi
.PRECIOUS: $(MIRRORDIR)/merged.owl
$(MIRRORDIR)/%.owl: mirror-% | $(MIRRORDIR)
if [ $(IMP) = true ] && [ $(MIR) = true ] && [ -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
###### END PARTIAL ODK MIGRATION ##############
###### BEGIN CUSTOM IMPORTS ###################
mirror/hgnc_gene.nt: | $(MIRRORDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L https://data.monarchinitiative.org/monarch-kg/latest/rdf/hgnc_gene.nt.gz | gzip -d > [email protected] &&\
perl -npe 's@https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/HGNC:@http://identifiers.org/hgnc/@g' [email protected] > $@; fi
.PRECIOUS: mirror/hgnc_gene.nt
mirror/ncbi_gene.nt: | $(MIRRORDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then curl -L https://github.com/monarch-initiative/ncbi-gene/releases/latest/download/ncbi_gene.nt.gz | gzip -d > [email protected] &&\
perl -npe 's@https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/HGNC:@http://identifiers.org/hgnc/@g' [email protected] > $@; fi
.PRECIOUS: mirror/ncbi_gene.nt
mirror-hgnc: mirror/hgnc_gene.nt | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) merge -i $< \
query --format ttl --query ../sparql/construct/construct-hgnc.sparql $(TMPDIR)/[email protected]; fi
../sparql/construct/construct-ncbigene.sparql: ../sparql/construct/construct-ncbigene.sparql.template $(IMPORTDIR)/merged_terms_combined.txt
@awk '{print " <" $$0 ">"}' $(IMPORTDIR)/merged_terms_combined.txt | grep ncbigene | paste -sd '\n' > $(TMPDIR)/formatted_values.tmp
@sed "/{{VALUES}}/r $(TMPDIR)/formatted_values.tmp" $< | sed '/{{VALUES}}/d' > $@
@rm "$(TMPDIR)/formatted_values.tmp"
mirror-ncbigene: mirror/ncbi_gene.nt ../sparql/construct/construct-ncbigene.sparql | $(TMPDIR)
if [ $(MIR) = true ] && [ $(IMP) = true ]; then arq --data=mirror/ncbi_gene.nt --query=../sparql/construct/construct-ncbigene.sparql > $(TMPDIR)/[email protected]; fi
$(TMPDIR)/hgnc_import.owl: $(IMPORTDIR)/merged_import.owl
$(ROBOT) filter -i $< --term SO:0000704 --select "annotations self descendants" --signature true \
query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru --update ../sparql/postprocess-module.ru \
annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) convert -f owl --output [email protected] && mv [email protected] $@
IMPORTSEED=$(IMPORTDIR)/seed.txt # SHOULD BE TMP
###### END CUSTOM IMPORTS ###################
edit-merged.owl: $(SRC)
$(ROBOT) merge -c true -i $< -o $@
imports/seed.txt: edit-merged.owl imports/manual_seed.txt
$(ROBOT) query -f tsv -i $< -s ../sparql/signature/classes.sparql [email protected]
cat [email protected] imports/manual_seed.txt | perl -npe 's@^\<@@;s@>$$@@' - | sort -u > $@
imports/%_terms.txt: imports/seed.txt
touch $@ && grep -hi $* $< $@ | sort -u > [email protected] && mv [email protected] $@
# ----------------------------------------
# Release
# ----------------------------------------
# copy from staging area (this directory) to top-level
#release: $(ONT).owl $(ONT).obo
# cp $^ $(RELEASEDIR) && cp imports/* $(RELEASEDIR)/imports && cp subsets/* $(RELEASEDIR)/subsets
mondo-lastbuild.owl:
curl -L -s $(OBO)/mondo.owl > [email protected] && mv [email protected] $@
mondo-lastbuild.obo:
curl -L -s $(OBO)/mondo.obo > [email protected] && mv [email protected] $@
#mondo-diff.md: mondo-lastbuild.owl
# owljs-diff -o $@ $< mondo.owl
mondo-diff.txt: mondo-lastbuild.obo
obo-simple-diff.pl $< mondo.obo > [email protected] && mv [email protected] $@
# ----------------------------------------
# Editing
# ----------------------------------------
td:
echo $(ISODATE)
# NOTE: no longer removes redundant
INF: mondo-edit.obo
owltools --use-catalog mondo-edit.obo --assert-inferred-subclass-axioms --always-assert-super-classes --keepRedundant --markIsInferred --merge-axiom-annotations -o -f obo [email protected] && grep -v ^owl-axioms [email protected] | perl -npe 's@is_inferred="true"@source="OWLReasoner:Elk-$(ISODATE)"@' | egrep -v '^relationship:.*is_inferred' | obo-grep.pl --neg -r 'id: (UBERON|CL|ENVO|NCBITaxon|HP|PATO|CHEBI):' - > $@
# normalize obo file
# note we use owltools-compat to ensure standard ordering
NORM: mondo-edit.obo
owltools --use-catalog mondo-edit.obo --merge-axiom-annotations -o -f obo [email protected] && $(ROBOT) convert -i [email protected] -o [email protected] && mv [email protected] $@
# tests roundtripping
roundtrip.obo: mondo-edit.obo
owltools --use-catalog mondo-edit.obo -o -f obo [email protected] && mv [email protected] $@
NEWAXTEST: mondo-edit.owl new.owl
# owltools --use-catalog $^ --merge-support-ontologies --run-reasoner -r elk -u -m z.owl -o $@
owltools --use-catalog $^ --merge-support-ontologies --assert-inferred-subclass-axioms --always-assert-super-classes --markIsInferred --removeRedundant --merge-axiom-annotations -o -f obo [email protected] && grep -v ^owl-axioms [email protected] | egrep -v '^relationship:.*is_inferred' | obo-grep.pl --neg -r 'id: (UBERON|CL|ENVO|NCBITaxon|HP|PATO|CHEBI):' - > $@
# ----------------------------------------
# Sparql queries: Q/C
# ----------------------------------------
SPARQL_MONDO_QC=$(patsubst %.sparql, %, $(notdir $(wildcard $(SPARQLDIR)/qc/mondo/qc-*.sparql)))
SPARQL_GENERAL_QC=$(patsubst %.sparql, %, $(notdir $(wildcard $(SPARQLDIR)/qc/general/qc-*.sparql)))
SPARQL_EDIT_EXCLUDE=
# qc-duplicate-exact-synonym-no-abbrev is excluded from the OBO check because we are running the OBO check on the base file
# There is something super weird about the way the OBO file is generated that causes this to fail
# Because the id of ontology is `ontology: mondo/mondo-base`, all the IRIs to properties related to
# the ontology begin looking like this: http://purl.obolibrary.org/obo/mondo/mondo-base#... This
# will cause the query to fail because it expects the IRI http://purl.obolibrary.org/obo/mondo#ABREVIATION
# for the duplicate-exact-synonym-no-abbrev check.
SPARQL_OBO_EXCLUDE=qc-single-child qc-omimps-should-be-inherited qc-omim-subsumption qc-permitted-properties qc-duplicate-exact-synonym-no-abbrev
SPARQL_OWL_EXCLUDE=qc-permitted-properties
SPARQL_GENERAL_QC_EDIT=$(filter-out $(SPARQL_EDIT_EXCLUDE),$(SPARQL_GENERAL_QC))
SPARQL_GENERAL_QC_OWL=$(filter-out $(SPARQL_OWL_EXCLUDE),$(SPARQL_GENERAL_QC))
SPARQL_GENERAL_QC_OBO=$(filter-out $(SPARQL_OBO_EXCLUDE),$(SPARQL_GENERAL_QC))
SPARQL_MONDO_QC_EDIT=$(filter-out $(SPARQL_EDIT_EXCLUDE),$(SPARQL_MONDO_QC))
SPARQL_MONDO_QC_OWL=$(filter-out $(SPARQL_OWL_EXCLUDE),$(SPARQL_MONDO_QC))
SPARQL_MONDO_QC_OBO=$(filter-out $(SPARQL_OBO_EXCLUDE),$(SPARQL_MONDO_QC))
SPARQL_MONDO_QC_FILES=$(foreach V,$(SPARQL_MONDO_QC),$(SPARQLDIR)/qc/mondo/$V.sparql)
SPARQL_GENERAL_QC_FILES_EDIT=$(foreach V,$(SPARQL_GENERAL_QC_EDIT),$(SPARQLDIR)/qc/general/$V.sparql)
SPARQL_GENERAL_QC_FILES_OBO=$(foreach V,$(SPARQL_GENERAL_QC_OBO),$(SPARQLDIR)/qc/general/$V.sparql)
SPARQL_GENERAL_QC_FILES_OWL=$(foreach V,$(SPARQL_GENERAL_QC_OWL),$(SPARQLDIR)/qc/general/$V.sparql)
SPARQL_MONDO_QC_FILES_EDIT=$(foreach V,$(SPARQL_MONDO_QC_EDIT),$(SPARQLDIR)/qc/mondo/$V.sparql)
SPARQL_MONDO_QC_FILES_OBO=$(foreach V,$(SPARQL_MONDO_QC_OBO),$(SPARQLDIR)/qc/mondo/$V.sparql)
SPARQL_MONDO_QC_FILES_OWL=$(foreach V,$(SPARQL_MONDO_QC_OWL),$(SPARQLDIR)/qc/mondo/$V.sparql)
QSRC = $(SRC)-noimports.owl
$(QSRC): $(SRC)
owltools --use-catalog $< --remove-imports-declarations -o $@
SRC_TAGS_REASONED=mondo-tags-reasoned.owl
tmp/cross-species-mappings.owl: $(SRC)
mkdir -p tmp
$(ROBOT) query -i $< --use-graphs false --query ../sparql/construct/construct-cross-species-analog.sparql $@
$(SRC_TAGS_REASONED): $(SRC) tmp/cross-species-mappings.owl
$(ROBOT) merge -i $< -i components/mondo-tags.owl -i tmp/cross-species-mappings.owl --collapse-import-closure false reason -o $@
# run all violation checks on edit file
sparql_test_edit: $(SRC_TAGS_REASONED)
mkdir -p reports/edit/ &&\
$(ROBOT) verify -i $< --queries $(SPARQL_MONDO_QC_FILES_EDIT) $(SPARQL_GENERAL_QC_FILES_EDIT) -O reports/edit/ && touch $@
sparql_test_main_owl: $(ONT).owl
mkdir -p reports/main_owl/ &&\
$(ROBOT) verify -i $< --queries $(SPARQL_MONDO_QC_FILES_OWL) $(SPARQL_GENERAL_QC_FILES_OWL) -O reports/main_owl/ && touch $@
# See comment about http://purl.obolibrary.org/obo/mondo/mondo-base# above
# if you ever encounter "strange" errors related to Mondo internal property ids.
sparql_test_main_obo: $(ONT)-base.obo
mkdir -p reports/main_obo/ &&\
$(ROBOT) verify -i $< --queries $(SPARQL_MONDO_QC_FILES_OBO) $(SPARQL_GENERAL_QC_FILES_OBO) -O reports/main_obo/ && touch $@
PL2SPARQL = ../plq/pq-mondo
#../sparql/%.sparql:
# $(PL2SPARQL) -v "$*" > [email protected] && mv [email protected] $@
reports/pql-%.tsv: mondo-edit.owl
$(PL2SPARQL) -f tsv -v -i $< -e -l "$*" > [email protected] && mv [email protected] $@
reports/bg-%.tsv:
$(PL2SPARQL) -f tsv -l "$*" > [email protected] && mv [email protected] $@
reports/$(Q)-pqlx-$(Ont).tsv: mondo-edit.owl
$(PL2SPARQL) -f tsv -v -i $< -i mirror/$(Ont).owl -e -l "$(Q)" > [email protected] && mv [email protected] $@
reports/pq-%.tsv: mondo-edit.owl
$(PL2SPARQL) -f tsv -v -i $< -e "$*" > [email protected] && mv [email protected] $@
reports/equiv-obs-%.tsv:
pl2sparql -e -A void.ttl -i mondo_edit -i equivs -i mirror/$*.owl -c ../plq/mondo_queries.pro -l equivalent_to_deprecated > $@
reports/equiv-replaced-by-%.tsv:
pl2sparql -e -A void.ttl -i mondo_edit -i equivs -i mirror/$*.owl -c ../plq/mondo_queries.pro -l equivalent_to_replaced_by > $@
reports/proxy-merge.tsv: mondo.owl
./mq -i all proxy_merge -f tsv -l > [email protected] && sort -u [email protected] > $@
# pl2sparql -f tsv -A void.ttl -e -i all -c ../plq/proxy_merge.pro proxy_merge > [email protected] && mv [email protected] $@
# the main OWL file will have 'pseudo-roots' caused by the fact that external classes
# are referenced; restrict the report to those with labels
%.owl-roots.tsv: %.owl
$(ROBOT) query -f tsv -i $< -s $(SPARQLDIR)/reports/root-labeled-classes.sparql $@
%.obo-roots.tsv: %.obo
$(ROBOT) query -f tsv -i $< -s $(SPARQLDIR)/reports/root-classes.sparql $@
prefixes: mondo-edit.obo
grep ^xref $< | cut -f2 -d : | count-occ.pl
# ----------------------------------------
# Sparql queries: Reports
# ----------------------------------------
all_reports: all_reports_1 fix_reports
all_reports_1: mondo.owl $(ADDITIONAL_REPORT_FILES)
$(ROBOT) query -f tsv -i $< $(REPORT_ARGS) && touch $@
# Will be retired when we have https://github.com/ontodev/robot/issues/176
fix_reports: $(foreach V, $(REPORTS), fix-report-$V)
fix-report-%:
../utils/tidy-sparql-output.pl reports/$*.tmp.tsv > reports/$*.tsv
# TODO: remove hacky script once we improve $(ROBOT) output: https://github.com/ontodev/robot/issues/176
reports/query-%-mondo-edit.obo.tsv: $(SRC) $(SPARQLDIR)/reports/%.sparql
$(ROBOT) query -f tsv -i $< -s $(SPARQLDIR)/reports/$*.sparql [email protected] && ../utils/tidy-sparql-output.pl [email protected] > $@
reports/query-%-mondo.owl.tsv: mondo.owl $(SPARQLDIR)/reports/%.sparql
$(ROBOT) query -f tsv -i $< -s $(SPARQLDIR)/reports/$*.sparql [email protected] && ../utils/tidy-sparql-output.pl [email protected] > $@
# TODO: replace with sparql
#reports/semantic-xref-pairs.tsv: d2p.pro mondo-base.obo
# blip-findall -i mondo-base.obo -i $< -i ../../scratch/mondo-ncit-finding.pro -consult ../utils/xreftbl_maker.pro xrefrow/5 -no_pred > $@
#RR=$(HOME)/repos/rctauber/robot/bin/$(ROBOT) report --fail-on none
RR= $(ROBOT) report --fail-on ERROR --profile profile.txt --print 8
reports/robot-report-%.tsv: %
$(RR) -i $* -o $@
reports/mondo-edit-report.html: $(SRC_TAGS_REASONED)
$(ROBOT) report -i $< --profile profile.txt --fail-on ERROR -o $@
.PRECIOUS: reports/mondo-edit-report.html
mondo_edit_report: reports/mondo-edit-report.html
common_map.tsv:
blip-findall -debug index -goal ix -i imports/equivalencies.obo -i d2p.pro -r mondoe -c ../utils/all_genetic.pro common_to_mondo/2 -label -no_pred -use_tabs | cut -f1,3,4 > $@
# ----------------------------------------
# Sparql constructs
# ----------------------------------------
# generate includes from sparql CONSTRUCT queries;
# these can then be merged in to the main ontology
#include-%.owl: ../sparql/construct/construct-%.sparql $(SRC)
# $(ROBOT) merge -i $(SRC) query -c $< [email protected] -f ttl && $(ROBOT) annotate -i [email protected] -O $(OBO)/mondo/$@ -o $@
imports/external_definitions.owl: ../sparql/construct/construct-embedded-definition.sparql $(SRC)
$(ROBOT) merge -i $(SRC) query -c $< [email protected] -f ttl && $(ROBOT) annotate -i [email protected] -O $(OBO)/mondo/$@ -o $@
FIX_URIS_IN_PLACE = perl -pi -ne $(FIX_URI_EXPR)
all_equivalencies: imports/equivalencies.owl imports/equivalencies.obo imports/equivalencies.json
imports/equivalencies.owl: ../sparql/construct/construct-ecs-from-xrefs.sparql $(SRC)
$(ROBOT) merge -i $(SRC) query -c $< [email protected] -f ttl && $(FIX_URIS_IN_PLACE) [email protected] && $(ROBOT) annotate -i [email protected] -a $(PV_CC0) -O $(OBO)/mondo/$@ -o $@
imports/equivalencies.obo: imports/equivalencies.owl
$(ROBOT) convert -i $< -o $@
clean_imports: $(patsubst %, clean-mirror-%, $(ONTOLOGY_IMPORTS))
clean-mirror-%:
test -f mirror/$*.owl && rm mirror/$*.owl || echo 'no mirror file'
#imports/equivalencies.owl: $(SRC)
# ../utils/xrefs2axioms.pl $< > [email protected] && owltools [email protected] -o $@
# ----------------------------------------
# Merge constructs
# ----------------------------------------
mondo-premerge-%.owl: mondo.owl mirror/%.owl
owltools --use-catalog $^ --merge-support-ontologies -o [email protected] && mv [email protected] $@
mondo-plus-%.owl: mondo-premerge-%.owl
owltools --use-catalog $< --reasoner elk --merge-equivalence-sets -P MONDO -s MONDO 100 --remove-dangling -o [email protected] && mv [email protected] $@
mondo-compat-%: mondo.owl mirror/%.owl
owltools --use-catalog $^ --add-imports-from-supports --run-reasoner -r elk -u -m [email protected] && touch $@
# ----------------------------------------
# External ontologies
# ----------------------------------------
XD = gard ncit-disease obo_orphanet icd10 doid medgen-disease-extract snomed mesh
XD_OWL = $(patsubst %, mirror/%.owl, $(XD))
mirror/xdisease-all.owl: $(patsubst %, mirror/%.owl, $(XD))
owltools $^ --merge-support-ontologies -o $@
mirror/xdisease-labels.owl: mirror/xdisease-all.owl
$(ROBOT) query --format ttl -c ../sparql/construct/construct-labels.sparql $@ -i $<
mirror/labels: $(patsubst %, mirror/%-labels.owl, $(XD))
mirror/%-labels.owl: mirror/%.owl
$(ROBOT) query --format ttl -c ../sparql/construct/construct-labels.sparql $@ -i $<
mirror/%-raw.owl: mirror/%.owl
$(OWLTOOLS) $< --remove-axioms-about -v
mirror/neoplasm-core.owl:
wget --no-check-certificate $(OBO)/ncit/neoplasm-core.owl -O $@ && touch $@
mirror/ncit-disease.uris: mirror/ncit.owl
$(ROBOT) query -i $< -s ../sparql/signature/ncit-subclass-of-disease.sparql $@
mirror/ncit-disease.ids: mirror/ncit-disease.uris
perl -npe 's@http://purl.obolibrary.org/obo/NCIT_@NCIT:@' $< > $@
# Make a disease subset; ensure axioms are relaxed
mirror/ncit-disease.owl: mirror/ncit.owl mirror/ncit-disease.uris
$(ROBOT) extract -i $< -T mirror/ncit-disease.uris --method BOT relax -o $@