forked from monarch-initiative/mondo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1130 lines (834 loc) · 47 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
# ----------------------------------------
# Instructions
# ----------------------------------------
#
# This needs to be simplified!
#
# ```
# make all
# rm mondo-lastbuild.obo
# make mondo-diff.txt
# ./get-new-classes.sh
# [manually edit ../../Changes.md using output of previous command and "git log mondo-edit.obo"]
# ```
# ----------------------------------------
# Standard Constants
# ----------------------------------------
# these can be overwritten on the command line
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)
SRC=$(ONT)-edit.obo
#RELEASEDIR=../../target/
CATALOG=catalog-v001.xml
ROBOT= robot --catalog $(CATALOG)
OWLTOOLS= owltools
USECAT= --use-catalog
SPARQLDIR = ../sparql
PATTERNDIR = ../patterns
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
echo "release finished"
# ----------------------------------------
# Artefacts
# ----------------------------------------
ONTOLOGY_IMPORTS = uberon cl go pato ro hp mf oba ncbitaxon chebi envo ncit hgnc foodon so ecto omo
IMPORT_ROOTS = $(patsubst %, imports/%_import, $(ONTOLOGY_IMPORTS)) imports/equivalencies
IMPORT_FILES = $(foreach n,$(IMPORT_ROOTS), $(n).owl $(n).obo $(n).json) imports/axioms.owl
IMPORT_FILES_OWL = $(foreach n,$(IMPORT_ROOTS), $(n).owl) imports/axioms.owl
COMPONENTS = mondo-tags
COMPONENT_FILES = $(foreach n, $(COMPONENTS), components/$(n).owl)
SUBSETS = mondo-minimal
SUBSET_ROOTS = $(patsubst %, subsets/%, $(SUBSETS))
SUBSET_FILES = $(foreach n,$(SUBSET_ROOTS), $(n).owl $(n).obo $(n).json)
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)-with-equivalents
MAIN_FILES = $(foreach n,$(MAIN_PRODUCTS), $(n).owl $(n).obo $(n).json)
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)
ASSETS = $(MAIN_FILES) $(SUBSET_FILES) $(EQUIVALENTS) ../../README.md
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)
# ----------------------------------------
# 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
test: sparql_test_edit roundtrip.obo debug.owl mondo-edit.owl sparql_test_main_obo test_nomerge
test: reports/robot-report-mondo-edit.obo.tsv reports/robot-report-mondo.owl.tsv
test: reports/robot-report-mondo.obo.tsv
# ----------------------------------------
# Staging releases
# ----------------------------------------
prepare_release: $(ARTEFACTS)
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: prepare_release_direct 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)
../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]
filtered.obo: $(SRC)
perl -ne 'print unless (m@^xref: (Orphanet|OMIM|DOID|EFO|NCIT|SCTID|MESH|UMLS):@ && !(m@equivalent@i))' $< | grep -v '^property_value: confidence' | 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] $@
#egrep -v 'MONDO:(subClassOf|superClassOf|relatedTo)' $< > $@
skos.ttl: $(SRC)
../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 $(ANN) -o $@
# merged = reasoned + equivalencies
reasoned-plus-equivalents.owl: reasoned.owl imports/equivalencies.owl
owltools --use-catalog $^ --merge-support-ontologies -o $@
# 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 $@
# obo is self-contained
$(ONT).obo: reasoned.owl
owltools --use-catalog $< --remove-imports-declarations --remove-dangling -o -f obo --no-check [email protected] && $(obo-filter-axiom-header) [email protected] > $@
$(ONT).json: $(ONT).owl
owltools --use-catalog $< -o -f json $(ONT).json.tmp && mv $(ONT).json.tmp $@
# $(ROBOT) convert -i $< -f json -o $(ONT).json.tmp && mv $(ONT).json.tmp $@
$(ONT)-with-equivalents.owl: reasoned-plus-equivalents.owl
$(ROBOT) annotate -i $< -V $(ONTURI)/releases/`date +%Y-%m-%d`/$(ONT).owl -o $@
$(ONT)-with-equivalents.obo: $(ONT)-with-equivalents.owl
$(OWL2OBO)
$(ONT)-with-equivalents.json: $(ONT)-with-equivalents.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
$(ONT)-base.owl: reasoned.owl
$(ROBOT) remove --input $< --select imports --trim false \
merge $(patsubst %, -i %, $(OTHER_SRC)) \
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
owltools --use-catalog $< -o -f json [email protected] && mv [email protected] $@
# $(ROBOT) convert -i $< -f json -o $(ONT).json.tmp && mv $(ONT).json.tmp $@
# 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: subsets/mondo-minimal.obo subsets/mondo-minimal.owl subsets/mondo-minimal.json
TRIM_MINIMAL = --remove-imports-declarations --remove-abox --remove-axiom-annotations --remove-annotation-assertions -l -r -p $(OIO)hasDbXref -p $(SKOS)exactMatch -p $(SKOS)narrowMatch -p $(SKOS)relatedMatch -p $(SKOS)broadMatch
subsets/mondo-minimal.owl: mondo-base.owl imports/equivalencies.owl
owltools --use-catalog $< $(TRIM_MINIMAL) imports/equivalencies.owl --merge-support-ontologies --set-ontology-id $(OBO)/mondo/$@ -o [email protected] &&\
$(ROBOT) annotate -R -i [email protected] -o [email protected] &&\
owltools [email protected] --add-ontology-annotation $(PV_CC0) -o $@
subsets/%.json: subsets/%.owl
$(ROBOT) convert -i $< -o $@
subsets/%.obo: subsets/%.owl
$(ROBOT) convert -i $< -o [email protected] && grep -v ^owl-axioms: [email protected] > $@ && rm [email protected]
# ----------------------------------------
# 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=$<
# ----------------------------------------
# Import modules
# ----------------------------------------
# Most ontologies are modularly constructed using portions of other ontologies
# These live in the imports/ folder
# These can be regenerated with make all_imports
ONTOLOGY_IMPORTS_OWL = $(patsubst %, imports/%_import.owl, $(ONTOLOGY_IMPORTS))
ONTOLOGY_IMPORTS_OBO = $(patsubst %, imports/%_import.obo, $(ONTOLOGY_IMPORTS))
ONTOLOGY_IMPORTS_OWL_ROOTS = $(patsubst %, imports/%_import.owl-roots.tsv, $(ONTOLOGY_IMPORTS))
# Make this target to regenerate ALL
all_imports: all_imports_owl all_imports_obo all_imports_owl_roots
all_imports_owl: $(ONTOLOGY_IMPORTS_OWL)
all_imports_owl_roots: $(ONTOLOGY_IMPORTS_OWL_ROOTS)
all_imports_obo: $(ONTOLOGY_IMPORTS_OBO)
# Use ROBOT, driven entirely by terms lists NOT from source ontology
IMP=true
imports/%_import.owl: mirror/%.owl imports/%_terms.txt
if [ $(IMP) = true ]; then $(ROBOT) extract -i $< -T imports/$*_terms.txt --force true --individuals definitions --method BOT \
query --update ../sparql/inject-subset-declaration.ru \
remove -T imports/removeseed.txt \
reason --exclude-tautologies structural \
annotate --ontology-iri $(ONTBASE)/$@ --version-iri $(ONTBASE)/releases/$(TODAY)/$@ --output [email protected] && mv [email protected] $@; fi
.PRECIOUS: imports/%_import.owl
# we use owltools for making the obo file until: https://github.com/ontodev/robot/issues/64
imports/%_import.obo: imports/%_import.owl
$(OWLTOOLS) $(USECAT) $< -o -f obo --no-check [email protected] && grep -v ^owl-axioms [email protected] > $@
imports/omo_import.owl: mirror/omo.owl imports/omo_terms.txt
@if [ $(IMP) = true ]; then $(ROBOT) merge -i $< \
annotate --ontology-iri $(ONTBASE)/$@ --version-iri $(ONTBASE)/releases/$(TODAY)/$@ --output [email protected] && mv [email protected] $@; fi
.PRECIOUS: imports/omo_import.owl
imports/so_import.owl: mirror/so.owl imports/so_terms.txt
if [ $(IMP) = true ]; then $(ROBOT) extract -i $< -T imports/so_terms.txt --force true --individuals definitions --method BOT \
query --update ../sparql/inject-subset-declaration.ru \
remove -T imports/removeseed.txt \
remove --select object-properties \
reason --exclude-tautologies structural \
annotate --ontology-iri $(ONTBASE)/$@ --version-iri $(ONTBASE)/releases/$(TODAY)/$@ --output [email protected] && mv [email protected] $@; fi
.PRECIOUS: imports/omo_import.owl
edit-merged.owl: $(SRC)
$(ROBOT) merge -c true -i $< -o $@
imports/seed.txt: edit-merged.owl
$(ROBOT) query -f tsv -i $< -s ../sparql/signature/classes.sparql [email protected] && perl -npe 's@^\<@@;s@>$$@@' [email protected] | sort -u > $@
imports/%_terms.txt: imports/seed.txt
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=
SPARQL_OBO_EXCLUDE=qc-single-child qc-omimps-should-be-inherited qc-omim-subsumption
SPARQL_OWL_EXCLUDE=
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=tmp/src_tags_reasoned.owl
$(SRC_TAGS_REASONED): $(SRC)
$(ROBOT) merge -i $< -i components/mondo-tags.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 $@
sparql_test_main_obo: $(ONT).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/edit/report.tsv: $(SRC)
reports/release/mondo-obo-report.tsv: mondo.obo
reports/release/mondo-owl-report.tsv: mondo.owl
reports/robot-report-%.tsv: %
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
# You could trigger this upstream to get the very latest results:
# https://ci.monarchinitiative.org/view/dipper/job/build-omim
trigger-mirror:
touch $@
# clone remote ontology locally, perfoming some excision of relations and annotations
mirror/%.owl:
$(OWLTOOLS) $(OBO)/$*.owl --remove-annotation-assertions -l -s -d -r --remove-dangling-annotations --remove-axiom-annotations -o $@
.PRECIOUS: mirror/%.owl
mirror/ncbitaxon.owl:
wget --no-check-certificate $(OBO)/ncbitaxon.obo -O [email protected] && mv [email protected] $@ && touch $@
.PRECIOUS: mirror/ncbitaxon.owl
# hp.owl currently contains many stray root classes
mirror/hp.obo:
wget --no-check-certificate $(OBO)/hp.obo -O [email protected] && mv [email protected] $@ && touch $@
.PRECIOUS: mirror/hp.obo
mirror/hp.owl: mirror/hp.obo
$(OWLTOOLS) $< -o [email protected] && mv [email protected] $@
.PRECIOUS: mirror/hp.owl
mirror/chebi.owl:
wget --no-check-certificate $(OBO)/chebi.obo -O [email protected] && owltools [email protected] --remove-annotation-assertions -l -s -d --remove-dangling-annotations --remove-axiom-annotations -o $@ && touch $@
.PRECIOUS: mirror/chebi.owl
mirror/mfoem.owl:
$(OWLTOOLS) $(OBO)/mfoem.owl --remove-annotation-assertions -l -s -d --make-subset-by-properties -f BFO:0000050 // --remove-dangling-annotations -o $@
.PRECIOUS: mirror/mfoem.owl
# we have to roundtrip some ontologies through obo for obscure reasons see https://github.com/monarch-initiative/mondo/issues/237
mirror/doid.owl:
wget --no-check-certificate $(OBO)/doid.owl -O doid1.owl && owltools doid1.owl -o -f obo doid1.obo && owltools doid1.obo -o $@
# TODO: change this when monochrom is on OBO
mirror/chr.owl:
wget --no-check-certificate https://raw.githubusercontent.com/monarch-initiative/monochrom/master/chr-base.owl -O $@
mirror/neoplasm-core.owl:
wget --no-check-certificate $(OBO)/ncit/neoplasm-core.owl -O $@ && touch $@
mirror/ncit.owl:
wget --no-check-certificate $(OBO)/ncit.owl -O $@ && touch $@
mirror/cl.owl:
wget --no-check-certificate $(OBO)/cl/cl-base.owl -O $@ && touch $@
mirror/omo.owl:
wget --no-check-certificate $(OBO)/omo.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 $@
mirror/ncit-%-xrefs.ttl: mirror/ncit.owl
$(ROBOT) query -c ../sparql/construct/construct-$*-xrefs-from-ncit.sparql $@ -i $<
mirror/merge-ncit-xrefs.owl: mirror/ncit.owl mirror/ncit-icdo-xrefs.ttl mirror/ncit-umls-xrefs.ttl
owltools $^ --merge-support-ontologies -o $@
mirror/ncit-disease.obo: mirror/ncit-disease.owl
owltools $< -o -f obo $@
# $(ROBOT) convert -i $< -o $@
mirror/rdo.obo:
wget --no-check-certificate ftp://ftp.rgd.mcw.edu/pub/ontology/disease/RDO.obo -O $@ && touch $@
mirror/medgen-disease-extract.owl: mirror/medgen-disease-extract.obo
owltools $< -o [email protected] && perl -npe $(FIX_URI_EXPR) [email protected] > $@
mirror/dipper-%.ttl:
wget --no-check-certificate https://data.monarchinitiative.org/ttl/$*.ttl -O [email protected] && perl -npe 's@https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/HGNC:@http://identifiers.org/hgnc/@g' [email protected] > $@
mirror/dipper-%.obo: mirror/dipper-%.ttl
$(ROBOT) convert -i $< -o [email protected] && grep -v ^owl-axioms [email protected] > $@
mirror/hgnc.owl: mirror/dipper-hgnc.ttl
$(ROBOT) query -i $< --format ttl --query ../sparql/construct/construct-hgnc.sparql [email protected] &&\
$(ROBOT) annotate -i [email protected] --annotation http://purl.org/dc/elements/1.1/type http://purl.obolibrary.org/obo/IAO_8000001 \
--ontology-iri $(ONTBASE)/$@ --version-iri $(ONTBASE)/releases/$(TODAY)/$@ \
# $(ROBOT) query construct
# owltools $< --remove-axioms -t EquivalentClasses -o $@
# owltools $< --remove-dangling -o $@
# owltools $< --merge-equivalence-sets -s http://identifiers.org/hgnc/ 20 -o $@
mirror/omia.ttl:
wget --no-check-certificate http://data.monarchinitiative.org/ttl/omia.ttl -O $@ && touch $@
.PRECIOUS: mirror/omia.ttl
mirror/omia-1.owl: mirror/omia.ttl
owltools $< --set-ontology-id $(OBO)/mondo/$@ -o $@
.PRECIOUS: mirror/omia-1.owl
mirror/omia-2.obo: mirror/omia-1.owl
owltools $< -o -f obo [email protected] && grep -v ^owl-axioms [email protected] | grep -v ^property_value | perl -npe 's@xref: OMIM:@relationship: RO:HOM0000001 OMIM:@' | perl -npe 's@is_a: MESH:@relationship: RO:HOM0000001 MESH:@' | obo-grep.pl --neg -r 'id: http' - | ../utils/fix-omia-names.pl > [email protected] && $(ROBOT) reduce -i [email protected] -o $@
mirror/omia.owl: mirror/omia-2.obo imports/equivalencies.owl
owltools $^ --add-imports-from-supports --reasoner elk --merge-equivalence-sets -s MONDO 20 --remove-imports-declarations -o $@
mirror/omia.obo: mirror/omia.owl
owltools --use-catalog $< -o -f obo $@
mirror/efo-src.owl:
wget --no-check-certificate http://www.ebi.ac.uk/efo/efo.owl -O $@ && touch $@
mirror/efo.owl: mirror/efo-src.owl
owltools $< $(EFO2OBO_OPTS) -o [email protected] && perl -npe $(EFO2OBO_PERL) [email protected] > $@
mirror/efo.obo: mirror/efo.owl
owltools $< -o -f obo --no-check [email protected] && perl ../utils/fix-efo.pl [email protected] > $@
mirror/efo-disease.uris: mirror/efo.owl
$(ROBOT) query -i $< -s ../sparql/signature/efo-subclass-of-disease.sparql $@
# Make a disease subset; ensure axioms are relaxed
mirror/efo-disease.owl: mirror/efo.owl mirror/efo-disease.uris
$(ROBOT) extract -i $< -T mirror/efo-disease.uris --method BOT relax -o $@
mirror/efo-disease.obo: mirror/efo-disease.owl
owltools $< -o -f obo --no-check [email protected] && perl ../utils/fix-efo.pl [email protected] > $@
# ----------------------------------------
# Indirect inferences
# ----------------------------------------
imports/indirect.owl: mondo-edit.obo
$(ROBOT) reason -r elk -i $< query --format ttl -c ../sparql/construct/construct-indirect-subclass-of.sparql $@
imports/tag-indirect.owl: mondo-edit.obo
$(ROBOT) reason -r elk -i $< query --format ttl -c ../sparql/construct/construct-tag-indirect-subclass-of.sparql $@
# ----------------------------------------
# Rewritten ext axioms
# ----------------------------------------
compare_all: compare_all_nd compare_all_d
compare_all_nd: $(patsubst %, compare/axioms-%-nd.obo, $(XD))
compare_all_d: $(patsubst %, compare/axioms-%-d.obo, $(XD))
# Generates synonym from labels
compare/lsyns-%.owl: mirror/%.owl
$(ROBOT) query -i $< --format ttl -c ../sparql/construct/construct-related-synonym-from-label.sparql $@
.PRECIOUS: compare/lsyns-%.owl
# Merges in the syns generated as above step
compare/%-plus-lsyns.owl: mirror/%.owl compare/lsyns-%.owl
owltools $^ --merge-support-ontologies -o $@
.PRECIOUS: compare/%-plus-lsyns.owl
# logical merge, no duplicate axioms
compare/axioms-%-nd.owl: compare/%-plus-lsyns.owl mondo-edit.obo
owltools --use-catalog mondo-edit.obo --copy-axioms -l -m imports/equivalencies.owl -s $< -n --set-ontology-id $(OBO)/mondo/$@ -o $@
.PRECIOUS: compare/axioms-%.owl
# duplicate axioms, for provenance tagging
compare/axioms-%-d.owl: compare/%-plus-lsyns.owl mondo-edit.obo
owltools --use-catalog mondo-edit.obo --copy-axioms -I -D -m imports/equivalencies.owl -s $< -n --set-ontology-id $(OBO)/mondo/$@ -o $@
.PRECIOUS: compare/axioms-%.owl
# bring in strictly new literals in annotation axioms
compare/ann-axioms-%-new.owl: compare/%-plus-lsyns.owl mondo-edit.obo
owltools --use-catalog mondo-edit.obo --copy-axioms -x -m imports/equivalencies.owl -s $< -n --set-ontology-id $(OBO)/mondo/$@ -o $@
.PRECIOUS: compare/axioms-%.owl
compare/ann-axioms-ncit-disease-new.owl: mirror/ncit-disease.owl mondo-edit.obo
owltools --use-catalog mondo-edit.obo --copy-axioms -x -m imports/equivalencies.owl -s $< -n --set-ontology-id $(OBO)/mondo/$@ -o $@
.PRECIOUS: compare/axioms-%.owl
# all axioms
compare/axioms-%-all.owl: compare/%-plus-lsyns.owl mondo-edit.obo
owltools --use-catalog mondo-edit.obo --copy-axioms -d -m imports/equivalencies.owl -s $< -n --set-ontology-id $(OBO)/mondo/$@ -o $@
.PRECIOUS: compare/axioms-%.owl
# tag axioms that are asserted but could be inferred
compare/entailed.obo: mondo-edit.obo
owltools --use-catalog $< --remove-axiom-annotations --reasoner elk --silence-elk --tag-entailed-axioms --set-ontology-id $(OBO)/mondo/$@ -o -f obo [email protected] && perl -npe 's@{source="direct"}@{source="MONDO:Redundant"}@' [email protected] > $@
compare/entailed-isa.obo: compare/entailed.obo
obo-filter-tags.pl -t is_a -t id | obo-grep.pl -r is_a - | grep -v ^import > $@
obo-filter-tags.pl -t is_a -t id | $(OBOGREP) -r is_a - | grep -v ^import > $@
compare/unique-isa.tsv: compare/entailed-isa.owl
./mq -i $< report unique_isa > $@
compare/main.obo: mondo-edit.obo
owltools --use-catalog $< --remove-axiom-annotations --set-ontology-id $(OBO)/mondo/$@ -o -f obo [email protected] && perl -npe 's@{source="direct"}@{source="MONDO:Redundant"}@' [email protected] > $@
#compare/axioms-%.owl:
# owltools --use-catalog mondo-edit.obo --copy-axioms -l -d -m imports/equivalencies.owl -s mirror/$*.owl -n --set-ontology-id $(OBO)/mondo/$@ -o $@
#.PRECIOUS: compare/axioms-%.owl
compare/axioms-%.obo: compare/axioms-%.owl
owltools $< -o -f obo --no-check $@
compare/ann-axioms-%.obo: compare/ann-axioms-%.owl
owltools $< -o -f obo --no-check $@
# construct an OWL file that expresses the fact that every child term must be distinct from its superclas
# C1 SubClassOf P ==> exists C2 : C2 subClassOf P, C1 DisjointWith C2
disjoint_sibs.owl: $(SRC)
$(ROBOT) query --format ttl -c ../sparql/construct/construct-disjoint-siblings.sparql $@ -i $<
testcombo-%: mondo-edit.obo disjoint_sibs.owl imports/equivalencies.owl mirror/%.owl disjoint_sibs.owl
owltools --use-catalog $^ --merge-support-ontologies --run-reasoner -r elk -u -m compare/bad-$*.owl
debug.owl: mondo-edit.obo disjoint_sibs.owl imports/equivalencies.owl
owltools --no-logging --use-catalog $^ --merge-support-ontologies --run-reasoner -r elk -u -m $@ | grep -v ^INFERENCE
debug2.owl: mondo-edit.obo disjoint_sibs.owl imports/equivalencies.owl
owltools --use-catalog $^ --merge-support-ontologies --reasoner elk --merge-equivalence-sets -s MONDO 100 --run-reasoner -r elk -u -m $@ | grep -v ^INFERENCE
debug-prod.owl: mondo.owl disjoint_sibs.owl imports/equivalencies.owl
owltools --use-catalog $^ --merge-support-ontologies --run-reasoner -r elk -u -m $@ | grep -v ^INFERENCE
# ----------------------------------------
# Lexical mapping
# ----------------------------------------
# align against self (*not* external ontologies)
mappings.tsv: mondo.json
ontobio-lexmap.py $< > [email protected] && mv [email protected] $@ && perl -pi -ne 's@http://purl.obolibrary.org/obo/MONDO_@MONDO:@g' $@
%-mappings.tsv: mondo.json mirror/%.json
ontobio-lexmap.py $^ -u unmapped-$@ > [email protected] && mv [email protected] $@
hp-mappings.tsv: mondo.json
ontobio-lexmap.py hp $< > [email protected] && mv [email protected] $@
mesh-mappings.tsv: mondo.json mesh.json
ontobio-lexmap.py $^ > [email protected] && mv [email protected] $@
gard-mappings.tsv: mondo-edit.json gard.json
ontobio-lexmap.py $^ -u unmapped-$@ > [email protected] && mv [email protected] $@
medgen-mappings.tsv: mondo-edit.json mirror/medgen-disease-extract.obo
ontobio-lexmap.py -v -e $^ -u unmapped-$@ > [email protected] && mv [email protected] $@
neoplasm-mappings.tsv: mondo-edit.json neoplasm-core.json
ontobio-lexmap.py -v -e $^ -u unmapped-$@ > [email protected] && mv [email protected] $@
ncit-mappings.tsv: mondo-edit.json mirror/ncit-disease.json
ontobio-lexmap.py -v -e $^ -u unmapped-$@ > [email protected] && mv [email protected] $@
ptable-%.tsv: %-mappings.tsv
cat $< | p.df 'df[df.right_novel==True]' 'df[["left", "right","pr_subClassOf","pr_superClassOf","pr_equivalentTo","pr_other"]]' -o csv -i tsv | grep -v '^"left' | grep MONDO > [email protected] && csv2tsv.py [email protected] $@
%-mappings-best.tsv: %-mappings.tsv
cat $< | p.df 'df[["left", "left_label", "right", "right_label", "reciprocal_score"]]' -o csv -i tsv | grep -v '^"left' | grep MONDO > [email protected] && mv [email protected] $@
%-mappings-filtered.tsv: %-mappings.tsv
cat $< | p.df 'df[df.reciprocal_score==4]' 'df[df.left_match_type=="label"]' 'df[df.right_match_type=="label"]' 'df[["left", "left_label", "right", "right_label"]]' -i tsv -o tsv > [email protected] && mv [email protected] $@
unlikely.md: linked-rpt.md
./unlikely-axiom-report.pl $< | head -200 > $@
modules/equiv-xrefs.obo: mondo-edit.obo
obo-filter-tags.pl -t id -t xref $< | egrep '^($$|\[Term|id:|xref:.*equivalentTo)' > $@
mim2gene_medgen:
wget ftp://ftp.ncbi.nih.gov/gene/DATA/mim2gene_medgen && touch $@
# g2g
mim2gene.txt:
curl -L -s https://omim.org/static/omim/data/mim2gene.txt > [email protected] && mv [email protected] $@
diseases_to_genes.txt:
curl -L -s http://compbio.charite.de/jenkins/job/hpo.annotations.monthly/lastSuccessfulBuild/artifact/annotation/diseases_to_genes.txt > [email protected] && mv [email protected] $@
omim2medgen.obo: mim2gene_medgen
grep phenotype $< | cut -f1,5 | perl -npe 's@^@OMIM:@;s@\t@\tUMLS:@' | grep UMLS:C | tbl2obolinks.pl --rel xref --source NCBI:mim2gene_medline - > $@
reports/mondo-equivs.tsv:
$(ROBOT) query -i mondo.owl -q ../sparql/reports/sssom-mappings.sparql [email protected] && ../utils/tidy-sparql-output.pl [email protected] > $@
# NEW: uses rdf_matcher
# **IMPORTANT*: remember to clear tmp/ dir for fresh start
# mondo_queries requires for prefixes
all_unique.tsv:
rdfmatch -p MONDO -f sssom ../plq/mondo_queries.pro -X tmp -A void.ttl -f tsv -v -i all -i skos.ttl unique_match > $@
all_matches.tsv:
rdfmatch -T --debug rdf_matcher -i prefixes.ttl -p MONDO -f sssom -X tmp -A void.ttl -w obo_weights -v -i all2 match > $@
matches-to-%.tsv:
rdfmatch --debug rdf_matcher -i prefixes.ttl -p MONDO -X tmp -A void.ttl -v -i mondo -i $* match > $@
matches-to-nando.tsv:
rdfmatch -g remove_non_english_literals --debug rdf_matcher -i prefixes.ttl -p NANDO --match_prefix MONDO -X tmp -A void.ttl -v -i mondo -i nando match > $@
lexrules-%.pro:
test -d tmp-$* || mkdir -p tmp-$*
rdfmatch --ontA MONDO --ontB $(shell echo $* | tr a-z A-Z) -l -c ../plq/mondo_queries.pro -X tmp-$* -A void.ttl -f tsv -v -i mondo_edit -i equivs -i mirror/$*.owl -i skos.ttl learn > $@
.PRECIOUS: lexrules-%.pro
match-dedupe-%.tsv: match-%.tsv
sssom dedupe -i $< -o $@
match-%.tsv:
rdfmatch -p MONDO -l -c ../plq/mondo_queries.pro -X tmp -A void.ttl -f sssom -w obo_weights -v -i mondo_edit -i equivs -i mirror/$*.owl -i skos.ttl new_match $< > $@
learnedmatch-%.tsv: lexrules-%.pro
rdfmatch -p MONDO -l -c ../plq/mondo_queries.pro -X tmp-$* -A void.ttl -f tsv -v -i mondo_edit -i equivs -i mirror/$*.owl -i skos.ttl classify $< > $@
all_unique_fresh: clean_tmp all_unique.tsv
clean_tmp:
rm tmp/*
# ----------------------------------------
# Metaclasses
# ----------------------------------------
disorder-by-%.tsv: mondo-edit.obo
blip-findall -r uberonp -r cell -r go -i $< "class_cdef(C,cdef('MONDO:0000001',[disease_has_location=A])),subclassRT(A,'$(subst _,:,$*)')" -select C-A -no_pred -use_tabs -label > [email protected] && sort -u [email protected] > $@
disorder-by-anatomical-region.tsv: disorder-by-UBERON_0000475.tsv
cp $< $@
disorder-by-anatomical-system.tsv: disorder-by-UBERON_0000467.tsv
cp $< $@
disorder-by-cell.tsv: disorder-by-CL_0000000.tsv
cp $< $@
# ----------------------------------------
# Anns
# ----------------------------------------
phenotype_annotation.tab:
wget http://compbio.charite.de/jenkins/job/hpo.annotations/lastStableBuild/artifact/misc/phenotype_annotation.tab -O $@ && touch $@
phenotype_annotation_nu.tab:
wget http://compbio.charite.de/jenkins/job/hpo.annotations.2018/lastSuccessfulBuild/artifact/misc_2018/phenotype.hpoa -O $@ && touch $@
g2p.tsv:
wget http://compbio.charite.de/jenkins/job/hpo.annotations.monthly/lastStableBuild/artifact/annotation/ALL_SOURCES_ALL_FREQUENCIES_genes_to_phenotype.txt -O $@ && touch $@
d2p.tsv: phenotype_annotation.tab
../utils/phenotab2tbl.pl $< > $@
# ----------------------------------------
# Hacky
# ----------------------------------------
mondox.obo: mondo-edit.obo
perl -npe 's@source="MONDO:(equivalentto|subclassof|superclassof|other|relatedto)@semantics="MONDO:$$1@i' $< > $@
check: mondo-edit.obo
$(HOME)/repos/go-ontology/src/util/check-obo-for-standard-release.pl --disable-xrf-abbs-check $<
%-quickcheck: %.obo
../utils/quick-check.pl $<
mondo-edit.owl: mondo-edit.obo
../utils/quick-check.pl $< && $(ROBOT) convert -i $< -o $@
d2taxon-wd.tsv:
pq-wd -f tsv "has_cause(D,T),doid_id(D,DX),ncbitaxon_id(T,TX)" "x(DX,TX)" > [email protected] && perl -npe 's@\t@\tNCBITaxon:@' [email protected] > $@
d2symp-wd.tsv:
pq-wd -f tsv "symptoms(D,S),doid_id(D,DX),umls_id(S,SX),enlabel(S,SN)" "x(DX,SX,SN)" > [email protected] && perl -npe 's@\tC@\tUMLS:C@' [email protected] > $@
# ----------------------------------------
# Kboom
# ----------------------------------------
# new
weights.tsv:
pl2sparql -f tsv -e -i mondo-edit.owl -c ../plq/kboom_weights.pro w > $@
weights-mg.tsv:
pl2sparql -f tsv -e -i mondo-edit.owl -i mirror/medgen-disease-extract.owl -c ../plq/kboom_weights.pro w > $@
ptable.tsv: weights.tsv
../utils/softmax-weights.py $< > $@
#ptable.tsv: mondo-edit.obo
# ../utils/xrefs2ptable.pl $< > [email protected] && mv [email protected] $@
seed.owl: mondo-edit.obo ext.obo
owltools --use-catalog $^ --remove-imports-declarations --merge-support-ontologies -o $@