-
Notifications
You must be signed in to change notification settings - Fork 54
/
mondo.Makefile
1390 lines (1060 loc) · 59.7 KB
/
mondo.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
ALL_PATTERNS=$(patsubst ../patterns/dosdp-patterns/%.yaml,%,$(wildcard ../patterns/dosdp-patterns/[a-z]*.yaml))
DOSDPT=dosdp-tools
TEMPLATES_DIR=../templates
MONDO_STATS_SPARQLDIR = ../sparql/mondo_stats
MONDO_STATS_REPORTS_DIR = reports/mondo_stats
.PHONY: dirs python-install-dependencies update-exclusion-reasons
dirs:
mkdir -p tmp/
mkdir -p components/
mkdir -p mirror/
mkdir -p reports/
.PHONY: matches
tmp/mondo-edit-merged.owl: $(SRC)
$(ROBOT) merge -i $< -o $@
matches: tmp/mondo-edit-merged.owl
$(DOSDPT) query --ontology=$< --catalog=catalog-v001.xml --reasoner=elk --obo-prefixes=true --batch-patterns="$(ALL_PATTERNS)" --template="../patterns/dosdp-patterns" --outfile="../patterns/data/matches/"
matches_annotations: tmp/mondo-edit-merged.owl
$(DOSDPT) query --ontology=$< --catalog=catalog-v001.xml --reasoner=elk --restrict-axioms-to=annotation --obo-prefixes=true --batch-patterns="$(ALL_PATTERNS)" --template="../patterns/dosdp-patterns" --outfile="../patterns/data/matches_annotations/"
pattern_schema_checks:
simple_pattern_tester.py ../patterns/dosdp-patterns/
owlaxioms_check:
! grep "^owl-axioms" mondo-edit.obo
obo_validator:
fastobo-validator mondo-edit.obo
test: pattern_schema_checks
test: owlaxioms_check
test: test_reason_equivalence
test: test_reason_equivalence_hermit
test: obo_validator
test_reason_equivalence_hermit: $(ONT)-base.obo
$(ROBOT) reason -i $< --equivalent-classes-allowed none -r hermit
test_reason_equivalence: $(SRC)
$(ROBOT) merge -i $< \
remove --term FOODON:03315150 --term FOODON:00001257 --term ENVO:01001479 --term ENVO:01001784 --axioms logical \
reason -e none
../patterns/dosdp-pattern.owl: pattern_schema_checks
$(DOSDPT) prototype --obo-prefixes=true --template=../patterns/dosdp-patterns --outfile=$@
../patterns/pattern-merged.owl: ../patterns/dosdp-pattern.owl
$(ROBOT) merge -i ../patterns/dosdp-pattern.owl annotate -V $(ONTBASE)/releases/`date +%Y-%m-%d`/$(ONT)-pattern.owl annotate --ontology-iri $(ONTBASE)/$(ONT)-pattern.owl -o $@
../patterns/imports/seed.txt: ../patterns/dosdp-pattern.owl
$(ROBOT) query -f csv -i $< --query ../sparql/terms.sparql $@
../patterns/imports/seed_sorted.txt: ../patterns/imports/seed.txt
cat ../patterns/imports/seed.txt | sort | uniq > $@
PATTERN_IMPORTS = ro
PATTERN_IMPORTS_OWL = $(patsubst %, ../patterns/imports/%_import.owl, $(PATTERN_IMPORTS))
../patterns/imports/%_import.owl: mirror/%.owl ../patterns/imports/seed_sorted.txt
$(ROBOT) extract -i $< -T ../patterns/imports/seed_sorted.txt --force true --method BOT -O mirror/$*.owl annotate --ontology-iri $(OBO)/$(ONT)/patterns/imports/$*_import.owl -o $@
../patterns/pattern-with-imports.owl: ../patterns/pattern-merged.owl $(PATTERN_IMPORTS_OWL)
$(ROBOT) merge $(addprefix -i , $^) unmerge -i ../patterns/components/pattern-ontology-remove-axioms.owl -o $@
../patterns/pattern.owl: ../patterns/pattern-with-imports.owl
$(ROBOT) merge -i ../patterns/pattern-with-imports.owl remove --term http://www.w3.org/2002/07/owl#Nothing reason -r Hermit reduce -r Hermit annotate --ontology-iri $(OBO)/$(ONT)/patterns/pattern.owl -o $@
pattern_ontology: ../patterns/pattern.owl
$(ROBOT) merge -i ../patterns/pattern.owl \
filter --select "<http://purl.obolibrary.org/obo/mondo/patterns*>" --select "self annotations" --signature true --trim true -o ../patterns/pattern-simple.owl
../patterns/dosdp-patterns/README.md: .FORCE
pip install tabulate
python ../scripts/patterns_create_overview.py "../patterns/dosdp-patterns" "../patterns/data/matches" $@
pattern_readmes: ../patterns/dosdp-patterns/README.md
MYDIR = .
list: $(MYDIR)/*
../../docs/editors-guide/quality-control-tests.md:
echo "# Custom SPARQL checks Mondo" > $@ &&\
echo "" >> $@ &&\
echo "## Mondo specific checks" >> $@ &&\
echo "" >> $@ &&\
for file in $(SPARQLDIR)/qc/mondo/*.sparql ; do \
echo "### " $$(basename $${file}) >> $@ ; \
echo "" >> $@ ; \
echo "\`\`\`" >> $@ ; \
cat $${file} >> $@ ; \
echo "" >> $@ ;\
echo "\`\`\`" >> $@ ; \
echo "" >> $@ ;\
done &&\
echo "## General quality checks" >> $@ &&\
echo "" >> $@ &&\
for file in $(SPARQLDIR)/qc/general/*.sparql ; do \
echo "### " $$(basename $${file}) >> $@ ; \
echo "" >> $@ ; \
echo "\`\`\`" >> $@ ; \
cat $${file} >> $@ ; \
echo "" >> $@ ;\
echo "\`\`\`" >> $@ ; \
echo "" >> $@ ;\
done
.PHONY: qc_docs
qc_docs: ../../docs/editors-guide/quality-control-tests.md
pattern_mkdocs:
pip install tabulate
python ../scripts/patterns_create_docs.py
.PHONY: pattern_docs
pattern_docs: pattern_ontology pattern_readmes pattern_mkdocs qc_docs
#################################
##### REPORTING PIPELINE ########
SPARQL_STATS=$(patsubst %.sparql, %, $(notdir $(wildcard $(SPARQLDIR)/reports/*-stats.sparql)))
SPARQL_TAGS=$(patsubst %.sparql, %, $(notdir $(wildcard $(SPARQLDIR)/tags/*-tags.sparql)))
tmp/mondo-version_edit.owl: $(SRC)
$(ROBOT) merge -i $< -o $@
tmp/mondo-version_mondo-owl.owl: mondo.owl
$(ROBOT) merge -i $< -o $@
tmp/mondo-version_current.owl:
$(ROBOT) merge -I $(OBO)/mondo.owl -o $@
tmp/mondo-version_2019.owl:
$(ROBOT) merge -I http://purl.obolibrary.org/obo/mondo/releases/2019-04-29/mondo.owl -o $@
tmp/mondo-version_2020.owl:
$(ROBOT) merge -I http://purl.obolibrary.org/obo/mondo/releases/2020-01-27/mondo.owl -o $@
tmp/mondo-version_2018.owl:
wget "https://osf.io/bqpjm/download?version=5&displayName=mondo-2018-01-06T03%3A29%3A32.300263%2B00%3A00.owl" -O $@
$(ROBOT) merge -i $@ -o [email protected] && mv [email protected] $@
tmp/mondo-version_2017.owl:
wget "https://osf.io/bqpjm/download?version=1&displayName=mondo-2017-10-19T06%3A08%3A40.163682%2B00%3A00.owl" -O $@
$(ROBOT) merge -i $@ -o [email protected] && mv [email protected] $@
# This combines all into one single command
.PHONY: all_reports_sparqlqc_%
all_reports_sparqlqc_%: tmp/mondo-version_%.owl
$(ROBOT) query -f tsv --use-graphs true -i $< $(foreach V,$(SPARQL_MONDO_QC),-s $(SPARQLDIR)/qc/mondo/$V.sparql reports/mondo-qc-$*-$V.tsv)
.PHONY: all_reports_stats_%
all_reports_stats_%: tmp/mondo-version_%.owl
$(ROBOT) query -f tsv --use-graphs true -i $< $(foreach V,$(SPARQL_STATS),-s $(SPARQLDIR)/reports/$V.sparql reports/mondo-qc-$*-$V.tsv)
reports/mondo-qc-%-robot-report-obo.tsv: tmp/mondo-version_%.owl
$(ROBOT) report -i $< --fail-on none --print 5 -o $@
.PRECIOUS: reports/mondo-qc-%-robot-report-obo.tsv
QC_BASE_FILES=edit mondo-owl current 2017 2018 2019 2020
QC_REPORTS=$(foreach V,$(QC_BASE_FILES), qc_reports_$V)
QC_REPORTS_RM=$(foreach V,$(QC_BASE_FILES), reports/$V*)
clean_qc:
rm report/mondo-qc-*
qc_reports_%: all_reports_stats_% reports/mondo-qc-%-robot-report-obo.tsv all_reports_sparqlqc_%
echo $^
travis_test: mondo.owl sparql_test_main_obo
$(ROBOT) report -i mondo.owl --fail-on none --print 5 -o reports/obo-report.tsv
run_notebook:
# https://github.com/jupyter/notebook/issues/2254
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.token='' --NotebookApp.password=''
reports/mondo_analysis.md: $(QC_REPORTS)
jupyter nbconvert --execute --to markdown --TemplateExporter.exclude_input=True reports/mondo_analysis.ipynb
#sed -i 's/<style.*<[/]style>//g' $@
# This is a hack to get rid of <style> tags that are rendered very ugly by github.
perl -0777 -i.original -pe 's#<style[^<]*<\/style>##igs' $@
reports/mondo_analysis.pdf: $(QC_REPORTS)
jupyter nbconvert --execute --to pdf --TemplateExporter.exclude_input=True reports/mondo_analysis.ipynb
##############################################################
###### Pipeline for adding a compoment with tagging ##########
# For example: DOSDP conformance
MATCHED_TSVs=$(foreach V,$(notdir $(wildcard ../patterns/data/matches/*.tsv)),../patterns/data/matches/$V)
tmp/mondo-tags-dosdp.tsv: | dirs
python ../scripts/dosdp-matches-tags.py $(addprefix -d , $(MATCHED_TSVs)) -o $@
tmp/mondo-tags-dosdp.owl: tmp/mondo-tags-dosdp.tsv | dirs
$(ROBOT) merge -i $(SRC) template --template $< --prefix "MONDO: http://purl.obolibrary.org/obo/MONDO_" --output $@
tmp/mondo-tags-sparql.ttl: $(SRC) | dirs
$(ROBOT) reason -i $< query -f ttl --queries $(foreach V,$(SPARQL_TAGS),$(SPARQLDIR)/tags/$V.sparql) --output-dir tmp/
$(ROBOT) merge $(addprefix -i , $(foreach V,$(SPARQL_TAGS),tmp/$V.ttl)) -o $@
components/mondo-tags.owl: tmp/mondo-tags-dosdp.owl tmp/mondo-tags-sparql.ttl | dirs
$(ROBOT) merge $(addprefix -i , $^) annotate --ontology-iri $(ONTBASE)/$@ -o $@
clean:
rm -rf mondo-base.* mondo.json mondo.obo mondo.owl mondo-qc.* \
mondo_current_release* all_reports_1 filtered.* mondo-with-equivalents.* \
*.tmp *.tmp.obo merged.owl *merged.owl reasoned.obo skos.ttl \
debug.owl roundtrip.obo test_nomerge sparql_test_* disjoint_sibs.obo \
reasoned-plus-equivalents.owl reasoned.owl tmp/*
reports/new-rare-diseases.txt: $(ONT)-base.owl
$(ROBOT) query -i $(ONT)-base.owl --query ../sparql/signature/rare-subset.sparql $@
reports/old-rare-diseases.txt: tmp/mondo-lastbase.owl
$(ROBOT) query -i tmp/mondo-lastbase.owl --query ../sparql/signature/rare-subset.sparql $@
reports/%-rare-diseases.tsv: $(ONT)-base.owl reports/%-rare-diseases.txt
$(ROBOT) filter --input $(ONT)-base.owl -T reports/$*-rare-diseases.txt --select "annotations self" \
export --header "ID|LABEL|SYNONYMS" \
--format tsv --export $@
rare-disease-reports: reports/old-rare-diseases.tsv reports/new-rare-diseases.tsv
python ../scripts/filter_rare_disease_list.py reports/old-rare-diseases.tsv reports/new-rare-diseases.tsv reports/added-rare-disases.tsv reports/removed-rare-diseases.tsv
#########################################
######### Create Mondo Stats ############
#########################################
# Create overview Mondo stats as needed for presentations. This includes: count of disease classes, terms w/definitions, xrefs,
# exact, related, narrow, and broad synonyms, and count of rare disease, cancer, infectious, and hereditary disease classes.
# Get the current date including the timezone
current_date := $(shell date)
# Create the directory if it does not already exist
$(MONDO_STATS_REPORTS_DIR):
mkdir -p $@
# Create the Mondo Stats Summary file
.PHONY: create-mondo-stats-summary-file
create-mondo-stats-summary-file: reasoned.owl | $(MONDO_STATS_REPORTS_DIR)
$(ROBOT) query --input reasoned.owl \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-classes.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_01_class_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-classes-with-definitions.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_03_classDefinition_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-xrefs.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_02_xref_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-exact-synonyms.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_04_exactSynonym_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-related-synonyms.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_05_relatedSynonym_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-narrow-synonyms.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_06_narrowSynonym_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-broad-synonyms.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_07_broadSynonym_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-rare-diseases-classes.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_08_rareDiseaseClass_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-infectious-diseases.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_09_infectiousDiseaseClass_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-cancer-diseases.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_10_cancerDiseaseClass_count.tsv \
--query $(MONDO_STATS_SPARQLDIR)/COUNT-hereditary-diseases.sparql $(MONDO_STATS_REPORTS_DIR)/tmp_11_hereditaryDiseaseClass_count.tsv
echo "All Mondo Stats created on: $(current_date)" > $(MONDO_STATS_REPORTS_DIR)/all_mondo_stats.txt
cat $(MONDO_STATS_REPORTS_DIR)/tmp_* >> $(MONDO_STATS_REPORTS_DIR)/all_mondo_stats.txt
rm $(MONDO_STATS_REPORTS_DIR)/tmp_*
# Create general Mondo Stats
.PHONY: create-mondo-stats
create-mondo-stats:
$(MAKE) create-mondo-stats-summary-file -B
#############################################
##### One-time scripts ######################
#############################################
# MedGen conflicts (Aug 2023) pipeline
# - https://github.com/monarch-initiative/mondo-ingest/issues/273
.PHONY: address-medgen-conflicts-aug2023
address-medgen-conflicts-aug202x3: address-medgen-conflicts-aug2023-deletes address-medgen-conflicts-aug2023-adds
# - MedGen conflicts: dependencies
tmp/July2023_CUIReports_FromMedGentoMondo.xlsx:
mkdir -p tmp && wget "https://github.com/monarch-initiative/mondo-ingest/files/12029712/July2023_CUIReports_FromMedGentoMondo.xlsx" -O $@
# - MedGen conflicts: analysis
tmp/mondo-edit.obo.tmp.diff: mondo-edit.obo.tmp
-diff mondo-edit.obo mondo-edit.obo.tmp > $@
tmp/report-qc-medgen-conflicts-update-diff.tsv: tmp/mondo-edit.obo.tmp.diff
python ../scripts/medgen_conflicts_removals_diff_analysis.py -i tmp/mondo-edit.obo.tmp.diff -o $@
tmp/report-qc-medgen-conflicts-adds-diff.tsv: $(TEMPLATES_DIR)/ROBOT_addMedGen_fromConflictResolution.tsv $(TEMPLATES_DIR)/ROBOT_addMedGen_fromIngest.tsv
python ../scripts/medgen_conflicts_add_xrefs_diff_analysis.py -c $(TEMPLATES_DIR)/ROBOT_addMedGen_fromConflictResolution.tsv -i $(TEMPLATES_DIR)/ROBOT_addMedGen_fromIngest.tsv -o $@
# - MedGen conflicts: deletes
.PHONY: address-medgen-conflicts-aug2023-deletes
address-medgen-conflicts-aug2023-deletes: mondo-edit.obo.tmp
mv mondo-edit.obo.tmp mondo-edit.obo
mondo-edit.obo.tmp: tmp/July2023_CUIReports_FromMedGentoMondo.xlsx mondo-edit.obo
python ../scripts/medgen_conflicts_removals.py -i tmp/July2023_CUIReports_FromMedGentoMondo.xlsx -I mondo-edit.obo -o $@
# - MedGen conflicts: adds
.PHONY: address-medgen-conflicts-aug2023-adds
address-medgen-conflicts-aug2023-adds: tmp/report-qc-medgen-conflicts-adds-diff.tsv
$(TEMPLATES_DIR)/ROBOT_addMedGen_fromConflictResolution.tsv: tmp/July2023_CUIReports_FromMedGentoMondo.xlsx
python ../scripts/medgen_conflicts_add_xrefs.py -i tmp/July2023_CUIReports_FromMedGentoMondo.xlsx -o $@
$(TEMPLATES_DIR)/ROBOT_addMedGen_fromIngest.tsv:
wget "https://github.com/monarch-initiative/medgen/releases/latest/download/medgen-xrefs.robot.template.tsv" -O $@
######################################################
##### Mondo Ingest Update Pipelines ##################
######################################################
# 1. Rare disease pipeline
# 2. Externally managed content pipeline
MONDO_INGEST_EXTERNAL_LOCATION=https://raw.githubusercontent.com/monarch-initiative/mondo-ingest/main/src/ontology/external
DOWNLOAD_EXTERNAL=true
# All the content for this pipeline is pulled from the mondo-ingest repo
tmp/external/processed-%.robot.owl:
mkdir -p tmp/external
if [ $(DOWNLOAD_EXTERNAL) = true ]; then wget "$(MONDO_INGEST_EXTERNAL_LOCATION)/processed-$*.robot.owl" -O $@; fi
# This is the main pipeline to update all rare disease subsets
update-rare-disease-subset:
$(MAKE) subset-metrics -B && cp $(TMPDIR)/subset-metrics.tsv $(TMPDIR)/subset-metrics-before.tsv
$(MAKE) update-orphanet-rare -B
$(MAKE) update-gard -B
$(MAKE) update-nord -B
$(MAKE) update-inferred-subset -B
$(MAKE) update-rare-subset -B
$(MAKE) subset-metrics -B && cp $(TMPDIR)/subset-metrics.tsv $(TMPDIR)/subset-metrics-after.tsv
@echo "Subset metrics before..."
cat $(TMPDIR)/subset-metrics-before.tsv
@echo "Subset metrics after..."
cat $(TMPDIR)/subset-metrics-after.tsv
# This is the main pipeline to update all externally managed content(EMC)
update-external-content:
$(MAKE) subset-metrics -B && cp $(TMPDIR)/subset-metrics.tsv $(TMPDIR)/subset-metrics-before.tsv
$(MAKE) update-efo-subset -B
$(MAKE) update-clingen -B
$(MAKE) update-ordo-subsets -B
$(MAKE) update-nando -B
$(MAKE) update-medgen -B
$(MAKE) subset-metrics -B && cp $(TMPDIR)/subset-metrics.tsv $(TMPDIR)/subset-metrics-after.tsv
@echo "Subset metrics before..."
cat $(TMPDIR)/subset-metrics-before.tsv
@echo "Subset metrics after..."
cat $(TMPDIR)/subset-metrics-after.tsv
# This is the main pipeline to update both externally managed content and rare disease subsets
update-external-content-incl-rare:
$(MAKE) subset-metrics -B && cp $(TMPDIR)/subset-metrics.tsv $(TMPDIR)/subset-metrics-before.tsv
$(MAKE) update-efo-subset -B
$(MAKE) update-clingen -B
$(MAKE) update-ordo-subsets -B
$(MAKE) update-nando -B
$(MAKE) update-medgen -B
$(MAKE) update-orphanet-rare -B
$(MAKE) update-gard -B
$(MAKE) update-nord -B
$(MAKE) update-inferred-subset -B
$(MAKE) update-rare-subset -B
$(MAKE) subset-metrics -B && cp $(TMPDIR)/subset-metrics.tsv $(TMPDIR)/subset-metrics-after.tsv
@echo "Subset metrics before..."
cat $(TMPDIR)/subset-metrics-before.tsv
@echo "Subset metrics after..."
cat $(TMPDIR)/subset-metrics-after.tsv
######################################################
##### Mondo Rare Disease Pipeline ####################
######################################################
##### Orphanet Rare ################
$(TMPDIR)/orphanet-rare-subset.owl: $(SRC)
$(ROBOT) merge -i $(SRC) reason \
query --format ttl --query ../sparql/construct/construct-orphanet-rare-subset.sparql $@
.PHONY: update-orphanet-rare
update-orphanet-rare:
$(MAKE) $(TMPDIR)/orphanet-rare-subset.owl
grep -vE '^(subset: orphanet_rare)' $(SRC) > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp mondo-edit.obo
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/orphanet-rare-subset.owl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
##### GARD #########################
# The complex part here is that we need to dynamically update the MONDO source code, i.e.
# MONDO:equivalentTo and MONDO:obsoleteEquivalentTo.
.PHONY: update-gard
update-gard:
$(MAKE) $(TMPDIR)/external/processed-gard.robot.owl
grep -vE '^(xref: GARD:|subset: gard_rare)' $(SRC) > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp mondo-edit.obo
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/external/processed-gard.robot.owl --collapse-import-closure false \
query --update ../sparql/update/insert-gard-obsoletion-status.ru \
convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC) && make deprecated_annotation_merging && make NORM && mv NORM $(SRC)
##### NORD #########################
.PHONY: update-nord
update-nord:
make $(TMPDIR)/external/processed-nord.robot.owl -B
grep -vE '^(xref: NORD:|subset: nord_rare)' $(SRC) > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp mondo-edit.obo
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/external/processed-nord.robot.owl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
##### Inferred #####################
# The inferred subset depends on the other ones, so we need to first remove the old subsets
# Then add the gard, nord and orphanet subsets back in
$(TMPDIR)/inferred-rare-subset.owl: $(SRC)
$(ROBOT) merge -i $(SRC) \
reason \
query --format ttl --query ../sparql/construct/construct-inferred-rare-subset.sparql $@
update-inferred-subset:
$(MAKE) $(TMPDIR)/inferred-rare-subset.owl
grep -vE '^(subset: inferred_rare)' $(SRC) > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp mondo-edit.obo
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/inferred-rare-subset.owl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
##### RARE #########################
tmp/rare-subset.owl: $(SRC)
$(ROBOT) merge -i $(SRC) \
query --format ttl --query ../sparql/construct/construct-rare-subset.sparql $@
.PHONY: update-rare-subset
update-rare-subset:
$(MAKE) $(TMPDIR)/rare-subset.owl
grep -vE '^(subset: rare)$$' $(SRC) > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp mondo-edit.obo
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/rare-subset.owl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
######################################################
##### Mondo Externally Managed Content Pipeline ######
######################################################
####################################
##### OMIM #####################
####################################
$(TMPDIR)/mondo-genes-axioms.owl: $(SRC)
$(ROBOT) filter --input $(SRC) \
--term RO:0004003 \
--axioms SubClassOf \
--preserve-structure false \
--trim false \
--drop-axiom-annotations "oboInOwl:source=~'(OMIM):.*'" \
-o $@
.PHONY: update-omim-genes
update-omim-genes:
$(MAKE) $(TMPDIR)/external/processed-mondo-omim-genes.robot.owl $(TMPDIR)/mondo-genes-axioms.owl -B
# We need to be less aggressive here, as some gene relations were not originally sourced
# from OMIM, and were added, for example, for ClinGen.
$(ROBOT) remove -i $(SRC) --term RO:0004003 --axioms SubClassOf --preserve-structure false --trim true \
merge -i $(TMPDIR)/external/processed-mondo-omim-genes.robot.owl -i $(TMPDIR)/mondo-genes-axioms.owl --collapse-import-closure false \
query --update ../sparql/update/omim-gene-equivalence.ru \
convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
####################################
##### Orphanet #####################
####################################
.PHONY: update-ordo-subsets
update-ordo-subsets:
$(MAKE) $(TMPDIR)/external/processed-ordo-subsets.robot.owl -B
grep -vE '^(subset: ordo_group_of_disorders)' $(SRC) | grep -vE '^(subset: ordo_disorder)' | grep -vE '^(subset: ordo_subtype_of_a_disorder)' > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp $(SRC)
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/external/processed-ordo-subsets.robot.owl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
####################################
##### NANDO #########################
####################################
.PHONY: update-nando
update-nando:
$(MAKE) $(TMPDIR)/external/processed-nando-mappings.robot.owl -B
grep -vE '^(xref: NANDO:)' $(SRC) > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp $(SRC)
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/external/processed-nando-mappings.robot.owl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
####################################
##### CLINGEN ######################
####################################
.PHONY: update-clingen
update-clingen:
$(MAKE) $(TMPDIR)/external/processed-mondo-clingen.robot.owl
grep -vE '^(relationship: curated_content_resource https://search.clinicalgenome.org|subset: clingen)' $(SRC) > $(TMPDIR)/mondo-edit.tmp
#CAREFUL, this needs to be uncommented when we just to include CLINGEN LABELs
#sed -i 's/EXACT CLINGEN_LABEL/EXACT/g' $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp $(SRC)
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/external/processed-mondo-clingen.robot.owl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
####################################
##### EFO ##########################
####################################
.PHONY: update-efo-subset
update-efo-subset:
$(MAKE) $(TMPDIR)/external/processed-mondo-otar-subset.robot.owl $(TMPDIR)/external/processed-mondo-efo.robot.owl
grep -vE '^(xref: EFO:|subset: otar)' $(SRC) > tmp/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp mondo-edit.obo
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/external/processed-mondo-otar-subset.robot.owl -i $(TMPDIR)/external/processed-mondo-efo.robot.owl --collapse-import-closure false \
query --use-graphs false --update ../sparql/update/update-equivalent-obsolete.ru \
convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
####################################
##### MedGen #######################
####################################
.PHONY: update-medgen
update-medgen:
$(MAKE) $(TMPDIR)/external/processed-mondo-medgen.robot.owl
grep -vE '^(xref: UMLS:|xref: MEDGEN:|subset: medgen)' $(SRC) > $(TMPDIR)/mondo-edit.tmp || true
mv $(TMPDIR)/mondo-edit.tmp mondo-edit.obo
$(ROBOT) merge -i $(SRC) -i $(TMPDIR)/external/processed-mondo-medgen.robot.owl --collapse-import-closure false \
query --use-graphs false --update ../sparql/update/update-equivalent-obsolete.ru \
convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC) && make NORM && mv NORM $(SRC)
.PHONY: subset-metrics
subset-metrics:
$(ROBOT) query -f tsv -i $(SRC) --query $(SPARQLDIR)/reports/count-subsets.sparql $(TMPDIR)/[email protected]
#############################################
##### Mondo analysis ########################
#############################################
# Makefile for mondo analysis
#all: sources
## SOURCES
## TODO: NOTE THE MONDO SOURCE BUNDLED HERE IS THE LATEST RELEASE, (i.e. does not trigger a release run)
## THIS is to enable fair comparison with the other sources and issues with syncronisation
SOURCE_VERSION = $(TODAY)
# snomed
SOURCE_IDS = doid ncit ordo omim gard
SOURCE_IDS_INCL_MONDO = $(SOURCE_IDS) mondo equivalencies
ALL_SOURCES_JSON = $(patsubst %, sources/$(SOURCE_VERSION)/%.json, $(SOURCE_IDS_INCL_MONDO))
ALL_SOURCES_JSON_GZ = $(patsubst %, sources/$(SOURCE_VERSION)/%.json.gz, $(SOURCE_IDS_INCL_MONDO))
ALL_SOURCES_OWL_GZ = $(patsubst %, sources/$(SOURCE_VERSION)/%.owl.gz, $(SOURCE_IDS_INCL_MONDO))
ALL_SOURCES_OWL = $(patsubst %, sources/$(SOURCE_VERSION)/%.owl, $(SOURCE_IDS_INCL_MONDO))
sources: $(ALL_SOURCES_JSON) $(ALL_SOURCES_OWL) $(ALL_SOURCES_JSON_GZ) $(ALL_SOURCES_OWL_GZ)
.PHONY: source_release_dir
source_release_dir:
mkdir -p sources/$(SOURCE_VERSION)
sources/$(SOURCE_VERSION)/%.gz: sources/$(SOURCE_VERSION)/% | source_release_dir
gzip -c $< > $@
sources/$(SOURCE_VERSION)/%.json: sources/$(SOURCE_VERSION)/%.owl
robot merge -i $< convert -f json -o $@
## The following goals covers NCIT, DOID, and MONDO
sources/$(SOURCE_VERSION)/%.owl: | source_release_dir
robot merge -I $(OBO)/$*.owl -o $@
sources/$(SOURCE_VERSION)/omim.owl: build-omim | source_release_dir
robot merge -i sources/omim/omim.owl -o $@
# build-medgen
sources/$(SOURCE_VERSION)/medgen.owl: | source_release_dir
echo "WARNING: MEDGEN IS CURRENTLY NOT BEING UPDATED, BECAUSE OF "
robot merge -i sources/medgen/medgen-disease-extract.owl -o $@
sources/$(SOURCE_VERSION)/ordo.owl: build-orphanet | source_release_dir
robot merge -i sources/orphanet/ordo_orphanet.owl -o $@
sources/$(SOURCE_VERSION)/equivalencies.owl: | source_release_dir
curl -L -s $(OBO)/mondo/imports/equivalencies.owl > [email protected] && mv [email protected] $@
#sources/CTD_diseases.obo:
# curl -L -s http://ctdbase.org/reports/CTD_diseases.obo.gz | gzip -dc | perl -npe 's@alt_id@xref@' > [email protected] && mv [email protected] $@
reports/gard-mondo-mapped-obsoletes.tsv: $(ONT).owl
$(ROBOT) query -i $(ONT).owl -f tsv --query $(SPARQLDIR)/reports/gard-mondo-mapped-obsoletes.sparql $@
##################################################
################## Old diseases2owl code #########
#### Download and preprocess upstream Mondo sources.
# MONDO_SOURCES = omim medgen medic orphanet
#MONDO_SOURCES_WITH_SPECIAL_PREPROCESSING = omim medgen orphanet
#all: build_sources
# $(ROBOT) query -f tsv --use-graphs false -i $(SRC) --query $(SPARQLDIR)/reports/related-exact-synonym-report.sparql reports/related-exact-synonym-report.tsv
#.PHONY: release_dir
#build_sources: $(patsubst %, build-%, $(MONDO_SOURCES))
.PHONY: build-%
build-%:
cd sources/$* && make all -B
#### Some useful ROBOT queries:
# $(ROBOT) query -f tsv --use-graphs false -i $(SRC) --query $(SPARQLDIR)/excluded-subsumption-is-inferred-violation.sparql reports/excluded-subsumption-is-inferred-violation.tsv
# $(ROBOT) query -i $(SRC) --update $(SPARQLDIR)/update/excluded-subsumption-is-inferred-tags.sparql -o $(SRC)
# $(ROBOT) query -f tsv --use-graphs false -i $(SRC) --query $(SPARQLDIR)/related-exact-synonym-report.sparql reports/related-exact-synonym-report.tsv
# $(ROBOT) query -f tsv --use-graphs false -i $(SRC) --query $(SPARQLDIR)/related-exact-synonym-reportz.sparql reports/related-exact-synonym-report.tsv
patterns: matches pattern_docs
make components/mondo-tags.owl
components:
$(MAKE) patterns
reports/robot_diff.md: mondo.obo mondo-lastbuild.obo
$(ROBOT) diff --left mondo-lastbuild.obo --right $< -f markdown -o $@
tmp/mondo-lastbase.owl:
mkdir -p tmp && wget "http://purl.obolibrary.org/obo/mondo/mondo-base.owl" -O $@
reports/mondo_diff.md: mondo-base.owl tmp/mondo-lastbase.owl
$(ROBOT) diff --left tmp/mondo-lastbase.owl --right $< -f markdown -o $@
reports/mondo_unsats.md: mondo.obo
$(ROBOT) explain -i $< --reasoner ELK -M unsatisfiability --unsatisfiable all --explanation $@ \
annotate --ontology-iri "http://purl.obolibrary.org/obo/$@" -o [email protected]
.PHONY: mondo_feature_diff
mondo_feature_diff: reports/robot_diff.md reports/mondo_unsats.md
.PHONY: mondo_feature_diff
related_annos_to_exact:
$(ROBOT) query --use-graphs false -i $(SRC) --update $(SPARQLDIR)/related-exact-synonym-annotations.ru -o $(SRC)
related_to_exact_where_label:
$(ROBOT) query --use-graphs false -i $(SRC) --update $(SPARQLDIR)/update/rm-related-where-label.ru -o $(SRC)
rm_related_annos_to_exact:
$(ROBOT) query --use-graphs false -i $(SRC) --update $(SPARQLDIR)/rm-related-exact-synonym-annotations.ru -o $(SRC)
rm_xref_without_source:
$(ROBOT) query --use-graphs false -i $(SRC) --update $(SPARQLDIR)/update/rm-xref-without-source.ru -o $(SRC)
rm_confidence_annotation:
$(ROBOT) query --use-graphs false -i $(SRC) --update $(SPARQLDIR)/update/rm-confidence_annotation.ru -o $(SRC)
report-query-%:
$(ROBOT) query --use-graphs true -i $(SRC) -f tsv --query $(SPARQLDIR)/reports/$*.sparql reports/report-$*.tsv
report-base-query-%: mondo-base.owl
$(ROBOT) query --use-graphs true -i mondo-base.owl -f tsv --query $(SPARQLDIR)/reports/$*.sparql reports/report-base-$*.tsv
report-reason-query-%:
$(ROBOT) reason -i $(SRC) query --use-graphs true -f tsv --query $(SPARQLDIR)/reports/$*.sparql reports/report-reason-$*.tsv
report-reason-materialise-query-%:
$(ROBOT) reason -i $(SRC) materialize --term RO:0002573 \
query --use-graphs true -f tsv --query $(SPARQLDIR)/reports/$*.sparql reports/report-reason-materialise-$*.tsv
#report-owl-query-%:
# $(ROBOT) query --use-graphs true -I http://purl.obolibrary.org/obo/mondo/mondo-with-equivalents.owl -f tsv --query $(SPARQLDIR)/reports/$*.sparql reports/report-$*.tsv
tmp/mondo-rdfxml.owl:
$(ROBOT) remove -i $(SRC) --select imports convert -f owl -o $@
report-tbd-query-%: tmp/mondo-rdfxml.owl
$(ROBOT) query --use-graphs true -i $< -f tsv --tdb true --query $(SPARQLDIR)/reports/$*.sparql reports/report-$*.tsv
update-query-%:
$(ROBOT) query --use-graphs true -i $(SRC) --update $(SPARQLDIR)/update/$*.ru convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC)
make NORM
mv NORM $(SRC)
construct-query-%:
$(ROBOT) query --use-graphs true -i $(SRC) --query $(SPARQLDIR)/update/$*.ru tmp/construct-$*.ttl
construct-merge-query-%: construct-query-%
$(ROBOT) merge -i $(SRC) -i tmp/construct-$*.ttl --collapse-import-closure false convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC)
make NORM
mv NORM $(SRC)
construct-unmerge-query-%: construct-query-%
$(ROBOT) unmerge -i $(SRC) -i tmp/construct-$*.ttl convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC)
make NORM
mv NORM $(SRC)
TMP_TEMPLATE_URL="https://docs.google.com/spreadsheets/d/e/2PACX-1vQ8cszVqBNOeClD6uFif3QRHn0Ud_Cyt_gylyTTFJ-RoJaOwNWS7Qv3c516bJoTBaKT1WLagSQ7CQqS/pub?gid=0&single=true&output=tsv"
TMP_TEMPLATE_FILE=tmp/temporary.tsv
TMP_TEMPLATE_OWL=tmp/temporary.owl
temporary_template:
wget "$(TMP_TEMPLATE_URL)" -O $(TMP_TEMPLATE_FILE)
robot template --template $(TMP_TEMPLATE_FILE) -o $(TMP_TEMPLATE_OWL)
UNMERGE_FILE=$(TMP_TEMPLATE_OWL)
unmerge:
$(ROBOT) convert -i $(UNMERGE_FILE) -f ofn -o tmp/unmerge.owl
sed -i '/^Declaration[(]/d' tmp/unmerge.owl
$(ROBOT) unmerge -i mondo-edit.obo -i tmp/unmerge.owl convert -f obo -o tmp/mondo-edit.obo
mv tmp/mondo-edit.obo mondo-edit.obo
make NORM
mv NORM mondo-edit.obo
# This first merges a the result of a construct query to mondo-edit, than unmerges another
construct-remerge-query-%: construct-query-% construct-query-%-new
$(ROBOT) merge -i $(SRC) -i tmp/construct-$*-new.ttl --collapse-import-closure false \
unmerge -i tmp/construct-$*.ttl \
convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC)
make NORM
mv NORM $(SRC)
fix-disorder-names:
make construct-unmerge-query-construct-disorders-conformsTo-location-label
make construct-merge-query-construct-disorders-conformsTo-location-newlabel
update-merge-normalise-%: update-query-%
mv $(SRC).obo $(SRC)
make NORM
mv NORM $(SRC)
.PHONY: r2e
r2e:
make related_annos_to_exact
make NORM
mv NORM mondo-edit.obo
GH_ISSUE=none
OBS_REASON=outOfScope
.PRECIOUS: config/obsolete_me.txt
.PRECIOUS: config/filtered_obsolete_me.txt
mass_obsolete:
perl ../scripts/obo-obsoletify.pl --seeAlso https://github.com/monarch-initiative/mondo/issues/$(GH_ISSUE) --obsoletionReason MONDO:$(OBS_REASON) -i ../scripts/obsolete_me.txt mondo-edit.obo > OBSOLETE && mv OBSOLETE mondo-edit.obo
tmp/mass_obsolete.sparql: ../sparql/reports/mondo-obsolete-simple.sparql config/filtered_obsolete_me.txt
@echo "\n** Run mondo-obsolete-simple.sparql **"
LISTT="$(shell paste -sd" " config/filtered_obsolete_me.txt)"; sed "s/MONDO:0000000/$$LISTT/g" $< > $@
tmp/mondo-rename-effected-classes.ru: ../sparql/reports/mondo-rename-effected-classes.ru config/filtered_obsolete_me.txt
@echo "\n** Run mondo-rename-effected-classes.ru **"
LISTT="$(shell paste -sd" " config/filtered_obsolete_me.txt)"; sed "s/MONDO:0000000/$$LISTT/g" $< > $@
tmp/mass_obsolete_warning.sparql: ../sparql/reports/mondo-obsolete-warning.sparql config/filtered_obsolete_me.txt
@echo "\n** Run mondo-obsolete-warning.sparql **"
LISTT="$(shell paste -sd" " config/filtered_obsolete_me.txt)"; sed "s/MONDO:0000000/$$LISTT/g" $< > $@
tmp/mass_obsolete.ru: ../sparql/update/mondo-obsolete-simple.ru config/filtered_obsolete_me.txt
@echo "\n** Run mondo-obsolete-simple.ru **"
# Create input for query
LISTT="$(shell paste -sd" " config/filtered_obsolete_me.txt)"; \
sed -e "s/MONDO:0000000/$$LISTT/g" -e "s|GITHUB_ISSUE_URL|$(GITHUB_ISSUE_URL)|g" $< > $@
config/filtered_obsolete_me.txt: tmp/identify_existing_obsoletes.txt config/obsolete_me.txt
# Remove ^M from tmp/identify_existing_obsoletes.txt
sed 's/\r//g' tmp/identify_existing_obsoletes.txt > tmp/filtered_identify_existing_obsoletes.txt
# Filter out existing obsoletes
grep -v -w -i -f tmp/filtered_identify_existing_obsoletes.txt config/obsolete_me.txt > $@
tmp/mass_obsolete_me.txt: tmp/mass_obsolete.sparql
$(ROBOT) query -i $(SRC) --use-graphs true -f tsv --query $< $@
sed -i 's/[?]//g' $@
sed -i 's/<http:[/][/]purl[.]obolibrary[.]org[/]obo[/]MONDO_/MONDO:/g' $@
sed -i 's/>//g' $@
.PHONY: mass_obsolete_warning
mass_obsolete_warning: tmp/mass_obsolete_warning.sparql
$(ROBOT) verify -i $(SRC) --queries $< --output-dir reports/
tmp/identify_existing_obsoletes.ru: ../sparql/reports/check_obsoletes_from_list.ru config/obsolete_me.txt
@echo "\n** Identify existing obsoletes in config/obsolete_me.txt **"
LISTT="$(shell paste -sd" " config/obsolete_me.txt)"; sed "s/MONDO:0000000/$$LISTT/g" $< > $@
tmp/identify_existing_obsoletes.txt: tmp/identify_existing_obsoletes.ru
@echo "\n** Write existing obsoletes to tmp/identify_existing_obsoletes.txt **"
$(ROBOT) query --format txt -i $(SRC) --query $< $@
mass_obsolete2: tmp/mass_obsolete.ru tmp/mass_obsolete_me.txt
@echo "Make sure you have updated config/obsolete_me.txt before running this script.."
$(MAKE) tmp/mondo-obsolete-labels.obo
$(MAKE) mass_obsolete_warning
@echo "** Check above for violations\n"
$(ROBOT) query -i $(SRC) --use-graphs true --update tmp/mass_obsolete.ru \
remove --preserve-structure false -T tmp/mass_obsolete_me.txt --axioms logical convert -f obo --check false -o $(SRC).obo
mv $(SRC).obo $(SRC)
$(MAKE) NORM
mv NORM $(SRC)
tmp/mondo-obsolete-labels.obo: tmp/mondo-rename-effected-classes.ru
@echo "\n** Re-name obsolete class labels **"
$(ROBOT) merge -i $(SRC) --collapse-import-closure false query --update tmp/mondo-rename-effected-classes.ru \
convert -f obo --check false -o $@
MAPPINGSDIR=mappings
METADATADIR=metadata
MAPPING_IDS=mondo
ALL_MAPPINGS=$(patsubst %, $(MAPPINGSDIR)/%.sssom.tsv, $(MAPPING_IDS))
tmp/mirror-ordo.json: mirror/ordo.obo
robot merge -i mirror/ordo.obo convert -f json -o $@
tmp/mirror-omim.json: mirror/omim.obo
robot merge -i mirror/omim.obo convert -f json -o $@
tmp/mirror-mondo.json: mondo.owl
robot merge -i mondo.owl convert -f json -o $@
tmp/mirror-efo.json: #mirror/efo.owl
robot merge -i mirror/efo.owl convert -f json -o $@
.PHONY: sssom
sssom:
python3 -m pip install --upgrade pip setuptools && python3 -m pip install --upgrade --force-reinstall sssom==0.4.0
.PHONY: oaklib
oaklib:
python3 -m pip install --upgrade pip setuptools && python3 -m pip install --upgrade --force-reinstall oaklib
tmp/%.sssom.tsv: tmp/mirror-%.json
sssom parse tmp/mirror-$*.json --no-strict-clean-prefixes -I obographs-json -m $(METADATADIR)/mondo.sssom.config.yml -C merged -o $@
$(MAPPINGSDIR)/mondo.sssom.tsv: tmp/mondo.sssom.tsv tmp/mondo-ingest.db
python ../scripts/add_object_label.py run $<
python ../scripts/split_sssom_by_source.py -s $< -m $(METADATADIR)/mondo.sssom.config.yml -o $(MAPPINGSDIR)/
sssom dosql -Q "SELECT * FROM df WHERE predicate_id IN (\"skos:exactMatch\", \"skos:broadMatch\")" $< -o $@
sssom annotate $@ -o $@ --mapping_set_id "http://purl.obolibrary.org/obo/mondo/mappings/mondo.sssom.tsv"
sssom sort $@ -o $@
sssom validate $@
#$(MAPPINGSDIR)/%.sssom.tsv: tmp/mirror-%.json
# sssom convert -i $< -o $@
# #python ../scripts/split_sssom_by_source.py $@
.PHONY: clean_mappings
.PHONY: mappings mappings_fast
clean_mappings:
rm -rf $(MAPPINGSDIR)/*.sssom.tsv
mappings: clean_mappings $(ALL_MAPPINGS)
mappings_fast:
$(MAKE) sssom -B
$(MAKE) clean_mappings -B
$(MAKE) mappings IMP=false MIR=false PAT=false -B
###### OMIM Genes #########
tmp/omim.owl:
$(ROBOT) merge -I "https://github.com/monarch-initiative/omim/releases/latest/download/omim.owl" convert -o $@
tmp/omim-genes.tsv: tmp/omim.owl
$(ROBOT) query --use-graphs true -i tmp/omim.owl -f tsv --tdb true --query $(SPARQLDIR)/reports/omim-genes.sparql $@
sed -i 's/[?]//g' $@
sed -i 's/[<]https[:][/][/]omim[.]org[/]entry[/]/OMIM:/g' $@
sed -i 's/>//g' $@
tail -n +2 $@ > output_file && mv output_file $@
# Check for occurrences of OMIM genes in MONDO,
# Then narrow down to only xrefs
tmp/omim-gene-matches.txt: tmp/omim-genes.tsv
grep -Ff $< mondo-edit.obo | grep '^xref' > $@ || true
if [ -s $@ ]; then \
echo "FAIL: OMIM gene entry used in xref (matches found in $@)"; \
exit 1; \
fi
test: tmp/omim-gene-matches.txt
##### RELEASE Report ######
reports/mondo_base_current_%.tsv: mondo-base.owl
$(ROBOT) query --use-graphs true -i mondo-base.owl -f tsv --tdb true --query $(SPARQLDIR)/reports/$*.sparql $@
reports/mondo_base_last_%.tsv: tmp/mondo-lastbase.owl
$(ROBOT) query --use-graphs true -i tmp/mondo-lastbase.owl -f tsv --tdb true --query $(SPARQLDIR)/reports/$*.sparql $@
tmp/mondo-versioned-base.owl:
$(ROBOT) convert -I http://purl.obolibrary.org/obo/mondo/releases/$(COMPARE_VERSION)/mondo-base.owl -f owl -o $@
reports/mondo_base_version_%.tsv: tmp/mondo-versioned-base.owl
$(ROBOT) query --use-graphs true -i tmp/mondo-versioned-base.owl -f tsv --tdb true --query $(SPARQLDIR)/reports/$*.sparql $@
reports/mondo_release_diff.md reports/mondo_release_diff_changed_terms.tsv reports/mondo_release_diff_new_terms.tsv: reports/mondo_base_last_release-report.tsv reports/mondo_base_current_release-report.tsv reports/mondo_obsoletioncandidates.tsv
python ../scripts/merge_release_diff.py reports/mondo_base_last_release-report.tsv reports/mondo_base_current_release-report.tsv reports/mondo_obsoletioncandidates.tsv reports/mondo_release_diff_changed_terms.tsv reports/mondo_release_diff_new_terms.tsv > reports/mondo_release_diff.md
sed -i 's/ */ /g' reports/mondo_release_diff.md
sed -i 's/----*/---/g' reports/mondo_release_diff.md
sed -i 's/----*/---/g' reports/mondo_release_diff.md
version_diff: reports/mondo_base_version_release-report.tsv reports/mondo_base_current_release-report.tsv reports/mondo_obsoletioncandidates.tsv
python ../scripts/merge_release_diff.py reports/mondo_base_last_release-report.tsv reports/mondo_base_current_release-report.tsv reports/mondo_obsoletioncandidates.tsv reports/mondo_release_diff_changed_terms_version.tsv reports/mondo_release_diff_new_terms_version.tsv > reports/mondo_release_diff_version.md
sed -i 's/ */ /g' reports/mondo_release_diff_version.md
sed -i 's/----*/---/g' reports/mondo_release_diff_version.md
sed -i 's/----*/---/g' reports/mondo_release_diff_version.md
reports/mondo_obsoletioncandidates.tsv: report-base-query-obsoletioncandidates-withcomment
cp reports/report-base-obsoletioncandidates-withcomment.tsv $@
sed -i 's/[?]//g' $@
sed -i 's/<http:[/][/]purl[.]obolibrary[.]org[/]obo[/]MONDO_/MONDO:/g' $@
sed -i 's/>//g' $@
release_diff: reports/mondo_release_diff.md
all: reports/mondo_release_diff.md
all: reports/mondo_obsoletioncandidates.tsv
##################
### KGCL Diff ####
##################
KGCL_ONTOLOGY=mondo-base.obo
all: kgcl-diff
.PHONY: kgcl-diff
kgcl-diff: kgcl-diff-release-base
.PHONY: kgcl-diff-release-base
kgcl-diff-release-base: reports/difference_release_base.yaml \
reports/difference_release_base.tsv \
reports/difference_release_base.md
tmp/mondo-released.obo: .FORCE
wget http://purl.obolibrary.org/obo/mondo/$(KGCL_ONTOLOGY) -O $@
reports/difference_release_base.md: tmp/mondo-released.obo $(KGCL_ONTOLOGY)
runoak -i simpleobo:tmp/mondo-released.obo diff -X simpleobo:$(KGCL_ONTOLOGY) -o $@ --output-type md
reports/difference_release_base.tsv: tmp/mondo-released.obo $(KGCL_ONTOLOGY)
runoak -i simpleobo:tmp/mondo-released.obo diff -X simpleobo:$(KGCL_ONTOLOGY) \
-o $@ --output-type csv --statistics --group-by-property oio:hasOBONamespace
reports/difference_release_base.yaml: tmp/mondo-released.obo $(KGCL_ONTOLOGY)
runoak -i simpleobo:tmp/mondo-released.obo diff -X simpleobo:$(KGCL_ONTOLOGY) -o $@ --output-type yaml
###########################
## MONDO VIEW GENERATION ##
###########################
# 1. In a ROBOT template, define a top level as you see fit (using, however, MONDO ids)
# 2. Make sure the template file ends up in modules, and is named like modules/harrisons-view.tsv, where harrisons is the id
# 3. Add the id to the MONDOVIEWS variable
# 4. Run `sh run.sh make mondo-views` to generate all views, including your new one.
# This will:
# a) build the template (modules/mondo-%-view-top.owl)
# b) query for the children of the leafs in the template
# c) Remove all other MONDO classes from mondo.owl (other than the leafs and their children)
# d) Merge this with the template upper level
HARRISON_TEMPLATE_URL=https://docs.google.com/spreadsheets/d/e/2PACX-1vS0748V0s6seWTYetzidiWJbY7r-e_Vc87XcQKl8NmN5BK0LWUios9DTcGqM_1cLj7wWUaueUaBDVx8/pub?gid=0&single=true&output=tsv
modules/harrisons-view.tsv:
wget "$(HARRISON_TEMPLATE_URL)" -O $@
modules/mondo-%-view-top.owl: modules/%-view.tsv
$(ROBOT) -vvv merge -i $(SRC) template --template $< --output $@ && \
$(ROBOT) -vvv annotate --input $@ --ontology-iri $(OBO)/$(ONT)/mondo-$*-view-top.owl -o $@
.PRECIOUS: modules/mondo-%-view-top.owl
tmp/mondo-%-leafs.txt: modules/mondo-%-view-top.owl
$(ROBOT) query --use-graphs false -i $< -f tsv --query $(SPARQLDIR)/signature/leaf-classes.sparql $@
tail -n +2 "$@" > [email protected] && mv [email protected] $@