diff --git a/modules/Bio/EnsEMBL/VEP/Config.pm b/modules/Bio/EnsEMBL/VEP/Config.pm index 2672f25c4..ee5e2f448 100644 --- a/modules/Bio/EnsEMBL/VEP/Config.pm +++ b/modules/Bio/EnsEMBL/VEP/Config.pm @@ -396,6 +396,12 @@ our %DEPRECATED = ( 'convert' => undef, ); +our %UNSORTABLE = ( + id => 1, + hgvs => 1, + spdi => 1, + region => 1, +); #################################### #################################### @@ -470,6 +476,8 @@ sub new { $config->{$flag} = [split(',', $config->{$flag})]; } + $config->{unsorted_formats} = \%UNSORTABLE; + $self->apply_option_sets($config); # check config before we return diff --git a/modules/Bio/EnsEMBL/VEP/Constants.pm b/modules/Bio/EnsEMBL/VEP/Constants.pm index d9715ea42..24d2b08e2 100644 --- a/modules/Bio/EnsEMBL/VEP/Constants.pm +++ b/modules/Bio/EnsEMBL/VEP/Constants.pm @@ -53,7 +53,7 @@ use warnings; use base qw(Exporter); our $VEP_VERSION = 97; -our $VEP_SUB_VERSION = 2; +our $VEP_SUB_VERSION = 3; our @EXPORT_OK = qw( @FLAG_FIELDS diff --git a/modules/Bio/EnsEMBL/VEP/InputBuffer.pm b/modules/Bio/EnsEMBL/VEP/InputBuffer.pm index 1da14c21d..0cf3833f1 100644 --- a/modules/Bio/EnsEMBL/VEP/InputBuffer.pm +++ b/modules/Bio/EnsEMBL/VEP/InputBuffer.pm @@ -203,7 +203,9 @@ sub next { $prev_chr = $vf->{chr}; } } - + + my $unsorted_formats = $self->config->{_params}->{unsorted_formats}; + if(my $parser = $self->parser) { while(@$buffer < $buffer_size && (my $vf = $parser->next)) { @@ -234,7 +236,7 @@ sub next { else { push @$buffer, $vf; $prev_chr = $vf->{chr}; - if (!$self->param('no_check_variants_order') && $self->param('format') ne 'id') { + if (!$self->param('no_check_variants_order') && !$unsorted_formats->{$self->param('format')}) { # Use a default distance to check if the variant is still in the same region # even if it's not ordered with the previous variant location: we use the VF start and not the VCF start # (they can be different when the variant is a deletion for instance and/or when the alleles can be minimised) diff --git a/t/InputBuffer.t b/t/InputBuffer.t index f7de06b4e..290d2038e 100644 --- a/t/InputBuffer.t +++ b/t/InputBuffer.t @@ -502,6 +502,19 @@ eval { }; ok(!$@, "Skip the count for non ordered variants with the flag 'no_check_variants_order'"); +# Skip check for hgvs variants +# To workaround the offline check for HGVS input, the parser being given to the InputBuffer is in VCF format. The sorting is correctly prevented by the InputBuffer, compared to the previous 2 tests. +$cfg = Bio::EnsEMBL::VEP::Config->new({%{$test_cfg->base_testing_cfg}, buffer_size => 100, format => 'hgvs'}); +$p = Bio::EnsEMBL::VEP::Parser::VCF->new({config => $cfg, file => $test_cfg->{not_ord_vcf}, valid_chromosomes => [1,21,22]}); +$ib = Bio::EnsEMBL::VEP::InputBuffer->new({config => $cfg, parser => $p, max_not_ordered_variants => $max_non_ordered_variants, max_not_ordered_variants_distance => $max_not_ordered_variants_distance}); + +$ib->next(); +$ib->next(); +eval { + $ib->next(); +}; +ok(!$@, "Skip the count for non ordered variants with the flag 'hgvs'"); + # Check for non ordered variants with larger position difference (default settings) $max_not_ordered_variants_distance = 100;