Skip to content

Commit

Permalink
fix out-by-1 error on BED custom files
Browse files Browse the repository at this point in the history
  • Loading branch information
William McLaren committed Dec 19, 2014
1 parent 8824d10 commit 0f40683
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions modules/Bio/EnsEMBL/Variation/Utils/VEP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2742,16 +2742,23 @@ sub get_custom_annotation {
}

foreach my $custom(@{$config->{custom}}) {

next unless defined($cache->{$chr}->{$custom->{name}});

my ($s, $e) = ($vf->{start}, $vf->{end});

# adjust start for BED as it is 0-based
$s-- if $custom->{format} eq 'bed';

# exact type must match coords of variant exactly
if($custom->{type} eq 'exact') {
foreach my $feature(values %{$cache->{$chr}->{$custom->{name}}->{$vf->{start}}}) {

foreach my $feature(values %{$cache->{$chr}->{$custom->{name}}->{$s}}) {

next unless
$feature->{chr} eq $chr &&
$feature->{start} eq $vf->{start} &&
$feature->{end} eq $vf->{end};
$feature->{start} == $s &&
$feature->{end} == $e;

$annotation->{$custom->{name}} .= $feature->{name}.',';

Expand All @@ -2768,8 +2775,8 @@ sub get_custom_annotation {

next unless
$feature->{chr} eq $chr &&
$feature->{end} >= $vf->{start} &&
$feature->{start} <= $vf->{end};
$feature->{end} >= $s &&
$feature->{start} <= $e;

$annotation->{$custom->{name}} .= $feature->{name}.',';
foreach my $field(@{$custom->{fields}}) {
Expand Down

0 comments on commit 0f40683

Please sign in to comment.