-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
159 lines (126 loc) · 4.06 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
# OHMI ontology Makefile
# Jie Zheng
#
# This Makefile is used to build artifacts
# for the OHMI ontology.
#
### Configuration
#
# prologue:
# <http://clarkgrubb.com/makefile-style-guide#toc2>
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := all
.DELETE_ON_ERROR:
.SUFFIXES:
### Definitions
SHELL := /bin/bash
OBO := http://purl.obolibrary.org/obo
OHMI := $(OBO)/OHMI_
DEV := $(OBO)/ohmi/dev
TODAY := $(shell date +%Y-%m-%d)
### Directories
#
# This is a temporary place to put things.
build:
mkdir -p $@
### ROBOT
#
# We use the official development version of ROBOT
# download the most recent build of ROBOT
build/robot.jar: | build
@echo "Getting ROBOT" && \
curl -L -o $@ https://github.com/ontodev/robot/releases/download/v1.2.0/robot.jar
ROBOT = java -jar build/robot.jar
### Imports
#
# Use Ontofox to import various modules.
#_build/import_%.owl: src/Ontofox-inputs/%_input.txt | build
#_ curl -s -F file=@$< -o $@ http://ontofox.hegroup.org/service.php
# Use ROBOT to ensure that serialization is consistent.
#_src/ontology/Ontofox_outputs/%_import.owl: build/import_%.owl
#_ $(ROBOT) convert -i build/$*_import.owl -o $@
#_IMPORT_FILES := $(wildcard src/ontology/import/import_*.owl)
#_.PHONY: imports
#_imports: $(IMPORT_FILES)
### Build
#
# Here we create a standalone OWL file appropriate for release.
# This involves merging, reasoning, annotating,
# and removing any remaining import declarations.
build/ohmi_merged.owl: src/ontology/ohmi-edit.owl | build/robot.jar
@echo "Merging $< to $@" && \
$(ROBOT) merge \
--input $< \
annotate \
--ontology-iri "$(OBO)/ohmi/ohmi_merged.owl" \
--version-iri "$(OBO)/ohmi/$(TODAY)/ohmi_merged.owl" \
--annotation owl:versionInfo "$(TODAY)" \
--output build/ohmi_merged.tmp.owl
sed '/<owl:imports/d' build/ohmi_merged.tmp.owl > $@
rm build/ohmi_merged.tmp.owl
ohmi.owl: build/ohmi_merged.owl | build/robot.jar
$(ROBOT) reason \
--input $< \
--reasoner HermiT \
annotate \
--ontology-iri "$(OBO)/ohmi.owl" \
--version-iri "$(OBO)/ohmi/$(TODAY)/ohmi.owl" \
--annotation owl:versionInfo "$(TODAY)" \
--output $@
test_report.tsv: build/ohmi_merged.owl
$(ROBOT) report \
--input $< \
--fail-on none \
--output $@
### Test
#
# Run main tests
MERGED_VIOLATION_QUERIES := $(wildcard src/sparql/*-violation.rq)
build/terms-report.csv: build/ohmi_merged.owl src/sparql/terms-report.rq | build
$(ROBOT) query --input $< --select $(word 2,$^) $@
build/ohmi-previous-release.owl: | build
curl -L -o $@ "http://purl.obolibrary.org/obo/ohmi.owl"
build/released-entities.tsv: build/ohmi-previous-release.owl src/sparql/get-ohmi-entities.rq | build/robot.jar
$(ROBOT) query --input $< --select $(word 2,$^) $@
build/current-entities.tsv: build/ohmi_merged.owl src/sparql/get-ohmi-entities.rq | build/robot.jar
$(ROBOT) query --input $< --select $(word 2,$^) $@
build/dropped-entities.tsv: build/released-entities.tsv build/current-entities.tsv
comm -23 $^ > $@
# Run all validation queries and exit on error.
.PHONY: verify
verify: verify-merged verify-entities
# Run validation queries on ohmi_merged and exit on error.
.PHONY: verify-merged
verify-merged: build/ohmi_merged.owl $(MERGED_VIOLATION_QUERIES) | build/robot.jar
$(ROBOT) verify --input $< --output-dir build \
--queries $(MERGED_VIOLATION_QUERIES)
# Check if any entities have been dropped and exit on error.
.PHONY: verify-entities
verify-entities: build/dropped-entities.tsv
@echo $(shell < $< wc -l) " ohmi IRIs have been dropped"
@! test -s $<
# Run a Hermit reasoner to find inconsistencies
.PHONY: reason
reason: build/ohmi_merged.owl | build/robot.jar
$(ROBOT) reason --input $< --reasoner HermiT
.PHONY: test
test: reason verify
### General/Users/jiezheng/Documents/ontology/ohmi
#
# Full build
.PHONY: all
all: test ohmi.owl build/terms-report.csv
# Remove generated files
.PHONY: clean
clean:
rm -rf build
# Check for problems such as bad line-endings
.PHONY: check
check:
src/scripts/check-line-endings.sh tsv
# Fix simple problems such as bad line-endings
.PHONY: fix
fix:
src/scripts/fix-eol-all.sh