EnsEMBL/IdMapping/TinyExon.pm untested

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