-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
195 lines (155 loc) · 6.42 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
# Cell Name and Marker Validator Demo
# James A. Overton <[email protected]>
#
# This Makefile is used to check the `source.tsv` spreadsheet
# against a configuration file
# to produce a normalized/ontologized output.
#
# WARN: This file contains significant whitespace, i.e. tabs!
# Ensure that your text editor shows you those characters.
#
# Requirements:
#
# - GNU Make <https://www.gnu.org/software/make/>
# - standard Unix tools: cURL, grep, sed, cut
# - Python 3
# - pytest <https://pytest.org> for running automated tests
# - Flask for web server
# - rapper <http://librdf.org/raptor/rapper.html>
# - Java Runtime Environment 8 or later
# - ROBOT <http://robot.obolibrary.org>
### GNU Make Configuration
#
# These are standard options to make Make sane:
# <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:
.SECONDARY:
### Set Up
build:
mkdir $@
cache:
mkdir $@
build/robot.jar: | build
curl -L -o $@ "https://github.com/ontodev/robot/releases/download/v1.4.0/robot.jar"
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
RDFTAB_URL := https://github.com/ontodev/rdftab.rs/releases/download/v0.1.1/rdftab-x86_64-apple-darwin
SED = sed -i.bak
else
RDFTAB_URL := https://github.com/ontodev/rdftab.rs/releases/download/v0.1.1/rdftab-x86_64-unknown-linux-musl
SED = sed -i
endif
build/rdftab: | build
curl -L -o $@ $(RDFTAB_URL)
chmod +x $@
### Project Configuration
#
# Most of the configuration is built into this Google Sheet:
# https://docs.google.com/spreadsheets/d/109FaxCDuwj9fxPqk1_haIrwo3_Y6EPU8lbNGYzmbRsU
# Download the HIPC FCS sheet
build/hipc_fcs.xlsx: | build
curl -L -o $@ "https://docs.google.com/spreadsheets/d/109FaxCDuwj9fxPqk1_haIrwo3_Y6EPU8lbNGYzmbRsU/export?format=xlsx&id=109FaxCDuwj9fxPqk1_haIrwo3_Y6EPU8lbNGYzmbRsU"
# Special markers for all valid markers
build/special_markers.tsv: build/hipc_fcs.xlsx
xlsx2csv -d tab -s 5 $< $@
### Protein Synonyms
#
# We download the Protein Ontology and extract exact synonyms.
# Download pr.owl, about 1GB!
build/pr.owl: | build
curl -k -L -o $@ "http://purl.obolibrary.org/obo/pr.owl"
# Insert pr.owl into sqlite database
build/pr.db: src/prefixes.sql build/pr.owl | build/rdftab
rm -rf $@
sqlite3 $@ < $<
./build/rdftab $@ < $(word 2,$^)
sqlite3 $@ "CREATE INDEX idx_stanza ON statements (stanza);"
sqlite3 $@ "CREATE INDEX idx_subject ON statements (subject);"
sqlite3 $@ "CREATE INDEX idx_predicate ON statements (predicate);"
sqlite3 $@ "CREATE INDEX idx_object ON statements (object);"
sqlite3 $@ "CREATE INDEX idx_value ON statements (value);"
sqlite3 $@ "ANALYZE;"
# Extract a table of `rdfs:label`s for (proper) PR terms.
build/pr-labels.tsv: build/pr.db
sqlite3 $< "SELECT DISTINCT subject, value FROM statements WHERE subject LIKE 'PR:%' AND predicate = 'rdfs:label' ORDER BY subject;" | sed 's/|/'$$'\t/g' > $@
# Extract a table of `oio:hasExactSynonym`s for (proper) PR terms.
build/pr-exact-synonyms.tsv: build/pr.db
sqlite3 $< "SELECT DISTINCT subject, value FROM statements WHERE subject LIKE 'PR:%' AND predicate = 'oio:hasExactSynonym' ORDER BY subject;" | sed 's/|/'$$'\t/g' > $@
# Extract a table of pr#PRO-short-label labels for (proper) PR terms.
build/pr-pro-short-labels.tsv: src/find-pro-short-labels.sql build/pr.db
cat $< | sqlite3 $(word 2,$^) | sed 's/|/'$$'\t/g' > $@
# Create a table of all valid markers from special markers & PR terms
build/marker.tsv: build/special_markers.tsv build/pr-labels.tsv build/pr-exact-synonyms.tsv build/pr-pro-short-labels.tsv
cat $^ | grep "\S" > $@
### Cell Ontology
#
# We use the Cell Ontology for its logical definitions.
# Download cl.owl, about 6MB, no imports.
build/cl.owl: | build
curl -k -L -o $@ "http://purl.obolibrary.org/obo/cl.owl"
# Inherit membrane parts
build/cl-plus.owl: build/cl.owl src/add-membrane-parts-to-children.ru | build/robot.jar
java -jar $| query --input $< --update $(word 2,$^) --output $@
# Insert pr.owl into sqlite database
build/cl.db: src/prefixes.sql build/cl-plus.owl | build/rdftab
rm -rf $@
sqlite3 $@ < $<
./build/rdftab $@ < $(word 2,$^)
sqlite3 $@ "CREATE INDEX idx_stanza ON statements (stanza);"
sqlite3 $@ "CREATE INDEX idx_subject ON statements (subject);"
sqlite3 $@ "CREATE INDEX idx_predicate ON statements (predicate);"
sqlite3 $@ "CREATE INDEX idx_object ON statements (object);"
sqlite3 $@ "CREATE INDEX idx_value ON statements (value);"
sqlite3 $@ "ANALYZE;"
# Extract a table of `rdfs:label`s for (proper) CL terms.
build/cl-labels.tsv: build/cl.db
sqlite3 $< "SELECT DISTINCT subject, value FROM statements WHERE subject LIKE 'CL:0%' AND predicate = 'rdfs:label' ORDER BY subject;" | sed 's/|/'$$'\t/g' > $@
# Extract a table of `oio:hasExactSynonym`s for (proper) CL terms.
build/cl-exact-synonyms.tsv: build/cl.db
sqlite3 $< "SELECT DISTINCT subject, value FROM statements WHERE subject LIKE 'CL:0%' AND predicate = 'oio:hasExactSynonym' ORDER BY subject;" | sed 's/|/'$$'\t/g' > $@
# Create a table of all valid cell names
build/cell.tsv: build/cl-labels.tsv build/cl-exact-synonyms.tsv
echo -e "ID\tName" > $@
cat $^ >> $@
# Create a table of membrane parts
build/cl-levels.tsv: build/cl.db
python3 -m gizmos.export -d $< \
-w "subject LIKE 'CL:%'" \
-p CURIE \
-p obo:RO_0002104 \
-p obo:cl#lacks_plasma_membrane_part \
-p obo:cl#has_high_plasma_membrane_amount \
-p obo:cl#has_low_plasma_membrane_amount \
-V CURIE > $@
### General Tasks
# Check python code style
# || true is appended to force make to ignore the exit code from pycodestyle
pystyle:
pycodestyle --max-line-length=100 --ignore E129,E126,E121,E111,E114,W504 src/*.py | grep -v "indentation is not a multiple of four" || true
# Run the python delinter (make sure pyflakes is for python version 3)
pydelint:
pyflakes src/*.py
test: build/valid-out.tsv build/invalid-out.tsv
build/empty.tsv: | build
touch $@
build/valid-out.tsv: src/validate.py build/cell.tsv build/cl-levels.tsv build/marker.tsv examples/valid.tsv | build build/empty.tsv
python3 $^ > $@
diff build/valid-out.tsv build/empty.tsv
build/invalid-out.tsv: src/validate.py build/cell.tsv build/cl-levels.tsv build/marker.tsv examples/invalid.tsv | build
python3 $^ > $@
[ -s $@ ]
# Remove spreadsheets, keep big PRO OWL file
.PHONY: clean
clean:
rm -f build/*.db build/*.tsv
# Remove build and cache directories
.PHONY: clobber
clobber:
rm -rf build cache
.PHONY: all
all: build/cell.tsv build/marker.tsv build/cl-levels.tsv