EnsEMBL/MicroRNA.pm untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 95 CC 7 SCAR 23.2
CC
7
Cov
0%
arm
30.0
new
6.0
_validate_arm_value
6.0
CRAP 10.2
1 =head1 LICENSE
2  
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
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 =cut
19  
20  
21 =head1 CONTACT
22  
23 Please email comments or questions to the public Ensembl
24 developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25  
26 Questions may also be sent to the Ensembl help desk at
27 <http://www.ensembl.org/Help/Contact>.
28  
29 =cut
30  
31 =head1 NAME
32  
33 Bio::EnsEMBL::MicroRNA - A class representing a microRNA product
34 of a transcript
35  
36 =head1 DESCRIPTION
37  
38 A specialisation of Bio::EnsEMBL::RNAProduct describing
39 MicroRNAs. Mostly takes care of wrapping miRNA-specific RNAProduct
40 attributes in methods which make them look like ordinary class
41 members.
42  
43 =head1 SYNOPSIS
44  
45 my $miR = Bio::EnsEMBL::MicroRNA->new(
46 -SEQ_START => 36,
47 -SEQ_END => 58
48 );
49  
50 # Stable-ID setter
51 $miR->stable_id('ENSS00090210');
52  
53 # Get start and end position in the precursor transcript
54 my $start = $miR->start();
55 my $end = $miR->end();
56  
57 =cut
58  
59  
60 package Bio::EnsEMBL::MicroRNA;
61 $Bio::EnsEMBL::MicroRNA::VERSION = '114.0.0_50'; # TRIAL
62 $Bio::EnsEMBL::MicroRNA::VERSION = '114.0.050';
63 use vars qw($AUTOLOAD);
64 use strict;
65 use warnings;
66  
67 use Bio::EnsEMBL::Utils::Exception qw( throw warning );
68 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
69 use Bio::EnsEMBL::Utils::Scalar qw( assert_ref wrap_array );
70 use Scalar::Util qw(weaken);
71  
72 use Bio::EnsEMBL::RNAProduct;
73  
74 use parent qw(Bio::EnsEMBL::RNAProduct);
75  
76  
77 =head2 new
78  
79 Arg: [-ARM] : which arm of the hairpin precursor this miRNA comes
80 from. Returns 3 and 5 for 3' and 5', respectively.
81 Arg [...] : Named arguments to superclass constructor
82 (see Bio::EnsEMBL::RNAProduct)
83 Example : my $miR = Bio::EnsEMBL::MicroRNA->new(
84 -SEQ_START => 36,
85 -SEQ_END => 58,
86 -ARM => 3
87 );
88 Description: Constructor. Creates a new MicroRNA object
89 Returntype : Bio::EnsEMBL::MicroRNA
90 Exceptions : throw if ARM value is out of bounds
91 Caller : general
92 Status : In Development
93  
94 =cut
95  
96 # perlcritic doesn't know about rearrange(), silence it
97 sub new { ## no critic (Subroutines::RequireArgUnpacking)
98 my $caller = shift;
99  
100 my $class = ref($caller) || $caller;
101  
102 my $self = $class->SUPER::new(@_);
103  
104 my ($arm) = rearrange(["ARM"], @_);
105 if (defined($arm)) {
106 _validate_arm_value($arm);
107 }
108 $self->{'arm'} = $arm;
109  
110 return $self;
111 }
112  
113  
114 =head2 arm
115  
116 Arg [1] : (optional) int $arm which arm of the hairpin precursor
117 this miRNA comes from
118 Example : $mirna_arm = $mirna->arm();
119 $mirna->arm(3);
120 Description : Sets or returns the arm of the hairpin this miRNA comes
121 from. Accepted values are 3 and 5 for 3' and 5',
122 respectively.
123 Return type : Integer
124 Exceptions : throw if setter is passed an incorrect value
125 or if multiple 'mirna_arm' attributes exist.
126 Caller : General
127 Status : Stable
128  
129 =cut
130  
131 sub arm {
132 my ($self, $arm) = @_;
133  
134 if (defined $arm) {
135 _validate_arm_value($arm);
136 $self->{'arm'} = $arm;
137 } elsif (!defined($self->{'arm'})) {
138 my $arm_attrs = $self->get_all_Attributes('mirna_arm');
139 my $n_arms = scalar @{$arm_attrs};
140 if ($n_arms > 0) {
141 if ($n_arms > 1) {
142 throw("MicroRNA " . $self->display_id() .
143 " has multiple arm attributes");
144 }
145 $self->{'arm'} = $arm_attrs->[0]->value();
146 }
147 }
148  
149 return $self->{'arm'};
150 }
151  
152  
153 =head2 summary_as_hash
154  
155 Example : $mirna_summary = $mirna->summary_as_hash();
156 Description : Retrieves a textual summary of this MicroRNA.
157 Built on top of generic implementation in RNAProduct.
158 Returns : hashref of arrays of descriptive strings
159 Status : Intended for internal use
160  
161 =cut
162  
163 sub summary_as_hash {
164 my $self = shift;
165  
166 my $summary = SUPER::summary_as_hash();
167 $summary->{'arm'} = $self->arm();
168  
169 return $summary;
170 }
171  
172  
173 =head2 _validate_arm_value
174 Arg [1] : int $arm which arm of the hairpin precursor this miRNA
175 comes from
176 Description: PRIVATE validates if its argument has one of the accepted
177 values for specifying the miRNA hairpin arm.
178 Returntype : none
179 Exceptions : throw if the argument is out of bounds
180 Caller : internal
181 Status : Stable
182  
183 =cut
184  
185 sub _validate_arm_value {
186 my ($arm) = @_;
187  
188 if (($arm != 3) && ($arm != 5)) {
189 throw("'$arm' is not a valid miRNA hairpin-arm specification");
190 }
191  
192 return;
193 }
194  
195 1;