comparison dir_plugins/SameCodon.pm @ 3:49397129aec0 draft

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