Skip to content

Commit

Permalink
Bugfix/sorting97 (#551)
Browse files Browse the repository at this point in the history
* Prevent sorting for list of input formats
* Update subversion
  • Loading branch information
aparton authored and ens-lgil committed Aug 6, 2019
1 parent 8bf4349 commit d896ba4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions modules/Bio/EnsEMBL/VEP/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ our %DEPRECATED = (
'convert' => undef,
);

our %UNSORTABLE = (
id => 1,
hgvs => 1,
spdi => 1,
region => 1,
);

####################################
####################################
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/Bio/EnsEMBL/VEP/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions modules/Bio/EnsEMBL/VEP/InputBuffer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {

Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions t/InputBuffer.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d896ba4

Please sign in to comment.