EnsEMBL/IdMapping/TinyExon.pm untested

filter: Statementstmt 0.0% 0 / 71 Branchbran 0.0% 0 / 42 Conditioncond n/a Subroutinesub 0.0% 0 / 19 Podpod 0.0% 0 / 14 totaltotal 0.0% 0 / 146 CC 22 SCAR 24.0
CC
22
Cov
0%
common_start
20.0
common_end
20.0
common_strand
20.0
CRAP 11.0
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::IdMapping::TinyExon - lightweight exon object
34  
35 =head1 SYNOPSIS
36  
37 # fetch an exon from the db and create a lightweight exon object
38 # from it
39 my $exon = $exon_adaptor->fetch_by_stable_id('ENSE000345437');
40 my $lightweight_exon = Bio::EnsEMBL::IdMapping::TinyExon->new_fast( [
41 $exon->dbID,
42 $exon->stable_id,
43 $exon->version,
44 $exon->created_date,
45 $exon->modified_date,
46 $exon->start,
47 $exon->end,
48 $exon->strand,
49 $exon->slice->seq_region_name,
50 $exon->slice->coord_system_name,
51 $exon->slice->coord_system->version,
52 $exon->slice->subseq( $exon->start, $exon->end, $exon->strand ),
53 $exon->phase,
54 $need_project,
55 ] );
56  
57 =head1 DESCRIPTION
58  
59 This is a lightweight exon object for the stable Id mapping. See the
60 documentation in TinyFeature for general considerations about its
61 design.
62  
63 =head1 METHODS
64  
65 start
66 end
67 strand
68 seq_region_name
69 coord_system_name
70 coord_system_version
71 seq
72 phase
73 need_project
74 common_start
75 common_end
76 common_strand
77 common_sr_name
78 length
79  
80 =cut
81  
82  
83 package Bio::EnsEMBL::IdMapping::TinyExon;
84 $Bio::EnsEMBL::IdMapping::TinyExon::VERSION = '114.0.0_50'; # TRIAL
85 $Bio::EnsEMBL::IdMapping::TinyExon::VERSION = '114.0.050';
86 # internal data structure (array indices):
87 #
88 # 0-4 see TinyFeature
89 # 5 start
90 # 6 end
91 # 7 strand
92 # 8 seq_region_name
93 # 9 coord_system_name
94 # 10 coord_system_version
95 # 11 seq
96 # 12 phase
97 # 13 need_project
98 # 14 common_start
99 # 15 common_end
100 # 16 common_strand
101 # 17 common_sr_name
102  
103  
104 use strict;
105 use warnings;
106 no warnings 'uninitialized';
107  
108 use Bio::EnsEMBL::IdMapping::TinyFeature;
109 our @ISA = qw(Bio::EnsEMBL::IdMapping::TinyFeature);
110  
111 use Bio::EnsEMBL::Utils::Exception qw(throw warning);
112  
113  
114 =head2 start
115  
116 Arg[1] : (optional) Int - the exon's start coordinate
117 Description : Getter/setter for the exon's start coordinate.
118 Return type : Int
119 Exceptions : none
120 Caller : general
121 Status : At Risk
122 : under development
123  
124 =cut
125  
126 sub start {
127 my $self = shift;
128 $self->[5] = shift if (@_);
129 return $self->[5];
130 }
131  
132  
133 =head2 end
134  
135 Arg[1] : (optional) Int - the exon's end coordinate
136 Description : Getter/setter for the exon's end coordinate.
137 Return type : Int
138 Exceptions : none
139 Caller : general
140 Status : At Risk
141 : under development
142  
143 =cut
144  
145 sub end {
146 my $self = shift;
147 $self->[6] = shift if (@_);
148 return $self->[6];
149 }
150  
151  
152 =head2 strand
153  
154 Arg[1] : (optional) Int - the exon's strand
155 Description : Getter/setter for the exon's strand.
156 Return type : Int
157 Exceptions : none
158 Caller : general
159 Status : At Risk
160 : under development
161  
162 =cut
163  
164 sub strand {
165 my $self = shift;
166 $self->[7] = shift if (@_);
167 return $self->[7];
168 }
169  
170  
171 =head2 seq_region_name
172  
173 Arg[1] : (optional) String - seq_region name
174 Description : Getter/setter for the seq_region name of the slice the exon is
175 on.
176 Return type : String
177 Exceptions : none
178 Caller : general
179 Status : At Risk
180 : under development
181  
182 =cut
183  
184 sub seq_region_name {
185 my $self = shift;
186 $self->[8] = shift if (@_);
187 return $self->[8];
188 }
189  
190  
191 =head2 coord_system_name
192  
193 Arg[1] : (optional) String - coord_system name
194 Description : Getter/setter for the coord_system name of the slice the exon is
195 on.
196 Return type : String
197 Exceptions : none
198 Caller : general
199 Status : At Risk
200 : under development
201  
202 =cut
203  
204 sub coord_system_name {
205 my $self = shift;
206 $self->[9] = shift if (@_);
207 return $self->[9];
208 }
209  
210  
211 =head2 coord_system_version
212  
213 Arg[1] : (optional) String - coord_system version
214 Description : Getter/setter for the coord_system version of the slice the
215 exon is on.
216 Return type : String
217 Exceptions : none
218 Caller : general
219 Status : At Risk
220 : under development
221  
222 =cut
223  
224 sub coord_system_version {
225 my $self = shift;
226 $self->[10] = shift if (@_);
227 return $self->[10];
228 }
229  
230  
231 =head2 seq
232  
233 Arg[1] : (optional) String - the exon's sequence
234 Description : Getter/setter for the exon's sequence.
235 Return type : String
236 Exceptions : none
237 Caller : general
238 Status : At Risk
239 : under development
240  
241 =cut
242  
243 sub seq {
244 my $self = shift;
245 $self->[11] = shift if (@_);
246 return $self->[11];
247 }
248  
249  
250 =head2 phase
251  
252 Arg[1] : (optional) Int - the exon's phase
253 Description : Getter/setter for the exon's phase.
254 Return type : Int
255 Exceptions : none
256 Caller : general
257 Status : At Risk
258 : under development
259  
260 =cut
261  
262 sub phase {
263 my $self = shift;
264 $self->[12] = shift if (@_);
265 return $self->[12];
266 }
267  
268  
269 =head2 need_project
270  
271 Arg[1] : (optional) Boolean - attribute to set
272 Description : Getter/setter for the attribute determining whether an exon
273 needs to be projected onto a common coord_system. You don't need
274 to do so if the native coord_system is common to the source and
275 target assemblies, or if no common coord_system is found (the
276 Cache object has methods to determine this).
277 Return type : Boolean
278 Exceptions : none
279 Caller : general
280 Status : At Risk
281 : under development
282  
283 =cut
284  
285 sub need_project {
286 my $self = shift;
287 $self->[13] = shift if (@_);
288 return $self->[13];
289 }
290  
291  
292 =head2 common_start
293  
294 Arg[1] : (optional) Int - the exon's start in common coord_system
295 coordinates
296 Description : Getter/setter for the exon's start in common coord_system
297 coordinates. Will return $self->start if no projection to a
298 common coord_system is required.
299 Return type : Int
300 Exceptions : none
301 Caller : general
302 Status : At Risk
303 : under development
304  
305 =cut
306  
307 sub common_start {
308 my $self = shift;
309  
310 # when used as a setter, always set a value
311 $self->[14] = shift if (@_);
312  
313 # when used as a getter
314 if (scalar(@$self) > 14) {
315 # return value for common coord_system if available (but avoid
316 # autovivification gotcha!)
317 return $self->[14];
318 } elsif ($self->need_project) {
319 # return undef if common value expected but not there (e.g. no projection
320 # found
321 return undef;
322 } else {
323 # return native value
324 return $self->start;
325 }
326 }
327  
328  
329 =head2 common_end
330  
331 Arg[1] : (optional) Int - the exon's end in common coord_system
332 coordinates
333 Description : Getter/setter for the exon's end in common coord_system
334 coordinates. Will return $self->end if no projection to a
335 common coord_system is required.
336 Return type : Int
337 Exceptions : none
338 Caller : general
339 Status : At Risk
340 : under development
341  
342 =cut
343  
344 sub common_end {
345 my $self = shift;
346  
347 # when used as a setter, always set a value
348 $self->[15] = shift if (@_);
349  
350 # when used as a getter
351 if (scalar(@$self) > 14) {
352 # return value for common coord_system if available (but avoid
353 # autovivification gotcha!)
354 return $self->[15];
355 } elsif ($self->need_project) {
356 # return undef if common value expected but not there (e.g. no projection
357 # found
358 return undef;
359 } else {
360 # return native value
361 return $self->end;
362 }
363 }
364  
365  
366 =head2 common_strand
367  
368 Arg[1] : (optional) Int - the exon's strand in common coord_system
369 coordinates
370 Description : Getter/setter for the exon's strand in common coord_system
371 coordinates. Will return $self->strand if no projection to a
372 common coord_system is required.
373 Return type : Int
374 Exceptions : none
375 Caller : general
376 Status : At Risk
377 : under development
378  
379 =cut
380  
381 sub common_strand {
382 my $self = shift;
383  
384 # when used as a setter, always set a value
385 $self->[16] = shift if (@_);
386  
387 # when used as a getter
388 if (scalar(@$self) > 14) {
389 # return value for common coord_system if available (but avoid
390 # autovivification gotcha!)
391 return $self->[16];
392 } elsif ($self->need_project) {
393 # return undef if common value expected but not there (e.g. no projection
394 # found
395 return undef;
396 } else {
397 # return native value
398 return $self->strand;
399 }
400 }
401  
402  
403 =head2 common_sr_name
404  
405 Arg[1] : (optional) String - seq_region name of the exon's slice on the
406 common coord_system
407 Description : Getter/setter for the seq_region name of the exon's slice on the
408 common coord_system coordinates. Will return
409 $self->seq_region_name if no projection to a common coord_system
410 is required.
411 Return type : String
412 Exceptions : none
413 Caller : general
414 Status : At Risk
415 : under development
416  
417 =cut
418  
419 sub common_sr_name {
420 my $self = shift;
421  
422 # when used as a setter, always set a value
423 $self->[17] = shift if (@_);
424  
425 # when used as a getter
426 if (scalar(@$self) > 14) {
427 # return value for common coord_system if available (but avoid
428 # autovivification gotcha!)
429 return $self->[17];
430 } elsif ($self->need_project) {
431 # return undef if common value expected but not there (e.g. no projection
432 # found
433 return undef;
434 } else {
435 # return native value
436 return $self->seq_region_name;
437 }
438 }
439  
440  
441 =head2 length
442  
443 Description : Returns the exon length (distance between start and end).
444 Return type : Int
445 Exceptions : none
446 Caller : general
447 Status : At Risk
448 : under development
449  
450 =cut
451  
452 sub length {
453 my $self = shift;
454 return ($self->end - $self->start + 1);
455 }
456  
457  
458  
459 1;
460