Skip to content

gtcheck -i qry|gt prefix not removed #2432

@aheinzel

Description

@aheinzel

Dear all,

bcftools 1.22 gtcheck site filter -i expressions referring to either query or genotype fields using the qry or gt prefix do currently not work.

Steps to reproduce

#!/bin/bash

dummy_vcf_file=$(cat <<'EOF'
##fileformat=VCFv4.1
##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	s1
chr1	1	.	A	T	.	.	DP=10	GT	1/1
EOF
)

for fout in g.vcf.gz q.vcf.gz
do
   echo "${dummy_vcf_file}" | bgzip > "${fout}"
   tabix -p vcf "${fout}"
done


echo "##VERSION INFO"
bcftools --version


printf "\n\n##no site filter expression\n"
bcftools gtcheck -g g.vcf.gz q.vcf.gz | tail -1


printf "\n\n##site filter without prefix (filters both gt and qry)\n"
bcftools gtcheck -i "INFO/DP>10" -g g.vcf.gz q.vcf.gz | tail -1

printf "\n\n##site filter with qry prefix\n"
bcftools gtcheck -i "qry:INFO/DP>10" -g g.vcf.gz q.vcf.gz | tail -1

Output

##VERSION INFO
bcftools 1.22
Using htslib 1.22
Copyright (C) 2025 Genome Research Ltd.
License Expat: The MIT/Expat license
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


##no site filter expression
INFO:   Time required to process one record .. 0.000009 seconds
DCv2    s1      s1      0.000000e+00    0.000000e+00    1       1


##site filter without prefix (filters both gt and qry)
DCv2    s1      s1      0.000000e+00    0.000000e+00    0       0


##site filter with qry prefix
[filter.c:3463 filters_init1] Error: the tag "qry:INFO" is not defined in the VCF header

Expected behaviour

bcftools gtcheck -i "qry:INFO/DP>10" -g g.vcf.gz q.vcf.gz should run and restrict the comparison to sites with depth > 10 in the query data set.

Actual behaviour

Command errors out

[filter.c:3463 filters_init1] Error: the tag "qry:INFO" is not defined in the VCF header

Additional information

Looking at the source code it appears that the qry: prefix is not "stripped" from the filter expression before assignment to args->qry_filter_str and thus the prefix is later on included when passing the expression to filter_init.

args->qry_filter_str = optarg;

In similar cases like e.g. sample filter

else if ( !strncasecmp("qry:",optarg,4) ) args->qry_samples = optarg+4;
the pointer is incremented before assignment to remove the prefix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions