forked from nanoporetech/medaka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
226 lines (174 loc) · 7.2 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
# Builds a cache of binaries which can just be copied for CI
BINARIES=samtools minimap2 tabix bgzip spoa racon bcftools
BINCACHEDIR=bincache
$(BINCACHEDIR):
mkdir -p $(BINCACHEDIR)
OS := $(shell uname)
ifeq ($(OS), Darwin)
SEDI=sed -i '.bak'
else
SEDI=sed -i
endif
PYTHON ?= python3
binaries: $(addprefix $(BINCACHEDIR)/, $(BINARIES))
SAMVER=1.9
submodules/samtools-$(SAMVER)/Makefile:
cd submodules; \
curl -L -o samtools-${SAMVER}.tar.bz2 https://github.com/samtools/samtools/releases/download/${SAMVER}/samtools-${SAMVER}.tar.bz2; \
tar -xjf samtools-${SAMVER}.tar.bz2; \
rm samtools-${SAMVER}.tar.bz2
libhts.a: submodules/samtools-$(SAMVER)/Makefile
# this is required only to add in -fpic so we can build python module
@echo Compiling $(@F)
cd submodules/samtools-${SAMVER}/htslib-${SAMVER}/ && CFLAGS=-fpic ./configure && make
cp submodules/samtools-${SAMVER}/htslib-${SAMVER}/$@ $@
$(BINCACHEDIR)/samtools: | libhts.a $(BINCACHEDIR)
@echo Making $(@F)
# copy our hack up version of tview
${SEDI} 's/tv->is_dot = 1;/tv->is_dot = 0;/' submodules/samtools-${SAMVER}/bam_tview.c
cd submodules/samtools-${SAMVER} && make -j 4
cp submodules/samtools-${SAMVER}/$(@F) $@
$(BINCACHEDIR)/tabix: | libhts.a $(BINCACHEDIR)
cp submodules/samtools-${SAMVER}/htslib-${SAMVER}/$(@F) $@
$(BINCACHEDIR)/bgzip: | libhts.a $(BINCACHEDIR)
cp submodules/samtools-${SAMVER}/htslib-${SAMVER}/$(@F) $@
.PHONY: clean_htslib
clean_htslib:
cd submodules/samtools-${SAMVER} && make clean || exit 0
cd submodules/samtools-${SAMVER}/htslib-${SAMVER} && make clean || exit 0
MINIMAPVER=2.17
$(BINCACHEDIR)/minimap2: | $(BINCACHEDIR)
@echo Compiling $(@F)
cd submodules; \
curl -L -o minimap2-${MINIMAPVER}.tar.bz2 https://github.com/lh3/minimap2/releases/download/v${MINIMAPVER}/minimap2-${MINIMAPVER}.tar.bz2; \
tar -xjf minimap2-${MINIMAPVER}.tar.bz2; \
rm -rf minimap2-${MINIMAPVER}.tar.bz2
cd submodules/minimap2-${MINIMAPVER} && make
cp submodules/minimap2-${MINIMAPVER}/minimap2 $@
$(BINCACHEDIR)/bcftools: | $(BINCACHEDIR)
@echo Making $(@F)
if [ ! -d submodules/bcftools-v${SAMVER} ]; then \
cd submodules; \
curl -L -o bcftools-v${SAMVER}.tar.bz2 https://github.com/samtools/bcftools/releases/download/${SAMVER}/bcftools-${SAMVER}.tar.bz2; \
tar -xjf bcftools-v${SAMVER}.tar.bz2; \
cd bcftools-${SAMVER}; \
make; \
fi
cp submodules/bcftools-${SAMVER}/bcftools $@
SPOAVER=3.0.0
$(BINCACHEDIR)/spoa: | $(BINCACHEDIR)
@echo Making $(@F)
if [ ! -e submodules/spoa-v${SPOAVER}.tar.gz ]; then \
cd submodules; \
curl -L -o spoa-v${SPOAVER}.tar.gz https://github.com/rvaser/spoa/releases/download/${SPOAVER}/spoa-v${SPOAVER}.tar.gz; \
tar -xzf spoa-v${SPOAVER}.tar.gz; \
fi
cd submodules; \
cd spoa-v${SPOAVER}; \
rm -rf build; \
mkdir build; \
cd build; \
cmake -DCMAKE_BUILD_TYPE=Release -Dspoa_build_executable=ON ..; \
make;
cp submodules/spoa-v${SPOAVER}/build/bin/$(@F) $@
RACONVER=1.3.1
$(BINCACHEDIR)/racon: | $(BINCACHEDIR)
@echo Making $(@F)
@echo GCC is $(GCC)
if [ ! -e submodules/racon-v${RACONVER}.tar.gz ]; then \
cd submodules; \
curl -L -o racon-v${RACONVER}.tar.gz https://github.com/isovic/racon/releases/download/${RACONVER}/racon-v${RACONVER}.tar.gz; \
tar -xzf racon-v${RACONVER}.tar.gz; \
fi
cd submodules/racon-v${RACONVER}; \
rm -rf build; \
mkdir build; \
cd build; \
cmake -DCMAKE_BUILD_TYPE=Release ..; \
make;
cp submodules/racon-v${RACONVER}/build/bin/racon $@
$(BINCACHEDIR)/vcf2fasta: | $(BINCACHEDIR)
cd src/vcf2fasta && g++ -std=c++11 \
-I./../../submodules/samtools-${SAMVER}/htslib-${SAMVER}/ vcf2fasta.cpp \
./../../submodules/samtools-${SAMVER}/htslib-${SAMVER}/libhts.a \
-lz -llzma -lbz2 -lpthread \
-o $(@F)
cp src/vcf2fasta/$(@F) $@
scripts/mini_align:
@echo Making $(@F)
curl https://raw.githubusercontent.com/nanoporetech/pomoxis/master/scripts/mini_align -o $@
chmod +x $@
venv: venv/bin/activate
IN_VENV=. ./venv/bin/activate
venv/bin/activate:
test -d venv || virtualenv venv --python=$(PYTHON) --prompt "(medaka) "
${IN_VENV} && pip install pip --upgrade
.PHONY: check_lfs
check_lfs: venv
${IN_VENV} && python -c "from setup import check_model_lfs; check_model_lfs()"
.PHONY: install
install: venv check_lfs scripts/mini_align libhts.a | $(addprefix $(BINCACHEDIR)/, $(BINARIES))
${IN_VENV} && pip install -r requirements.txt
${IN_VENV} && MEDAKA_BINARIES=1 python setup.py install
.PHONY: test
test: install
${IN_VENV} && pip install pytest pytest-cov flake8 flake8-rst-docstrings flake8-docstrings flake8-import-order
# TODO: add these exclusions back in after outstanding PRs
${IN_VENV} && flake8 medaka --import-order-style google --application-import-names medaka,libmedaka --exclude \
medaka/test/,medaka/medaka.py \
--statistics
${IN_VENV} && pytest medaka --doctest-modules \
--cov=medaka --cov-report html --cov-report term \
--cov-fail-under=80 --cov-report term-missing
.PHONY: clean
clean: clean_htslib
(${IN_VENV} && python setup.py clean) || echo "Failed to run setup.py clean"
rm -rf libhts.a libmedaka.abi3.so venv build dist/ medaka.egg-info/ __pycache__ medaka.egg-info
find . -name '*.pyc' -delete
.PHONY: mem_check
mem_check: install pileup
${IN_VENV} && python -c "import medaka.test.test_counts as tc; tc.create_simple_bam('mem_test.bam', tc.simple_data['calls'])"
valgrind --error-exitcode=1 --tool=memcheck ./pileup mem_test.bam ref:1-8 || (ret=$$?; rm mem_test.bam* && exit $$ret)
rm -rf mem_test.bam*
pileup: libhts.a
gcc -pthread -g -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC -std=c99 -msse3 -O3 \
-Isrc -Isubmodules/samtools-1.9/htslib-1.9 \
src/medaka_common.c src/medaka_counts.c src/medaka_bamiter.c libhts.a \
-lm -lz -llzma -lbz2 -lpthread -lcurl -lcrypto \
-o $(@) -std=c99 -msse3 -O3
trim_reads: libhts.a
gcc -pthread -pg -g -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC -std=c99 -msse3 -O3 \
-Isrc -Isubmodules/samtools-1.9/htslib-1.9 \
src/medaka_common.c src/medaka_trimbam.c src/medaka_bamiter.c libhts.a \
-lz -llzma -lbz2 -lpthread -lcurl -lcrypto \
-o $(@) -std=c99 -msse3 -O3
.PHONY: wheels
wheels:
docker run -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/build-wheels.sh /io 5 6
.PHONY: build
build: pypi_build/bin/activate
IN_BUILD=. ./pypi_build/bin/activate
pypi_build/bin/activate:
test -d pypi_build || virtualenv pypi_build --python=python3 --prompt "(pypi) "
${IN_BUILD} && pip install pip --upgrade
${IN_BUILD} && pip install --upgrade pip setuptools twine wheel readme_renderer[md]
.PHONY: sdist
sdist: pypi_build/bin/activate scripts/mini_align submodules/samtools-$(SAMVER)/Makefile
${IN_BUILD} && MEDAKA_DIST=1 python setup.py sdist
# Documentation
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
DOCSRC = docs
.PHONY: docs
docs: venv
${IN_VENV} && pip install sphinx sphinx_rtd_theme sphinx-argparse
${IN_VENV} && cd $(DOCSRC) && $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
rm -rf docs/modules.rst docs/medaka.rst
@echo
@echo "Build finished. The HTML pages are in $(DOCSRC)/$(BUILDDIR)/html."
touch $(DOCSRC)/$(BUILDDIR)/html/.nojekyll