Skip to content

Commit

Permalink
fix range-finding error for insertions when not using Set::IntervalTree
Browse files Browse the repository at this point in the history
  • Loading branch information
William McLaren committed Jun 22, 2017
1 parent 99cbe3f commit 95350a9
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/Bio/EnsEMBL/VEP/Constants.pm
Expand Up @@ -53,7 +53,7 @@ use warnings;
use base qw(Exporter);

our $VEP_VERSION = 89;
our $VEP_SUB_VERSION = 3;
our $VEP_SUB_VERSION = 4;

our @EXPORT_OK = qw(
@FLAG_FIELDS
Expand Down
5 changes: 4 additions & 1 deletion modules/Bio/EnsEMBL/VEP/InputBuffer.pm
Expand Up @@ -247,7 +247,10 @@ sub get_overlapping_vfs {
my $hash_tree = $self->hash_tree;

return [
grep {overlap($_->{start}, $_->{end}, $start, $end)}
grep { # checking both overlaps is quicker than sorting here
overlap($_->{start}, $_->{end}, $start, $end) ||
overlap($_->{end}, $_->{start}, $start, $end)
}
values %{{
map {$_->{_hash_tree_id} => $_} # use _hash_tree_id to uniquify
map {@{$hash_tree->{$_} || []}} # tree might be empty
Expand Down
81 changes: 81 additions & 0 deletions t/InputBuffer.t
Expand Up @@ -184,6 +184,45 @@ is_deeply(
'get_overlapping_vfs - big SV 2'
);

# insertion between 11 and 12
$ib->buffer->[0]->{start}++;

# reset trees
delete $ib->{temp}->{interval_tree};
delete $ib->{temp}->{hash_tree};

is_deeply(
$ib->get_overlapping_vfs(25592910, 25592911),
[$ib->buffer->[0]],
'get_overlapping_vfs - ins 1'
);

is_deeply(
$ib->get_overlapping_vfs(25592912, 25592913),
[$ib->buffer->[0]],
'get_overlapping_vfs - ins 2'
);

is_deeply(
$ib->get_overlapping_vfs(25592911, 25592912),
[$ib->buffer->[0]],
'get_overlapping_vfs - ins 3'
);

is_deeply(
$ib->get_overlapping_vfs(25592909, 25592910),
[],
'get_overlapping_vfs - ins 4'
);

is_deeply(
$ib->get_overlapping_vfs(25592913, 25592914),
[],
'get_overlapping_vfs - ins 5'
);

$ib->buffer->[0]->{start}--;

SKIP: {

## REMEMBER TO UPDATE THIS SKIP NUMBER IF YOU ADD MORE TESTS!!!!
Expand All @@ -194,6 +233,9 @@ SKIP: {
$Bio::EnsEMBL::VEP::InputBuffer::CAN_USE_INTERVAL_TREE = 0;

delete $ib->{temp}->{interval_tree};
delete $ib->{temp}->{hash_tree};

$DB::single = 1;

is_deeply(
$ib->get_overlapping_vfs(25592911, 25592911),
Expand Down Expand Up @@ -255,6 +297,45 @@ SKIP: {
'get_overlapping_vfs no tree - big SV 2'
);

# insertion between 11 and 12
$ib->buffer->[0]->{start}++;

# reset trees
delete $ib->{temp}->{interval_tree};
delete $ib->{temp}->{hash_tree};

is_deeply(
$ib->get_overlapping_vfs(25592910, 25592911),
[$ib->buffer->[0]],
'get_overlapping_vfs no tree - ins 1'
);

is_deeply(
$ib->get_overlapping_vfs(25592912, 25592913),
[$ib->buffer->[0]],
'get_overlapping_vfs no tree - ins 2'
);

is_deeply(
$ib->get_overlapping_vfs(25592911, 25592912),
[$ib->buffer->[0]],
'get_overlapping_vfs no tree - ins 3'
);

is_deeply(
$ib->get_overlapping_vfs(25592909, 25592910),
[],
'get_overlapping_vfs no tree - ins 4'
);

is_deeply(
$ib->get_overlapping_vfs(25592913, 25592914),
[],
'get_overlapping_vfs no tree - ins 5'
);

$ib->buffer->[0]->{start}--;

$Bio::EnsEMBL::VEP::InputBuffer::CAN_USE_INTERVAL_TREE = $orig;
}

Expand Down

0 comments on commit 95350a9

Please sign in to comment.