Skip to content

Commit 49aa0b0

Browse files
committed
Apply mask even if the VCF has no notion about the chromosome
When `contig` lines are not present in the VCF and the file does not contain any variants, the mask region was not applied. Fixes #1592
1 parent dd337cc commit 49aa0b0

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ Changes affecting specific commands:
5656
`--ligate-warn` option (previously this was the default). To keep such
5757
sites, use the new `--ligate-force` option (#1567).
5858

59+
* bcftools consensus:
60+
61+
- Apply mask even when the VCF has no notion about the chromosome. It
62+
was possible to encounter this problem when `contig` lines were not
63+
present in the VCF header and no variants were called on that chromosome
64+
(#1592)
65+
5966
* bcftools +contrast:
6067

6168
- support for chunking within map/reduce framework allowing to collect

consensus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ static void consensus(args_t *args)
975975
// determine if uppercase or lowercase is used in this fasta file
976976
if ( args->fa_case==-1 ) args->fa_case = toupper(str.s[0])==str.s[0] ? 1 : 0;
977977

978-
if ( args->mask && args->rid>=0) mask_region(args, str.s, str.l);
978+
if ( args->mask ) mask_region(args, str.s, str.l);
979979
kputs(str.s, &args->fa_buf);
980980

981981
bcf1_t **rec_ptr = NULL;

test/consensus.17.bed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1 0 59
2+
2 0 60
3+
3 0 30
4+
4 31 62

test/consensus.17.vcf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
##fileformat=VCFv4.2
2+
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
3+
##reference=file://some/path/human_g1k_v37.fasta
4+
##contig=<ID=1,assembly=b37,length=249250621>
5+
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA001

test/consensus17.1.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
>1
2+
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
3+
>2
4+
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
5+
>3
6+
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNATAACCTACGTATCAACTAAAGTGGTTGTT
7+
C
8+
>4
9+
CCCCTACCATATGTGACATATAAAAAAGAACNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
10+
NN

test/test.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@
693693
test_vcf_consensus($opts,in=>'consensus.15',out=>'consensus.17.out',fa=>'consensus.15.fa',args=>'-H I --mark-ins lc --mark-snv lc');
694694
test_vcf_consensus($opts,in=>'consensus.16',out=>'consensus.18.out',fa=>'consensus.fa',args=>'-I');
695695
test_vcf_consensus($opts,in=>'consensus.16',out=>'consensus.18.out',fa=>'consensus.fa',args=>'-H I');
696+
test_vcf_consensus($opts,in=>'consensus.17',out=>'consensus17.1.out',fa=>'consensus2.fa',mask=>'consensus.17.bed',args=>'-M N');
696697
test_mpileup($opts,in=>[qw(mpileup.1 mpileup.2 mpileup.3)],out=>'mpileup/mpileup.1.out',args=>q[-r17:100-150],test_list=>1);
697698
test_mpileup($opts,in=>[qw(mpileup.1 mpileup.2 mpileup.3)],out=>'mpileup/mpileup.2.out',args=>q[-a DP,DV -r17:100-600]); # test files from samtools mpileup test suite
698699
test_mpileup($opts,in=>[qw(mpileup.1)],out=>'mpileup/mpileup.3.out',args=>q[-B --ff 0x14 -r17:1050-1060]); # test file converted to vcf from samtools mpileup test suite

0 commit comments

Comments
 (0)