comparison dir_plugins/miRNA.pm @ 0:e545d0a25ffe draft

Uploaded
author dvanzessen
date Mon, 15 Jul 2019 05:17:17 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e545d0a25ffe
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 miRNA
27
28 =head1 SYNOPSIS
29
30 mv miRNA.pm ~/.vep/Plugins
31 ./vep -i variations.vcf --plugin miRNA
32
33 =head1 DESCRIPTION
34
35 A VEP plugin that determines where in the secondary structure of a miRNA a
36 variant falls.
37
38 =cut
39
40 package miRNA;
41
42 use strict;
43 use warnings;
44
45 use Bio::EnsEMBL::Variation::Utils::BaseVepPlugin;
46
47 use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin);
48
49 sub feature_types {
50 return ['Transcript'];
51 }
52
53 sub get_header_info {
54 my $self = shift;
55 return {
56 miRNA => 'SO term for miRNA component containing the variant'
57 }
58 }
59
60 sub run {
61 my ($self, $tva) = @_;
62
63 my $tv = $tva->transcript_variation;
64 my $tr = $tva->transcript;
65
66 # obviously this only works for *RNA transcripts
67 return {} unless $tr->biotype =~ /RNA/;
68
69 # and it only works if the TV falls in the cDNA
70 return {} unless $tv->cdna_start && $tv->cdna_end;
71
72 # get attribute if already cached
73 my ($attrib) = @{$tr->get_all_Attributes('ncRNA')};
74
75 # bit of a cheat to get attrib if ncRNA attribute hasn't been cached
76 if(!$attrib && defined($self->{config}->{ta})) {
77 delete $tr->{attributes};
78 $tr->{adaptor} = $self->{config}->{ta};
79 ($attrib) = @{$tr->get_all_Attributes('ncRNA')};
80 }
81
82 return {} unless $attrib;
83
84 # split out string to get coords and structure string
85 my ($start, $end, $struct) = split /\s+|\:/, $attrib->value;
86 return {} unless $struct && $struct =~ /[\(\.\)]+/;
87
88 # variant not in given structure?
89 return { miRNA => 'None' } unless $tv->cdna_start <= $end && $tv->cdna_end >= $start;
90
91 # parse out structure
92 my @struct;
93 while($struct =~ m/([\.\(\)])([0-9]+)?/g) {
94 my $num = $2 || 1;
95 push @struct, $1 for(1..$num);
96 }
97
98 # get struct element types overlapped by variant
99 my %chars;
100 for my $pos($tv->cdna_start..$tv->cdna_end) {
101 $pos -= $start;
102 next if $pos < 0 or $pos > scalar @struct;
103 $chars{$struct[$pos]} = 1;
104 }
105
106 # map element types to SO terms
107 my %map = (
108 '(' => 'miRNA_stem',
109 ')' => 'miRNA_stem',
110 '.' => 'miRNA_loop'
111 );
112
113 return {
114 miRNA => join(",", sort map {$map{$_}} keys %chars)
115 };
116 }
117
118 1;
119