forked from biolink/biolink-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
253 lines (188 loc) · 7.25 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
# All artifacts of the build should be preserved
.SECONDARY:
# It can be fairly expensive to regenerate the various png's in the markdown.
# There are three alternatives:
# 1) make imgflags="-i" -- generate uml images in images subdirectory (default)
# 2) make imgflags="-i --noimages" -- assume uml images already exist and generate links to them
# 3) make imgflags="" -- genrate uml images as inline url's
imgflags?=-i
# ----------------------------------------
# TOP LEVEL TARGETS
# ----------------------------------------
all: install tests build
# Build the biolink model python library
python: biolink/model.py
docs: docs/index.md
jekyll-docs: docs/Classes.md
shex: biolink-model.shex biolink-modeln.shex biolink-model.shexj biolink-modeln.shexj
json-schema: json-schema/biolink-model.json
prefix-map: prefix-map/biolink-model-prefix-map.json
build: python docs/index.md gen-golr-views biolink-model.graphql gen-graphviz context.jsonld contextn.jsonld \
json-schema/biolink-model.json biolink-model.owl.ttl biolink-model.proto shex biolink-model.ttl \
prefix-map/biolink-model-prefix-map.json
# TODO: Get this working
build_contrib: contrib_build_monarch contrib_build_translator contrib_build_go
install: env.lock
# ---------------------------------------
# Install package into build environment
# ---------------------------------------
env.lock:
pipenv install --dev
cp /dev/null env.lock
# ----------------------------------------
# BUILD/COMPILATION
# ----------------------------------------
# ~~~~~~~~~~~~~~~~~~~~
# Python
# ~~~~~~~~~~~~~~~~~~~~
biolink/model.py: biolink-model.yaml env.lock
mkdir biolink 2>/dev/null || true
export PIPENV_DONT_LOAD_ENV=1 && pipenv run gen-py-classes $< > [email protected] && pipenv run python [email protected] && mv [email protected] $@
# ~~~~~~~~~~~~~~~~~~~~
# DOCS
# ~~~~~~~~~~~~~~~~~~~~
docs/index.md: biolink-model.yaml env.lock
pipenv run gen-markdown --dir docs $(imgflags) $<
# ~~~~~~~~~~~~~~~~~~~~
# JEKYLL DOCS
# ~~~~~~~~~~~~~~~~~~~~
docs/Classes.md: biolink-model.yaml env.lock
pipenv run python script/jekyllmarkdowngen.py --dir jekyll_docs --yaml $<
# ~~~~~~~~~~~~~~~~~~~~
# Solr
# ~~~~~~~~~~~~~~~~~~~~
gen-golr-views: biolink-model.yaml dir-golr-views env.lock
pipenv run gen-golr-views -d golr-views $<
# ~~~~~~~~~~~~~~~~~~~~
# pydantic
# ~~~~~~~~~~~~~~~~~~~~
gen-pydantic: biolink-model.yaml dir-pydantic env.lock
pipenv run gen-pydantic $< > biolink/pydanticmodel.py
# ~~~~~~~~~~~~~~~~~~~~
# Graphql
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.graphql: biolink-model.yaml env.lock
pipenv run gen-graphql $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# Graphviz
# ~~~~~~~~~~~~~~~~~~~~
gen-graphviz: biolink-model.yaml dir-graphviz env.lock
pipenv run gen-graphviz -d graphviz $< -f gv
pipenv run gen-graphviz -d graphviz $< -f svg
# ~~~~~~~~~~~~~~~~~~~~
# Java
# ~~~~~~~~~~~~~~~~~~~~
java: json-schema/biolink-model.json dir-java env.lock
jsonschema2pojo --source $< -T JSONSCHEMA -t java
# ~~~~~~~~~~~~~~~~~~~~
# JSON-LD CONTEXT
# ~~~~~~~~~~~~~~~~~~~~
context.jsonld: biolink-model.yaml env.lock
touch $@
pipenv run gen-jsonld-context $< > tmp.jsonld && ( pipenv run comparefiles tmp.jsonld $@ -c "^\s*\"comments\".*\n" && cp tmp.jsonld $@); rm tmp.jsonld
contextn.jsonld: biolink-model.yaml env.lock
touch $@
pipenv run gen-jsonld-context --metauris $< > tmp.jsonld && ( pipenv run comparefiles tmp.jsonld $@ -c "^\s*\"comments\".*\n" && cp tmp.jsonld $@); rm tmp.jsonld
# ~~~~~~~~~~~~~~~~~~~~
# JSON-SCHEMA
# ~~~~~~~~~~~~~~~~~~~~
json-schema/biolink-model.json: biolink-model.yaml dir-json-schema env.lock
pipenv run gen-json-schema $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# prefix-map
# ~~~~~~~~~~~~~~~~~~~~
prefix-map/biolink-model-prefix-map.json: biolink-model.yaml dir-prefix-map env.lock
pipenv run gen-prefix-map $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# Ontology
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.owl.ttl: biolink-model.yaml env.lock
pipenv run gen-owl --no-metaclasses -o $@ $<
# ~~~~~~~~~~~~~~~~~~~~
# Proto
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.proto: biolink-model.yaml env.lock
pipenv run gen-proto $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# RDF
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.ttl: biolink-model.yaml env.lock
pipenv run gen-rdf -f ttl --context https://w3id.org/linkml/context.jsonld $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# ShEx
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.shex: biolink-model.yaml
pipenv run gen-shex $< > $@
biolink-modeln.shex: biolink-model.yaml
touch $@
pipenv run gen-shex --metauris $< > $@
biolink-model.shexj: biolink-model.yaml
touch $@
pipenv run gen-shex --format json $< > $@
biolink-modeln.shexj: biolink-model.yaml
touch $@
pipenv run gen-shex --metauris --format json $< > $@
# ----------------------------------------
# Ontology conversion
# ----------------------------------------
# ontology/%.json: ontology/%.ttl
# owltools $< -o -f json $@
# ontology/%.obo: ontology/%.ttl
# owltools $< -o -f obo --no-check $@
# ontology/%.omn: ontology/%.ttl
# owltools $< -o -f omn --prefix '' http://w3id.org/biolink/vocab/ --prefix def http://purl.obolibrary.org/obo/IAO_0000115 $@
# ontology/%.tree: ontology/%.json
# ogr --showdefs -t tree -r $< % > $@
# ontology/%.png: ontology/%.json
# ogr-tree -t png -o $@ -r $< %
# ~~~~~~~~~~~~~~~~~~~~
# Contrib
# ~~~~~~~~~~~~~~~~~~~~
contrib_build_%: contrib-dir-% contrib/%/docs/index.md contrib/%/datamodel.py contrib-golr-% contrib/%/%.graphql \
contrib/%/%.owl contrib/%/schema.json contrib-java-% contrib/%/%.shex
echo
contrib/%/datamodel.py: contrib-dir-% contrib/%.yaml env.lock
pipenv run gen-py-classes contrib/$*.yaml > tmp.py && (pipenv run comparefiles tmp.py $@ && cp tmp.py $@); rm tmp.py
contrib/%/docs/index.md: contrib/%.yaml
pipenv run gen-markdown --dir contrib/$*/docs $<
contrib/%/datamodel.py: contrib/%.yaml
pipenv run gen-py-classes contrib/$*.yaml > $@
contrib-golr-%: contrib-dir-% contrib/%.yaml
pipenv run gen-golr-views -d contrib/$*/golr-views contrib/$*.yaml
contrib-pydantic-%: contrib-dir-% contrib/%.yaml
pipenv run gen-pydantic -d contrib/$*/pydantic contrib/$*.yaml
contrib/%/%.graphql: contrib-dir-% contrib/%.yaml
pipenv run gen-graphql contrib/$*.yaml > contrib/$*/$*.graphql
contrib-java-%: contrib-dir-% contrib/%/schema.json
mkdir -p contrib/$*/java
jsonschema2pojo --source contrib/$*/schema.json -T JSONSCHEMA -t contrib/$*/java
contrib/%/schema.json: contrib-dir-% contrib/%.yaml
pipenv run gen-json-schema contrib/$*.yaml > $@
contrib/%/%.owl: contrib/%.yaml
pipenv run gen-owl -o $@ contrib/$*.yaml
contrib/%/%.shex: contrib-dir-% contrib/%.yaml
pipenv run gen-shex contrib/*.yaml > $@
# ----------------------------------------
# TESTS
# ----------------------------------------
test: tests
tests: biolink-model.yaml env.lock pytest # jsonschema_test
pipenv run python -m unittest discover -p 'test_*.py'
pytest: biolink/model.py
pipenv run python $<
# jsonschema_test: json-schema/biolink-model.json
# jsonschema $<
# ----------------------------------------
# CLEAN
# ----------------------------------------
clean:
rm -rf contrib/go contrib/monarch contrib/translator docs/images/* docs/*.md golr-views graphql graphviz java json json-schema ontology proto rdf shex pydantic
rm -f env.lock
pipenv --rm
# ----------------------------------------
# UTILS
# ----------------------------------------
dir-%:
mkdir -p $*
contrib-dir-%:
mkdir -p contrib/$*