Skip to content

Commit

Permalink
Improve the recent consensus fixes.
Browse files Browse the repository at this point in the history
Resolves samtools#938
  • Loading branch information
pd3 committed Dec 27, 2018
1 parent 27c9e5d commit 9589876
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion consensus.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,11 @@ static void apply_variant(args_t *args, bcf1_t *rec)
// Can be still OK iff this is an insertion (and which does not follow another insertion, see #888).
// This still may not be enough for more complicated cases with multiple duplicate positions
// and other types in between. In such case let the user normalize the VCF and remove duplicates.
if ( !(bcf_get_variant_type(rec,ialt) & VCF_INDEL) || rec->d.var[ialt].n <= 0 || args->prev_is_insert )
int overlap = 0;
if ( rec->pos < args->fa_frz_pos || !(bcf_get_variant_type(rec,ialt) & VCF_INDEL) ) overlap = 1;
else if ( rec->d.var[ialt].n <= 0 || args->prev_is_insert ) overlap = 1;

if ( overlap )
{
fprintf(stderr,"The site %s:%d overlaps with another variant, skipping...\n", bcf_seqname(args->hdr,rec),rec->pos+1);
return;
Expand Down
5 changes: 5 additions & 0 deletions test/consensus6.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
>NW_019171628.1:64330-64531
GAGAAAGAGAGAGAGAGCATGCTTCCAAACCCTTTGTTCTTTTTCTTCTGAAGAGAAGGT
GACCTGGTTTTGAAACACTGGCTACAGCAAATCACTCAGAACACACACACACACAACACA
CACACACACACACACACACACACACACACTCTCAGAACACACACACACACACGCACTTAC
ATTTAGCCTTGGTGTTACTAT
5 changes: 5 additions & 0 deletions test/consensus6.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
>NW_019171628.1:64330-64531
GAGAAAGAGAGAGAGAGAGCATGCTTCCAAACCCTTTGTTCTTTTTCTTCTGAAGAGAAG
GTGACCTGGTTTTGAAACACTGGCTACAGCAAATCACTCAGAACACACACACACACACAC
ACACACACACACACACACACACTCTCAGAACACACACACACACACGCACTTACATTTAGC
CTTGGTGTTACTAT
8 changes: 8 additions & 0 deletions test/consensus6.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##fileformat=VCFv4.2
##reference=consensus6.fa
##contig=<ID=NW_019171628.1,length=354362>
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT sample
NW_019171628.1 64334 . A AAG 159 . . GT 1/1
NW_019171628.1 64435 . CACACACACA C 170 . . GT 1/1
NW_019171628.1 64443 . C CACTCAG 72 . . GT 1/1
1 change: 1 addition & 0 deletions test/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@
test_vcf_consensus($opts,in=>'consensus3',out=>'consensus3.2.out',fa=>'consensus2.fa',args=>'-H 2 -M "?" -p xx_');
test_vcf_consensus($opts,in=>'consensus4',out=>'consensus4.out',fa=>'consensus2.fa',args=>'');
test_vcf_consensus($opts,in=>'consensus5',out=>'consensus5.out',fa=>'consensus5.fa',args=>'--haplotype LA');
test_vcf_consensus($opts,in=>'consensus6',out=>'consensus6.out',fa=>'consensus6.fa',args=>'');
test_mpileup($opts,in=>[qw(mpileup.1 mpileup.2 mpileup.3)],out=>'mpileup/mpileup.1.out',args=>q[-r17:100-150],test_list=>1);
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
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
Expand Down

0 comments on commit 9589876

Please sign in to comment.