Skip to content

Commit

Permalink
norm: avoid regression when ALT is a spanning deletion *
Browse files Browse the repository at this point in the history
* add tests for #452 and #439

Resolves #452
  • Loading branch information
mcshane committed Jul 1, 2016
1 parent da5e8a0 commit e43ca8c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions test/norm.out
Expand Up @@ -53,5 +53,6 @@
20 275 . A C,G 999 PASS INDEL;AN=2;AC=0,2 GT:PL:DP:FGF:FGI:FGS:FSTR 2:0,0,0:0:1e+06,2e+06,3e+06:1111,2222,3333:A,BB,CCC:WORD 2:0,0,0:0:1e+06,2e+06,3e+06:1111,2222,3333:A,BB,CCC:WORD
3 10 . GTGGAC GTGGACACAC,GTGGACAC,GTGGACACACAC,GTGG,GTGGACACACACAC,ATGGACACACAC 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
3 17 . CA C 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
4 25 . T TT,* 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
4 36 . TC C,TT,TTC 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
5 21 . A AAG 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
2 changes: 2 additions & 0 deletions test/norm.vcf
Expand Up @@ -54,4 +54,6 @@
3 10 . GTGGAC GTGGACACAC,GTGGACAC,GTGGACACACAC,GTGG,GTGGACACACACAC,ATGGACACACAC 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
3 15 . CACA CAC 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
4 21 . ATTTTTTTTTTTTTTTC ATTTTTTTTTTTTTTC,ATTTTTTTTTTTTTTTT,ATTTTTTTTTTTTTTTTC 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
4 25 . T TT,* 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
4 37 . C I 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
5 22 . A AGA 999 PASS INDEL;AN=0 GT:DP ./.:0 ./.:0
2 changes: 1 addition & 1 deletion test/test.pl
Expand Up @@ -95,7 +95,7 @@
test_vcf_query($opts,in=>'missing',out=>'query.23.out',args=>q[-e'ISTR="."' -f'%POS %ISTR\\n']);
test_vcf_query($opts,in=>'missing',out=>'query.22.out',args=>q[-e'ISTR!="."' -f'%POS %ISTR\\n']);
test_vcf_query($opts,in=>'missing',out=>'query.24.out',args=>q[-i'FILTER="q11"' -f'%POS %ISTR\\n']);
test_vcf_norm($opts,in=>'norm',out=>'norm.out',fai=>'norm');
test_vcf_norm($opts,in=>'norm',out=>'norm.out',fai=>'norm',args=>'-cx');
test_vcf_norm($opts,in=>'norm.split',out=>'norm.split.out',args=>'-m-');
test_vcf_norm($opts,in=>'norm.split.2',out=>'norm.split.2.out',args=>'-m-');
test_vcf_norm($opts,in=>'norm.split',fai=>'norm',out=>'norm.split.and.norm.out',args=>'-m-');
Expand Down
10 changes: 6 additions & 4 deletions vcfnorm.c
Expand Up @@ -259,10 +259,11 @@ static void fix_dup_alt(args_t *args, bcf1_t *line)
if ( changed ) bcf_update_genotypes(args->hdr,line,gts,ngts);
}

#define ERR_DUP_ALLELE -2
#define ERR_REF_MISMATCH -1
#define ERR_OK 0
#define ERR_SYMBOLIC 1
#define ERR_DUP_ALLELE -2
#define ERR_REF_MISMATCH -1
#define ERR_OK 0
#define ERR_SYMBOLIC 1
#define ERR_SPANNING_DELETION 2

static int realign(args_t *args, bcf1_t *line)
{
Expand Down Expand Up @@ -304,6 +305,7 @@ static int realign(args_t *args, bcf1_t *line)
for (i=0; i<line->n_allele; i++)
{
if ( line->d.allele[i][0]=='<' ) return ERR_SYMBOLIC; // symbolic allele
if ( line->d.allele[i][0]=='*' ) return ERR_SPANNING_DELETION; // spanning deletion
if ( has_non_acgtn(line->d.allele[i],0) )
{
if ( args->check_ref==CHECK_REF_EXIT )
Expand Down

0 comments on commit e43ca8c

Please sign in to comment.