EnsEMBL/IdMapping/TinyGene.pm untested

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