EnsEMBL/IdMapping/TinyGene.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 89 CC 8 SCAR 15.4
CC
8
Cov
0%
start
6.0
end
6.0
strand
6.0
CRAP 4.7
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::TinyGene - lightweight gene object
34  
35 =head1 SYNOPSIS
36  
37 # fetch a gene from the db and create a lightweight gene object from it
38 my $gene = $gene_adaptor->fetch_by_stable_id('ENSG000345437');
39 my $lightweight_gene = Bio::EnsEMBL::IdMapping::TinyGene->new_fast( [
40 $gene->dbID, $gene->stable_id,
41 $gene->version, $gene->created_date,
42 $gene->modified_date, $gene->start,
43 $gene->end, $gene->strand,
44 $gene->slice->seq_region_name, $gene->biotype,
45 $gene->analysis->logic_name,
46 ] );
47  
48 =head1 DESCRIPTION
49  
50 This is a lightweight gene object for the stable Id mapping. See the
51 documentation in TinyFeature for general considerations about its
52 design.
53  
54 =head1 METHODS
55  
56 start
57 end
58 strand
59 seq_region_name
60 biotype
61 logic_name
62 add_Transcript
63 get_all_Transcripts
64 length
65  
66 =cut
67  
68 package Bio::EnsEMBL::IdMapping::TinyGene;
69 $Bio::EnsEMBL::IdMapping::TinyGene::VERSION = '114.0.0';
70 # internal data structure (array indices):
71 #
72 # 0-4 see TinyFeature
73 # 5 start
74 # 6 end
75 # 7 strand
76 # 8 seq_region_name
77 # 9 biotype
78 # 10 logic_name
79 # 11 [transcripts]
80  
81  
82 use strict;
83 use warnings;
84 no warnings 'uninitialized';
85  
86 use Bio::EnsEMBL::IdMapping::TinyFeature;
87 our @ISA = qw(Bio::EnsEMBL::IdMapping::TinyFeature);
88  
89 use Bio::EnsEMBL::Utils::Exception qw(throw warning);
90  
91  
92 =head2 start
93  
94 Arg[1] : (optional) Int - the gene's start coordinate
95 Description : Getter/setter for the gene's start coordinate.
96 Return type : Int
97 Exceptions : none
98 Caller : general
99 Status : At Risk
100 : under development
101  
102 =cut
103  
104 sub start {
105 my $self = shift;
106 $self->[5] = shift if (@_);
107 return $self->[5];
108 }
109  
110  
111 =head2 end
112  
113 Arg[1] : (optional) Int - the gene's end coordinate
114 Description : Getter/setter for the gene's end coordinate.
115 Return type : Int
116 Exceptions : none
117 Caller : general
118 Status : At Risk
119 : under development
120  
121 =cut
122  
123 sub end {
124 my $self = shift;
125 $self->[6] = shift if (@_);
126 return $self->[6];
127 }
128  
129  
130 =head2 strand
131  
132 Arg[1] : (optional) Int - the gene's strand
133 Description : Getter/setter for the gene's strand.
134 Return type : Int
135 Exceptions : none
136 Caller : general
137 Status : At Risk
138 : under development
139  
140 =cut
141  
142 sub strand {
143 my $self = shift;
144 $self->[7] = shift if (@_);
145 return $self->[7];
146 }
147  
148  
149 =head2 seq_region_name
150  
151 Arg[1] : (optional) String - seq_region name
152 Description : Getter/setter for the seq_region name of the slice the gene is
153 on.
154 Return type : String
155 Exceptions : none
156 Caller : general
157 Status : At Risk
158 : under development
159  
160 =cut
161  
162 sub seq_region_name {
163 my $self = shift;
164 $self->[8] = shift if (@_);
165 return $self->[8];
166 }
167  
168  
169 =head2 biotype
170  
171 Arg[1] : (optional) String - the gene's biotype
172 Description : Getter/setter for the gene's biotype.
173 Return type : String
174 Exceptions : none
175 Caller : general
176 Status : At Risk
177 : under development
178  
179 =cut
180  
181 sub biotype {
182 my $self = shift;
183 $self->[9] = shift if (@_);
184 return $self->[9];
185 }
186  
187  
188  
189 =head2 logic_name
190  
191 Arg[1] : (optional) String - the gene's analysis' logic_name
192 Description : Getter/setter for the gene's analysis' logic_name.
193 Return type : String
194 Exceptions : none
195 Caller : general
196 Status : At Risk
197 : under development
198  
199 =cut
200  
201 sub logic_name {
202 my $self = shift;
203 $self->[10] = shift if (@_);
204 return $self->[10];
205 }
206  
207  
208  
209 =head2 add_Transcript
210  
211 Arg[1] : Bio::EnsEMBL::IdMapping::TinyTranscript $tr - the transcript to
212 add
213 Example : $tiny_gene->add_Transcript($tiny_transcript);
214 Description : Adds a transcript to a gene.
215 Return type : none
216 Exceptions : thrown on wrong or missing argument
217 Caller : general
218 Status : At Risk
219 : under development
220  
221 =cut
222  
223 sub add_Transcript {
224 my $self = shift;
225 my $tr = shift;
226  
227 unless ($tr && $tr->isa('Bio::EnsEMBL::IdMapping::TinyTranscript')) {
228 throw('Need a Bio::EnsEMBL::IdMapping::TinyTranscript.');
229 }
230  
231 push @{ $self->[11] }, $tr;
232 }
233  
234  
235 =head2 get_all_Transcripts
236  
237 Example : foreach my $tr (@{ $tiny_gene->get_all_Transcripts }) {
238 # do something with transcript
239 }
240 Description : Returns all transcripts attached to that gene.
241 Return type : Arrayref of Bio::EnsEMBL::IdMapping::TinyTranscript objects
242 Exceptions : none
243 Caller : general
244 Status : At Risk
245 : under development
246  
247 =cut
248  
249 sub get_all_Transcripts {
250 return $_[0]->[11] || [];
251 }
252  
253  
254 =head2 length
255  
256 Description : Returns the gene length (distance between start and end).
257 Return type : Int
258 Exceptions : none
259 Caller : general
260 Status : At Risk
261 : under development
262  
263 =cut
264  
265 sub length {
266 my $self = shift;
267 return ($self->end - $self->start + 1);
268 }
269  
270  
271 1;
272