forked from biolink/biolink-model
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
213 lines (157 loc) · 6.29 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
# 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
shex: biolink-model.shex biolink-modeln.shex biolink-model.shexj biolink-modeln.shexj
json-schema: json-schema/biolink-model.json
build: python docs/index.md gen-golr-views biolink-model.graphql gen-graphviz java context.jsonld contextn.jsonld \
json-schema/biolink-model.json biolink-model.owl biolink-model.proto biolink-model.shex biolink-model.ttl
# 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
pipenv run gen-py-classes $< > tmp.py && pipenv run python tmp.py && (pipenv run comparefiles tmp.py $@ && cp $@ $@-PREV && cp tmp.py $@); rm tmp.py
# ~~~~~~~~~~~~~~~~~~~~
# DOCS
# ~~~~~~~~~~~~~~~~~~~~
docs/index.md: biolink-model.yaml env.lock
pipenv run gen-markdown --dir docs $(imgflags) $<
# ~~~~~~~~~~~~~~~~~~~~
# Solr
# ~~~~~~~~~~~~~~~~~~~~
gen-golr-views: biolink-model.yaml dir-golr-views env.lock
pipenv run gen-golr-views -d golr-views $<
# ~~~~~~~~~~~~~~~~~~~~
# 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
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
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 $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# Ontology
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.owl: biolink-model.yaml env.lock
pipenv run gen-owl -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/biolink/biolinkml/context.jsonld $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# ShEx
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.shex: biolink-model.yaml
pipenv run gen-shex $< > $@
biolink-modeln.shex: biolink-model.yaml
pipenv run gen-shex --metauris $< > $@
biolink-model.shexj: biolink-model.yaml
pipenv run gen-shex --format json $< > $@
biolink-modeln.shexj: biolink-model.yaml
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/%/%.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
# ----------------------------------------
tests: biolink-model.yaml env.lock
pipenv run python -m unittest discover -p 'test_*.py'
# ----------------------------------------
# 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
rm -f env.lock
pipenv --rm
# ----------------------------------------
# UTILS
# ----------------------------------------
dir-%:
mkdir -p $*
contrib-dir-%:
mkdir -p contrib/$*