bcftools --targets-file fails to read the targets

Open
#690 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c

Research direction

Reproduce the commands with test.vcf, test.vcf.gz, and test.bcf, then trace the --targets-file handling and the index-loading path implicated by the tbx_index_load2 and bcf_sr_regions_init errors. Compare the BCF and compressed-VCF cases and add a regression test showing that a BCF targets file is handled correctly.

Written by the indexing model from the issue text.

Description

enhancement

Let's say I generate a minimal VCF file:

echo -e "##fileformat=VCFv4.2
##contig=<ID=20,length=63025520>
#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO
20\t1\t.\tA\tC\t0\t.\t." > test.vcf

And let's say I create a compressed/index version of it:

bcftools view --no-version test.vcf -Oz -o test.vcf.gz
bcftools index test.vcf.gz

Then everything seems to work just fine:

$ bcftools view --no-version test.vcf --targets-file test.vcf.gz
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##contig=<ID=20,length=63025520>
#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO
20	1	.	A	C	0	.	.

However, if I create a binary compressed version:

bcftools view --no-version test.vcf -Ob -o test.bcf
bcftools index test.bcf

I get the following error:

$ bcftools view --no-version test.vcf --targets-file test.bcf
[E::tbx_index_load2] Invalid index header for test.bcf
[E::bcf_sr_regions_init] Could not parse the file test.bcf, using the columns 1,2[,-1]
Failed to read the targets: test.bcf

The error is reproducible with version:

1.6-9-g46f17f5-dirty (using htslib 1.6-3-g75decb8)
Dominant language
C
Stars
891
Forks
277
Avg merge
2d 23h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from samtools/bcftools

All issues in samtools/bcftools

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.