-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
252 lines (214 loc) · 8.99 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
OS := $(shell uname)
ifeq ($(OS), Darwin)
# mainly for dev builds using homebrew things
EXTRA_LDFLAGS ?= -L$(shell brew --prefix [email protected])/lib
ARGP ?= $(shell brew --prefix argp-standalone)/lib/libargp.a
ARGP_INC ?= -I$(shell brew --prefix argp-standalone)/include
CFLAGS ?= -fpic -O3 ${ARGP_INC}
ZCAT = "gzcat"
else
ARGP ?=
ARGP_INC ?=
CFLAGS ?= -fpic -msse3 -O3 ${ARGP_INC}
ZCAT = "zcat"
endif
VALGRIND ?= valgrind
CC ?= gcc
STATIC_HTSLIB ?= htslib/libhts.a
EXTRA_CFLAGS ?=
EXTRA_LDFLAGS ?=
EXTRA_LIBS ?=
EXTRA_LIBS ?=
HTS_CONF_ARGS ?=
NOTHREADS ?=
ifeq ($(NOTHREADS), 1)
CFLAGS += -DNOTHREADS
endif
# we can't do pedantic because min/max macros lead to:
# "ISO C forbids braced-groups within expressions [-Werror=pedantic]"
ifeq ($(shell $(CC) --version | grep clang | wc -l), 0)
WARNINGS = -Werror -Wall -Wextra -Wno-incompatible-pointer-types
else
WARNINGS = -Werror -Wall -Wextra -Wpedantic -Wno-language-extension-token -Wno-gnu-statement-expression -Wno-incompatible-function-pointer-types
endif
.PHONY: default
default: fastcat bamstats bamindex
htslib/libhts.a:
@echo Compiling $(@F)
cd htslib/ \
&& autoheader \
&& autoconf \
&& autoreconf --install \
&& CFLAGS="$(CFLAGS) $(EXTRA_CFLAGS)" ./configure $(HTS_CONF_ARGS) \
&& make -j 4
zlib-ng/libz.a:
@echo Compiling $(@F)
cd zlib-ng/ \
&& CFLAGS="$(CFLAGS) $(EXTRA_CFLAGS)" ./configure --zlib-compat \
&& make -j 4 libz.a
src/%.o: src/%.c
$(CC) -Isrc -Ihtslib -c -pthread $(WARNINGS) -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
$(CFLAGS) $(EXTRA_CFLAGS) $^ -o $@
fastcat: src/fastcat/main.o src/fastcat/args.o src/fastcat/writer.o src/fastqcomments.o src/common.o src/stats.o src/kh_counter.o $(STATIC_HTSLIB) zlib-ng/libz.a
$(CC) -Isrc $(WARNINGS) -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
$(CFLAGS) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS) \
$^ $(ARGP) \
-lm $(EXTRA_LIBS) \
-o $@
bamstats: src/bamstats/main.o src/bamstats/args.o src/bamstats/readstats.o src/bamstats/bamiter.o src/fastqcomments.o src/common.o src/stats.o src/kh_counter.o $(STATIC_HTSLIB)
$(CC) -Isrc -Ihtslib $(WARNINGS) -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
$(CFLAGS) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS) \
$^ $(ARGP) \
-lm -lz -llzma -lbz2 -lpthread -lcurl -lcrypto $(EXTRA_LIBS) \
-o $@
bamindex: src/bamindex/main.o src/bamindex/build_main.o src/bamindex/fetch_main.o src/bamindex/dump_main.o src/bamindex/index.o $(STATIC_HTSLIB)
$(CC) -Isrc -Ihtslib $(WARNINGS) -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
$(CFLAGS) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS) \
$^ $(ARGP) \
-lm -lz -llzma -lbz2 -lpthread -lcurl -lcrypto $(EXTRA_LIBS) \
-o $@
test/rg_parse: test/rg_parse.o src/common.o
$(CC) -Isrc $(WARNINGS) -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
$(CFLAGS) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS) \
$^ $(ARGP) \
-lm $(EXTRA_LIBS) \
-o $@
.PHONY: clean
clean:
rm -rf fastcat bamstats bamindex src/fastcat/*.o src/bamstats/*.o src/bamindex/*.o src/*.o
.PHONY: clean_htslib
clean_htslib:
cd htslib && make clean
.PHONY: mem_check_fastcat
mem_check_fastcat: fastcat
rm -rf fastcat-histograms
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./fastcat test/data/*.fastq.gz > /dev/null
.PHONY: mem_check_fastcat_demultiplex
mem_check_fastcat_demultiplex: fastcat
rm -rf demultiplex
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./fastcat test/data/*.fastq.gz --demultiplex demultiplex > /dev/null
.PHONY: mem_check_bamstats
mem_check_bamstats: bamstats
rm -rf bamstats-histograms
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./bamstats test/bamstats/400ecoli.bam
.PHONY: mem_check_bamstats_duplex
mem_check_bamstats_duplex: bamstats
[ -d bamstats-histograms ] && rm -rf bamstats-histograms
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./bamstats test/bamstats/310dx.bam
.PHONY: mem_check_bamindex-build
mem_check_bamindex-build: bamindex
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./bamindex build test/bamindex/400.bam
test/bamindex/400.bam.bci: bamindex
./bamindex dump test/bamindex/400.bam.bci
.PHONY: mem_check_bamindex-dump
mem_check_bamindex-dump: bamindex test/bamindex/400.bam.bci
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./bamindex dump test/bamindex/400.bam.bci
.PHONY: mem_check_bamindex-fetch
mem_check_bamindex-fetch: bamindex test/bamindex/400.bam.bci
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes -s \
./bamindex fetch test/bamindex/400.bam --chunk 5 > /dev/null
.PHONY: mem_check_bamindex
mem_check_bamindex: mem_check_bamindex-build mem_check_bamindex-dump mem_check_bamindex-fetch
.PHONY: test_bamstats_NM
test_bamstats_NM: bamstats
if [ -d test/test-tmp ]; then rm -r test/test-tmp; fi
mkdir test/test-tmp && \
cd test/test-tmp && \
../../bamstats ../bamstats_badNM/test.sam 2> err || grep "appears to contain implausible alignment information" err && rm -rf bamstats-histograms && \
../../bamstats ../bamstats_zeroNM/test.sam
rm -r test/test-tmp
.PHONY: test_bamstats_polya
test_bamstats_polya: bamstats
if [ -d test/test-tmp ]; then rm -r test/test-tmp; fi
mkdir test/test-tmp && \
cd test/test-tmp && \
../../bamstats ../bamstats/RCS-100A.bam --poly_a > /dev/null && \
diff bamstats-histograms/polya.hist ../bamstats/RCS-100A.bam.polya.hist
rm -r test/test-tmp
.PHONY: regression_test_fastcat
regression_test_fastcat: fastcat
if [ -d test/test-tmp ]; then rm -r test/test-tmp; fi
mkdir test/test-tmp && \
cd test/test-tmp && \
../../fastcat ../data -s sample --reheader -f per-file-stats.tsv -r per-read-stats.tsv \
> concat.sorted.fastq && \
bash -c 'diff <(sort per-file-stats.tsv) \
<(sort ../fastcat_expected_results/per-file-stats.tsv)' && \
bash -c 'diff <(sort per-read-stats.tsv) \
<(sort ../fastcat_expected_results/per-read-stats.tsv)' && \
bash -c "diff \
<(cat concat.sorted.fastq | paste -d '|' - - - - | sort | tr '|' '\n') \
<(${ZCAT} ../fastcat_expected_results/concat.reheader.sorted.fastq.gz | \
paste -d '|' - - - - | sort | tr '|' '\n')" && \
rm -rf fastcat-histograms/ && \
../../fastcat ../data -s sample -f per-file-stats.tsv -r per-read-stats.tsv \
> concat.sorted.fastq && \
bash -c "diff \
<(cat concat.sorted.fastq | paste -d '|' - - - - | sort | tr '|' '\n') \
<(${ZCAT} ../fastcat_expected_results/concat.sorted.fastq.gz | \
paste -d '|' - - - - | sort | tr '|' '\n')"
rm -r test/test-tmp
# samtools fastq -T'*' sam2fastq/wf_basecalling_demo.sam > sam2fastq/wf_basecalling_demo.fastq
.PHONY: regression_test_sam_to_fastcat
regression_test_sam_to_fastcat: fastcat
if [ -d test/test-tmp ]; then rm -r test/test-tmp; fi
mkdir test/test-tmp && \
cd test/test-tmp && \
../../fastcat ../sam2fastq/wf_basecalling_demo.fastq -s sample -H \
--histograms fastcat-histograms1 -r per-read-stats.fastcat_once.tsv -f per-file-stats.fastcat_once.tsv \
> wf_basecalling_demo.fastcat_once.fastq && \
../../fastcat wf_basecalling_demo.fastcat_once.fastq -s sample -H \
--histograms fastcat-histograms2 -r per-read-stats.fastcat_twice.tsv -f per-file-stats.fastcat_twice.tsv \
> wf_basecalling_demo.fastcat_twice.fastq && \
diff wf_basecalling_demo.fastcat_once.fastq wf_basecalling_demo.fastcat_twice.fastq && \
bash -c 'diff <(sort -d per-file-stats.fastcat_once.tsv | sed 's,../sam2fastq/wf_basecalling_demo.fastq,FILE,') \
<(sort -d per-file-stats.fastcat_twice.tsv | sed 's,wf_basecalling_demo.fastcat_once.fastq,FILE,')' && \
bash -c 'diff <(sort per-read-stats.fastcat_once.tsv | sed 's,../sam2fastq/wf_basecalling_demo.fastq,FILE,') \
<(sort per-read-stats.fastcat_twice.tsv | sed 's,wf_basecalling_demo.fastcat_once.fastq,FILE,')'
rm -r test/test-tmp
.PHONY: regression_test_parse_rg_fastq
regression_test_parse_rg_fastq: fastcat
if [ -d test/test-tmp ]; then rm -r test/test-tmp; fi
mkdir test/test-tmp && \
cd test/test-tmp && \
for i in ../parse_rg/*.fastq.gz; do \
echo $$i; \
../../fastcat $$i --histograms hist -l rg \
> /dev/null; \
diff rg $$i.callers; \
rm -rf hist rg; \
done;
rm -r test/test-tmp
.PHONY: regression_test_parse_rg_bam
regression_test_parse_rg_bam: bamstats
if [ -d test/test-tmp ]; then rm -r test/test-tmp; fi
mkdir test/test-tmp && \
cd test/test-tmp && \
for i in ../parse_rg/*.bam; do \
../../bamstats $$i --histograms hist -l rg \
> /dev/null; \
diff rg $$i.callers; \
rm -rf hist rg; \
done;
rm -r test/test-tmp
.PHONY: regression_test_parse_rd_fastq
regression_test_parse_rd_fastq: fastcat
if [ -d test/test-tmp ]; then rm -r test/test-tmp; fi
mkdir test/test-tmp && \
cd test/test-tmp && \
for i in ../parse_rd/*.fastq; do \
echo $$i; \
../../fastcat $$i --histograms hist -i rd > /dev/null; \
diff rd $$i.runids; \
rm -rf hist rg; \
done;
rm -r test/test-tmp
.PHONY: regression_test_rg_parsing
regression_test_rg_parsing: test/rg_parse
./test/rg_parse