forked from Ensembl/VEP_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SameCodon.pm
117 lines (79 loc) · 3.11 KB
/
SameCodon.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2021] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=head1 CONTACT
Ensembl <http://www.ensembl.org/info/about/contact/index.html>
=cut
=head1 NAME
SameCodon
=head1 SYNOPSIS
mv SameCodon.pm ~/.vep/Plugins
./vep -i variations.vcf --plugin SameCodon
=head1 DESCRIPTION
A VEP plugin that reports existing variants that fall in the same codon.
=cut
package SameCodon;
use strict;
use warnings;
use Bio::EnsEMBL::Variation::Utils::BaseVepPlugin;
use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin);
sub version {
return '3.0';
}
sub feature_types {
return ['Transcript'];
}
sub get_header_info {
return {
SameCodon => "Existing variant IDs that fall in the same codon",
};
}
sub run {
my ($self, $tva) = @_;
if ($self->config->{offline}) {
die "A connection to the database is required to use the plugin SameCodon\n";
}
my $tv = $tva->transcript_variation;
my $vf = $tv->variation_feature;
my ($pep_start, $pep_end) = ($tv->translation_start, $tv->translation_end);
my ($vf_start, $vf_end) = ($vf->start, $vf->end);
return {} unless defined($pep_start) && defined($pep_end);
my $config = $self->{config};
# we need to map the TV start and end coords to the genome
# needs to be done through the mapper in case the codon spans exons
my $mapper = $tv->_mapper();
return {} unless defined($mapper);
my @coords = $mapper->pep2genomic($pep_start, $pep_end);
return {} unless scalar @coords;
return {} if grep {!$_->isa('Bio::EnsEMBL::Mapper::Coordinate')} @coords;
my @results;
# we might get multiple "slices" if the codon that the variant falls in spans exons
foreach my $coord(@coords) {
my ($slice_start, $slice_end) = ($coord->start, $coord->end);
my $sub_slice = $vf->slice->sub_Slice($slice_start, $slice_end);
my $vf_adaptor = $vf->slice->_get_VariationFeatureAdaptor();
push @results,
map {$_->variation_name}
grep {
$_->variation_name ne $vf->variation_name &&
$_->seq_region_start != $vf_start &&
$_->seq_region_end != $vf_end &&
scalar $mapper->genomic2cds($_->seq_region_start, $_->seq_region_end, 1) >= 1
}
@{$vf_adaptor->fetch_all_by_Slice_SO_terms($sub_slice)};
}
return {} unless scalar @results;
return {
SameCodon => join ",", @results
}
}
1;