Skip to content

Commit d98d58f

Browse files
committed
Fix BCF output
The command `convert --gvcf2vcf` was not filling the REF allele when BCF was output because VCF API was not used, the alleles were rewritten directly. That works for VCF, but not BCF output. Fixes #243, finally
1 parent 25aff97 commit d98d58f

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Changes affecting specific commands:
1212
- New experimental plugin for scoring variants and assess site noisiness (allelic frequency profiles)
1313
from a large number of unaffected parental samples
1414

15+
* bcftools convert
16+
17+
- The command `convert --gvcf2vcf` was not filling the REF allele when BCF was output (#243)
18+
1519
* bcftools query
1620

1721
- The functions used in -i/-e filtering expressions (such as SUM, MEDIAN, etc) can be

test/test.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,7 @@ sub test_vcf_convert_gvcf
15411541
my ($opts,%args) = @_;
15421542
bgzip_tabix_vcf($opts,$args{in});
15431543
test_cmd($opts,%args,cmd=>"$$opts{bin}/bcftools convert --no-version $args{args} -f $$opts{path}/$args{fa} $$opts{tmp}/$args{in}.vcf.gz");
1544+
test_cmd($opts,%args,cmd=>"$$opts{bin}/bcftools convert --no-version $args{args} -f $$opts{path}/$args{fa} $$opts{tmp}/$args{in}.vcf.gz -Ou | $$opts{bin}/bcftools view --no-version");
15441545
test_cmd($opts,%args,cmd=>"$$opts{bin}/bcftools view -Ob $$opts{tmp}/$args{in}.vcf.gz | $$opts{bin}/bcftools convert $args{args} -f $$opts{path}/$args{fa} | grep -v ^##bcftools");
15451546
}
15461547
sub test_vcf_convert_tsv2vcf

vcfconvert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* vcfconvert.c -- convert between VCF/BCF and related formats.
22
3-
Copyright (C) 2013-2023 Genome Research Ltd.
3+
Copyright (C) 2013-2024 Genome Research Ltd.
44
55
Author: Petr Danecek <[email protected]>
66
@@ -1583,6 +1583,7 @@ static void gvcf_to_vcf(args_t *args)
15831583
char *ref = faidx_fetch_seq(args->ref, (char*)bcf_hdr_id2name(hdr,line->rid), line->pos, line->pos, &len);
15841584
if ( !ref ) error("faidx_fetch_seq failed at %s:%"PRId64"\n", bcf_hdr_id2name(hdr,line->rid),(int64_t) line->pos+1);
15851585
strncpy(line->d.allele[0],ref,len);
1586+
bcf_update_alleles(hdr,line,(const char**)line->d.allele,line->n_allele);
15861587
if ( bcf_write(out_fh,hdr,line)!=0 ) error("[%s] Error: cannot write to %s\n", __func__,args->outfname);
15871588
free(ref);
15881589
}

0 commit comments

Comments
 (0)