ensembl-hive  2.7.0
TinyTranscript.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 
34 
35 =head1 SYNOPSIS
36 
37  # fetch a transcript from the db and create a lightweight
38  # transcript object from it
39  my $tr = $transcript_adaptor->fetch_by_stable_id('ENST000345437');
40  my $lightweight_tr =
42  $tr->dbID, $tr->stable_id,
43  $tr->version, $tr->created_date,
44  $tr->modified_date, $tr->start,
45  $tr->end, $tr->strand,
46  $tr->length, md5_hex( $tr->spliced_seq ),
47  ] );
48 
49 =head1 DESCRIPTION
50 
51 This is a lightweight transcript object for the stable Id mapping. See
52 the documentation in TinyFeature for general considerations about its
53 design.
54 
55 =head1 METHODS
56 
57  start
58  end
59  strand
60  length
61  seq_md5_sum
62  add_Translation
63  translation
64  add_Exon
65  get_all_Exons
66 
67 =cut
68 
69 package Bio::EnsEMBL::IdMapping::TinyTranscript;
70 
71 # internal data structure (array indices):
72 #
73 # 0-4 see TinyFeature
74 # 5 start
75 # 6 end
76 # 7 strand
77 # 8 length
78 # 9 seq_md5_sum
79 # 10 translation
80 # 11 [exons]
81 # 12 biotype
82 # 13 slice
83 
84 
85 use strict;
86 use warnings;
87 no warnings 'uninitialized';
88 
91 
92 use Bio::EnsEMBL::Utils::Exception qw(throw warning);
93 
94 
95 =head2 start
96 
97  Arg[1] : (optional) Int - the transcript's start coordinate
98  Description : Getter/setter for the transcript's start coordinate.
99  Return type : Int
100  Exceptions : none
101  Caller : general
102  Status : At Risk
103  : under development
104 
105 =cut
106 
107 sub start {
108  my $self = shift;
109  $self->[5] = shift if (@_);
110  return $self->[5];
111 }
112 
113 
114 =head2 end
115 
116  Arg[1] : (optional) Int - the transcript's end coordinate
117  Description : Getter/setter for the transcript's end coordinate.
118  Return type : Int
119  Exceptions : none
120  Caller : general
121  Status : At Risk
122  : under development
123 
124 =cut
125 
126 sub end {
127  my $self = shift;
128  $self->[6] = shift if (@_);
129  return $self->[6];
130 }
131 
132 
133 =head2 strand
134 
135  Arg[1] : (optional) Int - the transcript's strand
136  Description : Getter/setter for the transcript's strand.
137  Return type : Int
138  Exceptions : none
139  Caller : general
140  Status : At Risk
141  : under development
142 
143 =cut
144 
145 sub strand {
146  my $self = shift;
147  $self->[7] = shift if (@_);
148  return $self->[7];
149 }
150 
151 
152 =head2 length
153 
154  Arg[1] : (optional) Int - the transcript's length
155  Description : Getter/setter for the transcript's length. Note that this is
156  *not* the distance between start and end, but rather the sum of
157  the lengths of all exons.
158  Return type : Int
159  Exceptions : none
160  Caller : general
161  Status : At Risk
162  : under development
163 
164 =cut
165 
166 sub length {
167  my $self = shift;
168  $self->[8] = shift if (@_);
169  return $self->[8];
170 }
171 
172 
173 =head2 seq_md5_sum
174 
175  Arg[1] : (optional) String - the md5 digest of the transcript's sequence
176  Description : Getter/setter for the md5 digest of the transcript's sequence.
177  Note that when used as a setter, you are expected to pass a
178  digest, not the raw sequence (i.e. the digest is not created for
179  you).
180  Return type : String
181  Exceptions : none
182  Caller : general
183  Status : At Risk
184  : under development
185 
186 =cut
187 
188 sub seq_md5_sum {
189  my $self = shift;
190  $self->[9] = shift if (@_);
191  return $self->[9];
192 }
193 
194 
195 
196 =head2 add_Translation
197 
198  Arg[1] : Bio::EnsEMBL::IdMapping::TinyTranslation $tl - the translation
199  to add
200  Example : $tiny_transcript->add_Translation($tiny_translation);
201  Description : Adds a translation to this transcript.
202  Return type : none
203  Exceptions : thrown on wrong or missing argument
204  Caller : general
205  Status : At Risk
206  : under development
207 
208 =cut
209 
210 sub add_Translation {
211  my $self = shift;
212  my $tl = shift;
213 
214  unless ($tl && $tl->isa('Bio::EnsEMBL::IdMapping::TinyTranslation')) {
215  throw('Need a Bio::EnsEMBL::IdMapping::TinyTranslation.');
216  }
217 
218  $self->[10] = $tl;
219 }
220 
221 
222 =head2 translation
223 
224  Description : Getter for the transcript's translation.
225  Return type : Bio::EnsEMBL::IdMapping::TinyTranslation
226  Exceptions : none
227  Caller : general
228  Status : At Risk
229  : under development
230 
231 =cut
232 
233 sub translation {
234  return $_[0]->[10];
235 }
236 
237 
238 =head2 add_Exon
239 
240  Arg[1] : Bio::EnsEMBL::IdMapping::TinyExon $exon - the exon to add
241  Example : $tiny_transcript->add_Exon($tiny_exon);
242  Description : Adds an exon to this transcript.
243  Return type : none
244  Exceptions : thrown on wrong or missing argument
245  Caller : general
246  Status : At Risk
247  : under development
248 
249 =cut
250 
251 sub add_Exon {
252  my $self = shift;
253  my $exon = shift;
254 
255  unless ($exon && $exon->isa('Bio::EnsEMBL::IdMapping::TinyExon')) {
256  throw('Need a Bio::EnsEMBL::IdMapping::TinyExon.');
257  }
258 
259  push @{ $self->[11] }, $exon;
260 }
261 
262 
263 =head2 get_all_Exons
264 
265  Example : foreach my $exon (@{ $tiny_transcript->get_all_Exons }) {
266  # do something with exon
267  }
268  Description : Returns all exons attached to that transcript.
269  Return type : Arrayref of Bio::EnsEMBL::IdMapping::TinyExon objects
270  Exceptions : none
271  Caller : general
272  Status : At Risk
273  : under development
274 
275 =cut
276 
277 sub get_all_Exons {
278  return $_[0]->[11] || [];
279 }
280 
281 =head2 biotype
282 
283  Arg[1] : (optional) String - the gene's biotype
284  Description : Getter/setter for the gene's biotype.
285  Return type : String
286  Exceptions : none
287  Caller : general
288  Status : At Risk
289  : under development
290 
291 =cut
292 
293 sub biotype {
294  my $self = shift;
295  $self->[12] = shift if (@_);
296  return $self->[12];
297 }
298 
299 =head2 seq_region_name
300 
301  Arg[1] : (optional) String - seq_region name
302  Description : Getter/setter for the seq_region name of the slice the gene is
303  on.
304  Return type : String
305  Exceptions : none
306  Caller : general
307  Status : At Risk
308  : under development
309 
310 =cut
311 
312 sub seq_region_name {
313  my $self = shift;
314  $self->[13] = shift if (@_);
315  return $self->[13];
316 }
317 
318 
319 1;
320 
transcript
public transcript()
Bio::EnsEMBL::IdMapping::TinyExon
Definition: TinyExon.pm:37
Bio::EnsEMBL::IdMapping::TinyFeature::new_fast
public Bio::EnsEMBL::IdMapping::TinyFeature new_fast()
Bio::EnsEMBL::IdMapping::TinyTranslation
Definition: TinyTranslation.pm:27
Bio::EnsEMBL::IdMapping::TinyFeature
Definition: TinyFeature.pm:30
about
public about()
Bio::EnsEMBL::IdMapping::TinyTranscript
Definition: TinyTranscript.pm:29
Bio::EnsEMBL::Utils::Exception
Definition: Exception.pm:68