Skip to content

Commit

Permalink
Increase test data creation idempotency
Browse files Browse the repository at this point in the history
Use --force arguments for tabix and bcftools index to rebuild indexes
even if they already exist rather than failing. This should not occur
anyway as the Makefile rules will avoid rebuilding if the target is
already up-to-date -- other than in the courageous scenario of parallel
test running in which multiple makes may be running simultaneously.

There are still likely race conditions in such scenarios, and it would be
sensible to avoid them entirely by pre-creating the test data sequentially
by running `make -C tests/tabix_data` et al outside any parallelisation.
  • Loading branch information
jmarshall committed May 13, 2024
1 parent 36a0304 commit 43c1066
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/VariantFile_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def genomes_data():
fn_small = "small.vcf.gz"
if not os.path.exists(fn_small):
os.system("bcftools view {} | head -n 10000 | bgzip > {}".format(fn, fn_small))
os.system("tabix -p vcf {}".format(fn_small))
os.system("tabix -f -p vcf {}".format(fn_small))

return fn_small

Expand Down
6 changes: 3 additions & 3 deletions tests/cbcf_data/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ all.stamp: $(VCFGZ) $(BCF)

%.vcf.gz: %.vcf
bgzip < $< > $@
tabix -p vcf $@ # create tbi index
bcftools index $@ # create csi index
tabix -f -p vcf $@ # create tbi index
bcftools index -f $@ # create csi index

%.bcf: %.vcf.gz
bcftools view -O b $< -o $@
bcftools index $@
bcftools index -f $@

example_empty.bcf: example_empty.vcf.gz
touch $@
Expand Down
8 changes: 4 additions & 4 deletions tests/tabix_data/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ all.stamp: $(DERIVED_FILES)
bgzip -c $< > $@

%.gff2.gz.tbi: %.gff2.gz
tabix -p gff $<
tabix -f -p gff $<

%.gff3.gz.tbi: %.gff3.gz
tabix -p gff $<
tabix -f -p gff $<

%.gtf.gz.tbi: %.gtf.gz
tabix -p gff $<
tabix -f -p gff $<

%.gz.tbi: %.gz
tabix -p $(subst .,,$(suffix $*)) $<
tabix -f -p $(subst .,,$(suffix $*)) $<

clean:
-rm -f all.stamp $(DERIVED_FILES)

0 comments on commit 43c1066

Please sign in to comment.