Skip to content

Commit 7dbea87

Browse files
Fix buffer logic for multi-allelic variants
1 parent 39ab22c commit 7dbea87

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

modules/Bio/EnsEMBL/VEP/InputBuffer.pm

+1-7
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ sub next {
191191
while(@$pre_buffer && @$buffer < $buffer_size) {
192192
my $vf = $pre_buffer->[0];
193193

194-
## Set minimal to 1 if indel
195-
$self->{minimal} = 1 if (defined($vf->{minimised}) && $vf->{minimised});
196-
197194
# new chromosome
198195
if($prev_chr && $vf->{chr} ne $prev_chr) {
199196
$self->split_variants() if $self->{minimal};
@@ -212,8 +209,6 @@ sub next {
212209
if(my $parser = $self->parser) {
213210
while(@$buffer < $buffer_size && (my $vf = $parser->next)) {
214211

215-
## Set minimal to 1 if indel
216-
$self->{minimal} = 1 if (defined($vf->{minimised}) && $vf->{minimised});
217212

218213
# exit the program if the maximum number of variants not ordered in the input file is reached
219214
if (!$self->param('no_check_variants_order') &&
@@ -262,8 +257,7 @@ sub next {
262257
die($error_msg);
263258
}
264259

265-
$self->split_variants() if $self->{minimal};
266-
260+
$self->split_variants() if $self->{minimal} ;
267261
return $buffer;
268262
}
269263

modules/Bio/EnsEMBL/VEP/Parser.pm

+11-2
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,16 @@ sub post_process_vfs {
858858
# For VCF input, the allele_string is trimmed to remove anchor base, so we capture original allele
859859

860860
my $original_allele_string = ($vf->{nontrimmed_allele_string} || $vf->{allele_string});
861-
my ($ref_allele_string,$alt_allele_string) = split(/\//, $original_allele_string);
862-
$is_non_minimised_indel = 1 unless length($ref_allele_string) == length($alt_allele_string) or $original_allele_string =~ /-/;
861+
my @alleles = split(/\//, $original_allele_string);
862+
my $ref_allele_string = shift @alleles;
863+
my $alt_allele_count;
864+
865+
foreach my $alt(@alleles) {
866+
if (length($ref_allele_string) != length($alt) or $original_allele_string =~ /^-/){
867+
$is_non_minimised_indel = 1;
868+
last;
869+
}
870+
}
863871
$vf = ${$self->minimise_alleles([$vf])}[0] if $is_non_minimised_indel;
864872
}
865873
}
@@ -961,6 +969,7 @@ sub minimise_alleles {
961969
{
962970
# Updating a flag to minimise multi-allelic variants in split_variants/rejoin_variants
963971
$vf->{minimised} = 1;
972+
$vf->{original_allele_string} = $vf->{nontrimmed_allele_string} || $vf->{allele_string};
964973
push @return, $vf;
965974
}
966975

0 commit comments

Comments
 (0)