Skip to content

Commit 7d57ea1

Browse files
committed
Abstract ref_to_m5 from cram_io
This creates a new file: `ref.c`, which contains a function `m5_to_path`. This function returns a valid path to a reference from the MD5 checksum of a reference. This replaces logic in cram_io, open_trace_file and mFILE.
1 parent 99acb64 commit 7d57ea1

16 files changed

+1095
-528
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ lib*.so.*
4747
/test/test-regidx
4848
/test/test-vcf-api
4949
/test/test-vcf-sweep
50+
/test/test-ref
5051
/test/test_view
5152
/test/thrash_threads[1-6]
5253
/test/*.tmp

Makefile

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ BUILT_TEST_PROGRAMS = \
7272
test/hfile \
7373
test/sam \
7474
test/test_bgzf \
75+
test/test-ref \
7576
test/test_realn \
7677
test/test-regidx \
7778
test/test_view \
@@ -140,6 +141,7 @@ LIBHTS_OBJS = \
140141
multipart.o \
141142
probaln.o \
142143
realn.o \
144+
ref.o \
143145
regidx.o \
144146
sam.o \
145147
synced_bcf_reader.o \
@@ -158,8 +160,6 @@ LIBHTS_OBJS = \
158160
cram/cram_samtools.o \
159161
cram/cram_stats.o \
160162
cram/files.o \
161-
cram/mFILE.o \
162-
cram/open_trace_file.o \
163163
cram/pooled_alloc.o \
164164
cram/rANS_static.o \
165165
cram/sam_header.o \
@@ -174,11 +174,12 @@ cram_misc_h = cram/misc.h $(cram_os_h)
174174
cram_os_h = cram/os.h $(htslib_hts_endian_h)
175175
cram_sam_header_h = cram/sam_header.h cram/string_alloc.h cram/pooled_alloc.h $(htslib_khash_h) $(htslib_kstring_h)
176176
cram_samtools_h = cram/cram_samtools.h $(htslib_sam_h) $(cram_sam_header_h)
177-
cram_structs_h = cram/cram_structs.h $(htslib_thread_pool_h) cram/string_alloc.h cram/mFILE.h $(htslib_khash_h)
178-
cram_open_trace_file_h = cram/open_trace_file.h cram/mFILE.h
179177
bcf_sr_sort_h = bcf_sr_sort.h $(htslib_synced_bcf_reader_h) $(htslib_kbitset_h)
178+
cram_structs_h = cram/cram_structs.h $(htslib_thread_pool_h) cram/string_alloc.h $(htslib_khash_h)
179+
180180
hfile_internal_h = hfile_internal.h $(htslib_hfile_h) $(textutils_internal_h)
181181
hts_internal_h = hts_internal.h $(htslib_hts_h) $(textutils_internal_h)
182+
ref_internal_h = ref_internal.h $(htslib_hfile_h) cram/mFILE.h
182183
textutils_internal_h = textutils_internal.h $(htslib_kstring_h)
183184
thread_pool_internal_h = thread_pool_internal.h $(htslib_thread_pool_h)
184185

@@ -316,18 +317,17 @@ plugin.o plugin.pico: plugin.c config.h $(hts_internal_h) $(htslib_kstring_h)
316317
probaln.o probaln.pico: probaln.c config.h $(htslib_hts_h)
317318
realn.o realn.pico: realn.c config.h $(htslib_hts_h) $(htslib_sam_h)
318319
textutils.o textutils.pico: textutils.c config.h $(htslib_hfile_h) $(htslib_kstring_h) $(hts_internal_h)
320+
ref.o ref.pico: ref.c config.h $(htslib_kstring_h) $(htslib_bgzf_h) $(cram_h) $(cram_io_h) $(htslib_hfile_h)
319321

320322
cram/cram_codecs.o cram/cram_codecs.pico: cram/cram_codecs.c config.h $(cram_h)
321323
cram/cram_decode.o cram/cram_decode.pico: cram/cram_decode.c config.h $(cram_h) $(cram_os_h) $(htslib_hts_h)
322324
cram/cram_encode.o cram/cram_encode.pico: cram/cram_encode.c config.h $(cram_h) $(cram_os_h) $(htslib_hts_h) $(htslib_hts_endian_h)
323325
cram/cram_external.o cram/cram_external.pico: cram/cram_external.c config.h $(htslib_hfile_h) $(cram_h)
324326
cram/cram_index.o cram/cram_index.pico: cram/cram_index.c config.h $(htslib_bgzf_h) $(htslib_hfile_h) $(hts_internal_h) $(cram_h) $(cram_os_h)
325-
cram/cram_io.o cram/cram_io.pico: cram/cram_io.c config.h os/lzma_stub.h $(cram_h) $(cram_os_h) $(htslib_hts_h) $(cram_open_trace_file_h) cram/rANS_static.h $(htslib_hfile_h) $(htslib_bgzf_h) $(htslib_faidx_h) $(hts_internal_h)
327+
cram/cram_io.o cram/cram_io.pico: cram/cram_io.c config.h os/lzma_stub.h $(cram_h) $(cram_os_h) $(htslib_hts_h) $(htslib_ref_h) cram/rANS_static.h $(htslib_hfile_h) $(htslib_bgzf_h) $(htslib_faidx_h) $(hts_internal_h)
326328
cram/cram_samtools.o cram/cram_samtools.pico: cram/cram_samtools.c config.h $(cram_h) $(htslib_sam_h)
327329
cram/cram_stats.o cram/cram_stats.pico: cram/cram_stats.c config.h $(cram_h) $(cram_os_h)
328330
cram/files.o cram/files.pico: cram/files.c config.h $(cram_misc_h)
329-
cram/mFILE.o cram/mFILE.pico: cram/mFILE.c config.h $(htslib_hts_log_h) $(cram_os_h) cram/mFILE.h
330-
cram/open_trace_file.o cram/open_trace_file.pico: cram/open_trace_file.c config.h $(cram_os_h) $(cram_open_trace_file_h) $(cram_misc_h) $(htslib_hfile_h) $(htslib_hts_log_h)
331331
cram/pooled_alloc.o cram/pooled_alloc.pico: cram/pooled_alloc.c config.h cram/pooled_alloc.h $(cram_misc_h)
332332
cram/rANS_static.o cram/rANS_static.pico: cram/rANS_static.c config.h cram/rANS_static.h cram/rANS_byte.h
333333
cram/sam_header.o cram/sam_header.pico: cram/sam_header.c config.h $(htslib_hts_log_h) $(cram_sam_header_h) cram/string_alloc.h
@@ -354,7 +354,7 @@ tabix.o: tabix.c config.h $(htslib_tbx_h) $(htslib_sam_h) $(htslib_vcf_h) $(htsl
354354
#
355355
# If using MSYS, avoid poor shell expansion via:
356356
# MSYS2_ARG_CONV_EXCL="*" make check
357-
check test: $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS)
357+
check test: $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS) test_ebi_fetch
358358
test/hts_endian
359359
test/fieldarith test/fieldarith.sam
360360
test/hfile
@@ -364,6 +364,26 @@ check test: $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS)
364364
test/test-regidx
365365
cd test && REF_PATH=: ./test.pl $${TEST_OPTS:-}
366366

367+
test_ebi_fetch:
368+
@if [ "$(ENABLE_HTTP_TESTS)" = true ] ; then \
369+
export REF_CACHE=`mktemp -d` && \
370+
echo "test ref: fetching" && \
371+
test/test-ref && \
372+
echo "test ref: fetch from cache" && \
373+
test/test-ref && \
374+
rm -rf $$REF_CACHE; \
375+
export REF_CACHE=`mktemp -d` && \
376+
test/test_view -t test/xx.fa -S -C test/xx#rg.sam > test/xx#rg.tmp.cram && \
377+
echo "test view: fetching" && \
378+
test/test_view -D test/xx#rg.tmp.cram > /dev/null && \
379+
echo "test view: fetch from cache" && \
380+
test/test_view -D test/xx#rg.tmp.cram > /dev/null && \
381+
rm -rf $$REF_CACHE; \
382+
else \
383+
echo "Warning: testing of EBI fetching disabled"; \
384+
fi
385+
386+
367387
test/hts_endian: test/hts_endian.o
368388
$(CC) $(LDFLAGS) -o $@ test/hts_endian.o $(LIBS)
369389

@@ -379,6 +399,9 @@ test/sam: test/sam.o libhts.a
379399
test/test_bgzf: test/test_bgzf.o libhts.a
380400
$(CC) $(LDFLAGS) -o $@ test/test_bgzf.o libhts.a -lz $(LIBS) -lpthread
381401

402+
test/test-ref: test/test-ref.o libhts.a
403+
$(CC) $(LDFLAGS) -o $@ test/test-ref.o libhts.a $(LIBS) -lpthread
404+
382405
test/test_realn: test/test_realn.o libhts.a
383406
$(CC) $(LDFLAGS) -o $@ test/test_realn.o libhts.a $(LIBS) -lpthread
384407

@@ -406,6 +429,7 @@ test/hfile.o: test/hfile.c config.h $(htslib_hfile_h) $(htslib_hts_defs_h)
406429
test/sam.o: test/sam.c config.h $(htslib_hts_defs_h) $(htslib_sam_h) $(htslib_faidx_h) $(htslib_kstring_h)
407430
test/test_bgzf.o: test/test_bgzf.c config.h $(htslib_bgzf_h) $(htslib_hfile_h) $(hfile_internal_h)
408431
test/test-realn.o: test/test_realn.c config.h $(htslib_hts_h) $(htslib_sam_h) $(htslib_faidx_h)
432+
test/test-ref.o: test/test-ref.c $(htslib_bgzf_h)
409433
test/test-regidx.o: test/test-regidx.c config.h $(htslib_regidx_h) $(hts_internal_h)
410434
test/test_view.o: test/test_view.c config.h $(cram_h) $(htslib_sam_h)
411435
test/test-vcf-api.o: test/test-vcf-api.c config.h $(htslib_hts_h) $(htslib_vcf_h) $(htslib_kstring_h) $(htslib_kseq_h)

0 commit comments

Comments
 (0)