Skip to content

bcftools merge --force-samples can fail #1081

Closed
@freeseek

Description

The following code reproduces the error:

(echo "##fileformat=VCFv4.2"
echo -e "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tA\t2:A") | bgzip > A.vcf.gz
tabix -f A.vcf.gz

(echo "##fileformat=VCFv4.2"
echo -e "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tA") | bgzip > B.vcf.gz
tabix -f B.vcf.gz

bcftools merge A.vcf.gz B.vcf.gz --force-samples

with error:

[E::bcf_hdr_add_sample_len] Duplicated sample name '2:A'
bcftools: vcfmerge.c:683: maux_init: Assertion `n_smpl==bcf_hdr_nsamples(args->out_hdr)' failed.
Aborted (core dumped)

My understanding is that the resolution of duplicate sample names is not clever enough to assign a new valid name all the time. It seems like bcftools merge --force-samples is changing the ID of A to 2:A but this sample already exists in the VCF causing the renaming attempt to fail.

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