Skip to content

Commit a662866

Browse files
pd3daviesrob
authored andcommitted
Fix a bug in breakend detection
it was incorrectly assumed that the ALT allele is of equal length to REF allele, but the VCF specification allows breakend insertions, such as C > CAGTNNNNNCA[2:321682[ Resolves samtools/bcftools#2317
1 parent c384c81 commit a662866

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

test/test-bcf_set_variant_type.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ static void test_bcf_set_variant_type(void)
9191
{
9292
error("[16:33625444[N was not detected as a breakend");
9393
}
94+
95+
bcf_set_variant_type("T", "]chrB:123]AGTNNNNNCAT", &var3d);
96+
if ( var3d.type != VCF_BND)
97+
{
98+
error("]chrB:123]AGTNNNNNCAT was not detected as a breakend");
99+
}
100+
bcf_set_variant_type("C", "CAGTNNNNNCA[chrA:321[", &var3d);
101+
if ( var3d.type != VCF_BND)
102+
{
103+
error("CAGTNNNNNCA[chrA:321[ was not detected as a breakend");
104+
}
105+
106+
94107
// Test special reference alleles
95108
bcf_variant_t var4a;
96109
bcf_set_variant_type("A", "<NON_REF>", &var4a);

vcf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5025,8 +5025,8 @@ static void bcf_set_variant_type(const char *ref, const char *alt, bcf_variant_t
50255025

50265026
if ( *a && !*r )
50275027
{
5028-
if ( *a==']' || *a=='[' ) { var->type = VCF_BND; return; } // "joined after" breakend
50295028
while ( *a ) a++;
5029+
if ( *(a-1)==']' || *(a-1)=='[' ) { var->type = VCF_BND; return; } // "joined after" breakend
50305030
var->n = (a-alt)-(r-ref); var->type = VCF_INDEL | VCF_INS; return;
50315031
}
50325032
else if ( *r && !*a )

0 commit comments

Comments
 (0)