forked from DiseaseOntology/HumanDiseaseOntology
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
386 lines (322 loc) · 11.1 KB
/
Makefile
File metadata and controls
386 lines (322 loc) · 11.1 KB
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
# config
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := all
.DELETE_ON_ERROR:
.SUFFIXES:
.SECONDARY:
DO = src/ontology/doid
EDIT = src/ontology/doid-edit.owl
OBO = http://purl.obolibrary.org/obo/
# Other products
DM = src/ontology/doid-merged
DNC = src/ontology/doid-non-classified
HD = src/ontology/HumanDO
# to make a release, use `make release`
# to update imports, use `make imports`
# to do both, use `make all`
release: products publish post
all: imports release
test: verify
# ----------------------------------------
# ROBOT
# ----------------------------------------
init: build
build build/reports:
mkdir -p $@
# run `make update_robot` to get a new version of ROBOT
.PHONY: update_robot
update_robot:
rm -rf build/robot.jar && make build/robot.jar
build/robot.jar: init
curl -L -o $@ https://github.com/beckyjackson/doid-robot/releases/download/1.0.0/robot.jar
# ROBOT with Reason logging suppressed
ROBOT := java -Dlog4j.configuration=src/util/logging.properties -jar build/robot.jar
# ----------------------------------------
# IMPORTS
# ----------------------------------------
# You can run `make <import name>` from the `ontology` dir
# or the `ontology/imports` dir
.PHONY: imports
imports: | build/robot.jar
@echo "Generating import modules (this may take some time)..."
@cd src/ontology/imports && make imports
IMPS = bto chebi cl foodon hp ncbitaxon uberon trans so symp full
$(IMPS): | build/robot.jar
@echo "Generating $@ import module..."
@cd src/ontology/imports && make $@
# ----------------------------------------
# PRE-BUILD REPORT
# ----------------------------------------
report: build/reports/report.tsv
# Report for general issues on doid-edit
.PRECIOUS: build/reports/report.tsv
build/reports/report.tsv: $(EDIT) | build/robot.jar build/reports
@echo ""
@$(ROBOT) report --input $< \
--profile src/sparql/report/report_profile.txt \
--labels true --output $@
@echo "Full DO QC report available at $@"
@echo ""
# ----------------------------------------
# RELEASE
# ----------------------------------------
products: subsets human merged build
# release vars
TS = $(shell date +'%d:%m:%Y %H:%M')
DATE = $(shell date +'%Y-%m-%d')
$(DO).owl: $(EDIT) build/reports/report.tsv | build/robot.jar
@$(ROBOT) reason \
--input $< \
--create-new-ontology false \
--annotate-inferred-axioms false \
--exclude-duplicate-axioms true \
annotate \
--annotation oboInOwl:date "$(TS)" \
--version-iri "$(OBO)doid/releases/$(DATE)/$(notdir $@)" \
--output $@
@echo "Created $@"
$(DO).obo: $(DO).owl | build/robot.jar
@$(ROBOT) remove \
--input $< \
--select imports \
--trim true \
remove \
--select "parents equivalents" \
--select "anonymous" \
query \
--update src/sparql/remove-ref-type.ru \
annotate \
--version-iri "$(OBO)doid/releases/$(DATE)/$(notdir $@)" \
--output $(basename $@)-temp.obo
@grep -v ^owl-axioms $(basename $@)-temp.obo | \
grep -v ^date | \
perl -lpe 'print "date: $(TS)" if $$. == 3' > $@
@rm $(basename $@)-temp.obo
@echo "Created $@"
$(DO).json: $(DO).owl | build/robot.jar
@$(ROBOT) convert --input $< --output $@
@echo "Created $@"
# ----------------------------------------
# DOID-MERGED
# ----------------------------------------
merged: $(DM).owl $(DM).obo
$(DM).owl: $(DO).owl | build/robot.jar
@$(ROBOT) merge \
--input $< \
--collapse-import-closure true \
annotate \
--version-iri "$(OBO)doid/releases/$(DATE)/$(notdir $@)" \
--ontology-iri "$(OBO)doid/$(notdir $@)" \
--output $@
@echo "Created $@"
$(DM).obo: $(DM).owl | build/robot.jar
@$(ROBOT) query \
--input $< \
--update src/sparql/remove-ref-type.ru \
annotate \
--version-iri "$(OBO)doid/releases/$(DATE)/$(notdir $@)" \
--ontology-iri "$(OBO)doid/$(notdir $@)" \
convert \
--check false \
--output $(basename $@)-temp.obo
@grep -v ^owl-axioms $(basename $@)-temp.obo | \
grep -v ^date | \
perl -lpe 'print "date: $(TS)" if $$. == 3' > $@
@rm $(basename $@)-temp.obo
@echo "Created $@"
# ----------------------------------------
# HUMANDO
# ----------------------------------------
human: $(DNC).owl $(DNC).obo $(DNC).json
$(DNC).owl: $(EDIT) | build/robot.jar
@$(ROBOT) remove \
--input $< \
--select imports \
--trim true \
remove \
--select "parents equivalents" \
--select anonymous \
annotate \
--ontology-iri "$(OBO)doid/$(notdir $@)" \
--version-iri "$(OBO)doid/releases/$(DATE)/$(notdir $@)" \
--output $@
@cp $@ $(HD).owl
@echo "Created $@"
$(DNC).obo: $(EDIT) | build/robot.jar
@$(ROBOT) remove \
--input $< \
--select imports \
--trim true \
remove \
--select "parents equivalents" \
--select "anonymous" \
query \
--update src/sparql/remove-ref-type.ru \
annotate \
--ontology-iri "$(OBO)doid/$(notdir $@)" \
--version-iri "$(OBO)doid/releases/$(DATE)/$(notdir $@)" \
--output $(basename $@)-temp.obo
@grep -v ^owl-axioms $(basename $@)-temp.obo | \
perl -lpe 'print "date: $(TS)" if $$. == 3' > $@
@cp $@ $(HD).obo
@rm $(basename $@)-temp.obo
@echo "Created $@"
$(DNC).json: $(DNC).owl | build/robot.jar
@$(ROBOT) convert --input $< --output $@
@echo "Created $@"
# ----------------------------------------
# SUBSETS
# ----------------------------------------
SUB_NAMES = DO_AGR_slim DO_cancer_slim DO_FlyBase_slim DO_GXD_slim DO_IEDB_slim DO_MGI_slim\
DO_rare_slim GOLD NCIthesaurus TopNodes_DOcancerslim gram-negative_bacterial_infectious_disease\
gram-positive_bacterial_infectious_disease sexually_transmitted_infectious_disease\
tick-borne_infectious_disease zoonotic_infectious_disease
SUBS = $(foreach N,$(SUB_NAMES),$(addprefix src/ontology/subsets/, $(N)))
OWL_SUBS = $(foreach N,$(SUBS),$(addsuffix .owl, $(N)))
OBO_SUBS = $(foreach N,$(SUBS),$(addsuffix .obo, $(N)))
JSON_SUBS = $(foreach N,$(SUBS),$(addsuffix .json, $(N)))
subsets: $(OWL_SUBS) $(OBO_SUBS) $(JSON_SUBS)
$(OWL_SUBS): $(DNC).owl | build/robot.jar
@$(ROBOT) filter \
--input $< \
--select "oboInOwl:inSubset=<$(OBO)doid#$(basename $(notdir $@))> annotations" \
annotate \
--version-iri "$(OBO)doid/$(DATE)/subsets/$(notdir $@)" \
--ontology-iri "$(OBO)doid/subsets/$(notdir $@)" --output $@
@echo "Created $@"
src/ontology/subsets/%.obo: src/ontology/subsets/%.owl | build/robot.jar
@$(ROBOT) query \
--input $< \
--update src/sparql/remove-ref-type.ru \
annotate \
--version-iri "$(OBO)doid/$(DATE)/subsets/$(notdir $@)" \
--ontology-iri "$(OBO)doid/subsets/$(notdir $@)" \
convert --output $@
@echo "Created $@"
src/ontology/subsets/%.json: src/ontology/subsets/%.owl | build/robot.jar
@$(ROBOT) annotate --input $< \
--version-iri "$(OBO)doid/$(DATE)/subsets/$(notdir $@)" \
--ontology-iri "$(OBO)doid/subsets/$(notdir $@)" \
convert --output $@
@echo "Created $@"
# ----------------------------------------
# RELEASE
# ----------------------------------------
DIR = src/ontology/releases/$(DATE)
# Move release files to a new dir
.PHONY: publish
publish: $(DO).owl $(DO).obo $(DO).json\
$(DM).owl $(DM).obo\
$(DNC).owl $(DNC).obo $(DNC).json\
subsets
@mkdir -p $(DIR)
@cp $(DO).* $(DIR)
@cp $(DM).* $(DIR)
@cp $(DNC).* $(DIR)
@cp -r src/ontology/subsets $(DIR)
@echo "Published to $(DIR)"
@echo ""
# ----------------------------------------
# POST-BUILD REPORT
# ----------------------------------------
# Count classes, imports, and logical defs from old and new
post: build/reports/report-diff.txt build/reports/branch-count.tsv build/reports/removed-axioms.html
# Get the last build of DO from IRI
#.PHONY: build/doid-last.owl
build/doid-last.owl: | build/robot.jar
@$(ROBOT) merge \
--input-iri http://purl.obolibrary.org/obo/doid/doid-merged.owl \
--collapse-import-closure true \
--output $@
# all report queries
QUERIES := $(wildcard src/sparql/*-report.rq)
# target names for previous release reports
LAST_REPORTS := $(foreach Q,$(QUERIES), $(subst src/sparql,build/reports,$(subst .rq,-last.tsv,$(Q))))
.PHONY: last-reports
last-reports: $(LAST_REPORTS)
build/reports/%-last.tsv: src/sparql/%.rq build/doid-last.owl | build/reports
@echo "Counting: $(notdir $(basename $@))"
@$(ROBOT) query \
--input $(word 2,$^) \
--query $< $@
# target names for current release reports
NEW_REPORTS := $(foreach Q,$(QUERIES), $(subst src/sparql,build/reports,$(subst .rq,-new.tsv,$(Q))))
.PHONY: new-reports
new-reports: $(NEW_REPORTS)
build/reports/%-new.tsv: src/sparql/%.rq $(DM).owl | build/reports
@echo "Counting: $(notdir $(basename $@))"
@$(ROBOT) query \
--input $(word 2,$^) \
--query $< $@
# create a clean diff between last and current reports
build/reports/report-diff.txt: last-reports new-reports
@python src/util/report-diff.py
@mv $@ $(DIR)/report-diff.txt
@echo "Release diff report available at $(DIR)/report-diff.txt"
# create a count of the various disease branches
.PHONY: build/reports/branch-count.tsv
build/reports/branch-count.tsv: $(DNC).owl | build/robot.jar build/reports
@echo "Counting all branches..."
@./src/util/branch_count/branch_count.py $< $@
@echo "Branch count available at $@"
# the following targets are used to build a smaller diff with only removed axioms to review
build/robot.diff: build/doid-last.owl $(DM).owl | build/robot.jar
@echo "Comparing axioms in previous release to current release"
@$(ROBOT) diff \
--left $< \
--right $(word 2,$^) \
--labels true --output $@
build/missing-axioms-terms.txt: build/robot.diff
@python src/util/parse-diff.py $< $@
build/doid-last-changed.owl: build/doid-last.owl build/missing-axioms-terms.txt
@$(ROBOT) filter \
--input $< \
--term-file $(word 2,$^) \
--select "self parents annotations" \
--output $@
build/doid-current-changed.owl: $(DM).owl build/missing-axioms-terms.txt
@$(ROBOT) filter \
--input $< \
--term-file $(word 2,$^) \
--select "self parents annotations" \
--output $@
build/reports/removed-axioms.html: build/doid-last-changed.owl build/doid-current-changed.owl | build/reports
@$(ROBOT) diff \
--left $< \
--right $(word 2,$^) \
--format html \
--output $@
@echo "See $@ to review removed axioms"
#-----------------------------
# Ensure proper OBO structure
#-------------------------------
EDIT_V_QUERIES := $(wildcard src/sparql/edit-verify-*.rq)
V_QUERIES := $(wildcard src/sparql/verify-*.rq)
DNC_V_QUERIES := src/sparql/dnc-verify-connectivity.rq
# We are not reduced to single inheritence in DNC
# Once this is cleaned up, we can change to all DNC verifications
#DNC_V_QUERIES := $(wildcard src/sparql/dnc-verify-*.rq)
verify: verify-edit verify-do verify-dnc
# Verify doid-edit.owl
verify-edit: $(EDIT) | build/robot.jar build/reports/report.tsv
@echo "Verifying $< (see build/reports on error)"
@$(ROBOT) verify \
--input $< \
--queries $(EDIT_V_QUERIES) \
--output-dir build/reports
# Verify doid.obo
verify-do: $(DO).obo | build/robot.jar build/reports/report.tsv
@echo "Verifying $< (see build/reports on error)"
@$(ROBOT) verify \
--input $< \
--queries $(V_QUERIES) \
--output-dir build/reports
# Verify doid-non-classified.obo
verify-dnc: $(DNC).obo | build/robot.jar build/reports/report.tsv
@echo "Verifying $< (see build/reports on error)"
@$(ROBOT) verify \
--input $< \
--queries $(V_QUERIES) $(DNC_V_QUERIES) \
--output-dir build/reports