-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update NearestExonJB #771
Open
dglemos
wants to merge
7
commits into
Ensembl:postreleasefix/114
Choose a base branch
from
dglemos:update/nearestExonJB
base: postreleasefix/114
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update NearestExonJB #771
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c52bf0f
Include intronic variants
dglemos 9a1e21b
Change output
dglemos d38079f
Apply to intron variants
dglemos a38e408
Update plugin description
dglemos baa5275
Format output to be the same as default
dglemos ee4e683
Update description
dglemos 819b1a9
Remove comment
dglemos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,8 @@ limitations under the License. | |
|
||
This is a plugin for the Ensembl Variant Effect Predictor (VEP) that | ||
finds the nearest exon junction boundary to a coding sequence variant. More than | ||
one boundary may be reported if the boundaries are equidistant. | ||
one boundary may be reported if the boundaries are equidistant or if using option | ||
--intronic. | ||
|
||
The plugin will report the Ensembl identifier of the exon, the distance to the | ||
exon boundary, the boundary type (start or end of exon) and the total | ||
|
@@ -44,9 +45,16 @@ limitations under the License. | |
|
||
max_range : maximum search range in bp (default: 10000) | ||
|
||
intronic : set to 1 to check nearest exons for intronic variants (default: 0) | ||
returns the nearest exon upstream and downstream without considering | ||
the max_range. | ||
|
||
|
||
Parameters are passed e.g.: | ||
|
||
--plugin NearestExonJB,max_range=50000 | ||
--plugin NearestExonJB,max_range=50000,intronic=1 | ||
--plugin NearestExonJB,intronic=1 | ||
|
||
=cut | ||
|
||
|
@@ -63,6 +71,7 @@ my $char_sep = "|"; | |
|
||
my %CONFIG = ( | ||
max_range => 10000, | ||
intronic => 0 | ||
); | ||
|
||
sub new { | ||
|
@@ -106,9 +115,39 @@ sub run { | |
my $loc_string = sprintf("%s:%s-%i-%i", $trv->transcript_stable_id, $vf->{chr} || $vf->seq_region_name, $vf->{start}, $vf->{end}); | ||
|
||
if(!exists($self->{_cache}) || !exists($self->{_cache}->{$loc_string})) { | ||
my $exons = $trv->_overlapped_exons; | ||
my $exons = $trv->_overlapped_exons; # intronic variants do not overlap any exon | ||
my %dists; | ||
my $min = $CONFIG{max_range}; | ||
|
||
# For option --intronic, fetch the list of exons with different method | ||
# Do not take into account the max_range | ||
if(scalar @{$exons} == 0 && $CONFIG{intronic} == 1) { | ||
my $intron_numbers = $trv->intron_number(); | ||
my $consequences = join(",", map { $_->SO_term } @{$tva->get_all_OverlapConsequences}); | ||
|
||
if(defined $intron_numbers && $consequences =~ /intron/) { | ||
$exons = $trv->_sorted_exons; | ||
my ($intron_number, $total_number) = split(/\//, $intron_numbers); | ||
|
||
# Get the number of exons before and after the intron | ||
my $exon_before = $intron_number; | ||
my $exon_after = $intron_number + 1; | ||
|
||
my @exons_tmp; | ||
# Reverse strand we get the exons from the end of the list | ||
if($tva->transcript->strand < 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggesting that we just directly modify the $exons like this
|
||
push(@exons_tmp, $exons->[-$exon_before]); | ||
push(@exons_tmp, $exons->[-$exon_after]); | ||
} | ||
else { | ||
push(@exons_tmp, $exons->[$exon_before -1]); | ||
push(@exons_tmp, $exons->[$exon_after -1]); | ||
} | ||
|
||
$exons = \@exons_tmp; | ||
} | ||
} | ||
|
||
foreach my $exon (@$exons) { | ||
my $startD = abs ($vf->start - $exon->seq_region_start); | ||
my $endD = abs ($vf->end - $exon->seq_region_end); | ||
|
@@ -128,9 +167,34 @@ sub run { | |
} | ||
|
||
my @finalRes; | ||
foreach my $exon (keys %dists){ | ||
if (exists $dists{$exon}{$min}) { | ||
push(@finalRes, $exon.$char_sep.$min.$char_sep.$dists{$exon}{$min}.$char_sep.$dists{$exon}{len}) | ||
# For option --intronic, return the closest exons (upstream/dowsntream) from the intron | ||
if(scalar @{$exons} == 2 && $CONFIG{intronic} == 1) { | ||
foreach my $exon (keys %dists) { | ||
my $inner_hash = $dists{$exon}; | ||
my $length_value; | ||
my $type; | ||
my $distance_value; | ||
|
||
for my $internal_key (keys %{$inner_hash}) { | ||
if($internal_key eq "len") { | ||
$length_value = $inner_hash->{$internal_key}; | ||
} | ||
else { | ||
$type = $inner_hash->{$internal_key}; | ||
$distance_value = $internal_key; | ||
} | ||
} | ||
|
||
my $string = $exon . $char_sep . $distance_value . $char_sep . $type . $char_sep . $length_value; | ||
push(@finalRes, $string); | ||
} | ||
} | ||
else { | ||
# This is the default behaviour of the plugin | ||
foreach my $exon (keys %dists){ | ||
if (exists $dists{$exon}{$min}) { | ||
push(@finalRes, $exon.$char_sep.$min.$char_sep.$dists{$exon}{$min}.$char_sep.$dists{$exon}{len}) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -140,4 +204,3 @@ sub run { | |
} | ||
|
||
1; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting we change the get_header_info since we support
intron_variants
now