ensembl-hive  2.7.0
MicroRNA.pm
Go to the documentation of this file.
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 
62 use vars qw($AUTOLOAD);
63 use strict;
64 use warnings;
65 
66 use Bio::EnsEMBL::Utils::Exception qw( throw warning );
67 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
68 use Bio::EnsEMBL::Utils::Scalar qw( assert_ref wrap_array );
69 use Scalar::Util qw(weaken);
70 
72 
73 use parent qw(Bio::EnsEMBL::RNAProduct);
74 
75 
76 =head2 new
77 
78  Arg: [-ARM] : which arm of the hairpin precursor this miRNA comes
79  from. Returns 3 and 5 for 3' and 5', respectively.
80  Arg [...] : Named arguments to superclass constructor
82  Example : my $miR = Bio::EnsEMBL::MicroRNA->new(
83  -SEQ_START => 36,
84  -SEQ_END => 58,
85  -ARM => 3
86  );
87  Description: Constructor. Creates a new MicroRNA object
88  Returntype : Bio::EnsEMBL::MicroRNA
89  Exceptions : throw if ARM value is out of bounds
90  Caller : general
91  Status : In Development
92 
93 =cut
94 
95 # perlcritic doesn't know about rearrange(), silence it
96 sub new { ## no critic (Subroutines::RequireArgUnpacking)
97  my $caller = shift;
98 
99  my $class = ref($caller) || $caller;
100 
101  my $self = $class->SUPER::new(@_);
102 
103  my ($arm) = rearrange(["ARM"], @_);
104  if (defined($arm)) {
105  _validate_arm_value($arm);
106  }
107  $self->{'arm'} = $arm;
108 
109  return $self;
110 }
111 
112 
113 =head2 arm
114 
115  Arg [1] : (optional) int $arm which arm of the hairpin precursor
116  this miRNA comes from
117  Example : $mirna_arm = $mirna->arm();
118  $mirna->arm(3);
119  Description : Sets or returns the arm of the hairpin this miRNA comes
120  from. Accepted values are 3 and 5 for 3' and 5',
121  respectively.
122  Return type : Integer
123  Exceptions : throw if setter is passed an incorrect value
124  or if multiple 'mirna_arm' attributes exist.
125  Caller : General
126  Status : Stable
127 
128 =cut
129 
130 sub arm {
131  my ($self, $arm) = @_;
132 
133  if (defined $arm) {
134  _validate_arm_value($arm);
135  $self->{'arm'} = $arm;
136  } elsif (!defined($self->{'arm'})) {
137  my $arm_attrs = $self->get_all_Attributes('mirna_arm');
138  my $n_arms = scalar @{$arm_attrs};
139  if ($n_arms > 0) {
140  if ($n_arms > 1) {
141  throw("MicroRNA " . $self->display_id() .
142  " has multiple arm attributes");
143  }
144  $self->{'arm'} = $arm_attrs->[0]->value();
145  }
146  }
147 
148  return $self->{'arm'};
149 }
150 
151 
152 =head2 summary_as_hash
153 
154  Example : $mirna_summary = $mirna->summary_as_hash();
155  Description : Retrieves a textual summary of this MicroRNA.
156  Built on top of generic implementation in RNAProduct.
157  Returns : hashref of arrays of descriptive strings
158  Status : Intended for internal use
159 
160 =cut
161 
162 sub summary_as_hash {
163  my $self = shift;
164 
165  my $summary = SUPER::summary_as_hash();
166  $summary->{'arm'} = $self->arm();
167 
168  return $summary;
169 }
170 
171 
172 =head2 _validate_arm_value
173  Arg [1] : int $arm which arm of the hairpin precursor this miRNA
174  comes from
175  Description: PRIVATE validates if its argument has one of the accepted
176  values for specifying the miRNA hairpin arm.
177  Returntype : none
178  Exceptions : throw if the argument is out of bounds
179  Caller : internal
180  Status : Stable
181 
182 =cut
183 
184 sub _validate_arm_value {
185  my ($arm) = @_;
186 
187  if (($arm != 3) && ($arm != 5)) {
188  throw("'$arm' is not a valid miRNA hairpin-arm specification");
189  }
190 
191  return;
192 }
193 
194 1;
Bio::EnsEMBL::RNAProduct
Definition: RNAProduct.pm:33
transcript
public transcript()
Bio::EnsEMBL::RNAProduct::stable_id
public String stable_id()
Bio::EnsEMBL::Utils::Scalar
Definition: Scalar.pm:66
Bio::EnsEMBL::MicroRNA
Definition: MicroRNA.pm:32
Bio::EnsEMBL::MicroRNA::new
public Bio::EnsEMBL::MicroRNA new()
Bio::EnsEMBL::Utils::Argument
Definition: Argument.pm:34
Bio::EnsEMBL::Utils::Exception
Definition: Exception.pm:68