Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/IdMapping/TinyGene.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 =head1 LICENSE | |
2 | |
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
4 Genome Research Limited. All rights reserved. | |
5 | |
6 This software is distributed under a modified Apache license. | |
7 For license details, please see | |
8 | |
9 http://www.ensembl.org/info/about/code_licence.html | |
10 | |
11 =head1 CONTACT | |
12 | |
13 Please email comments or questions to the public Ensembl | |
14 developers list at <dev@ensembl.org>. | |
15 | |
16 Questions may also be sent to the Ensembl help desk at | |
17 <helpdesk@ensembl.org>. | |
18 | |
19 =cut | |
20 | |
21 =head1 NAME | |
22 | |
23 Bio::EnsEMBL::IdMapping::TinyGene - lightweight gene object | |
24 | |
25 =head1 SYNOPSIS | |
26 | |
27 # fetch a gene from the db and create a lightweight gene object from it | |
28 my $gene = $gene_adaptor->fetch_by_stable_id('ENSG000345437'); | |
29 my $lightweight_gene = Bio::EnsEMBL::IdMapping::TinyGene->new_fast( [ | |
30 $gene->dbID, $gene->stable_id, | |
31 $gene->version, $gene->created_date, | |
32 $gene->modified_date, $gene->start, | |
33 $gene->end, $gene->strand, | |
34 $gene->slice->seq_region_name, $gene->biotype, | |
35 $gene->status, $gene->analysis->logic_name, | |
36 ( $gene->is_known ? 1 : 0 ), | |
37 ] ); | |
38 | |
39 =head1 DESCRIPTION | |
40 | |
41 This is a lightweight gene object for the stable Id mapping. See the | |
42 documentation in TinyFeature for general considerations about its | |
43 design. | |
44 | |
45 =head1 METHODS | |
46 | |
47 start | |
48 end | |
49 strand | |
50 seq_region_name | |
51 biotype | |
52 status | |
53 logic_name | |
54 is_known | |
55 add_Transcript | |
56 get_all_Transcripts | |
57 length | |
58 | |
59 =cut | |
60 | |
61 package Bio::EnsEMBL::IdMapping::TinyGene; | |
62 | |
63 # internal data structure (array indices): | |
64 # | |
65 # 0-4 see TinyFeature | |
66 # 5 start | |
67 # 6 end | |
68 # 7 strand | |
69 # 8 seq_region_name | |
70 # 9 biotype | |
71 # 10 status | |
72 # 11 logic_name | |
73 # 12 is_known | |
74 # 13 [transcripts] | |
75 | |
76 | |
77 use strict; | |
78 use warnings; | |
79 no warnings 'uninitialized'; | |
80 | |
81 use Bio::EnsEMBL::IdMapping::TinyFeature; | |
82 our @ISA = qw(Bio::EnsEMBL::IdMapping::TinyFeature); | |
83 | |
84 use Bio::EnsEMBL::Utils::Exception qw(throw warning); | |
85 | |
86 | |
87 =head2 start | |
88 | |
89 Arg[1] : (optional) Int - the gene's start coordinate | |
90 Description : Getter/setter for the gene's start coordinate. | |
91 Return type : Int | |
92 Exceptions : none | |
93 Caller : general | |
94 Status : At Risk | |
95 : under development | |
96 | |
97 =cut | |
98 | |
99 sub start { | |
100 my $self = shift; | |
101 $self->[5] = shift if (@_); | |
102 return $self->[5]; | |
103 } | |
104 | |
105 | |
106 =head2 end | |
107 | |
108 Arg[1] : (optional) Int - the gene's end coordinate | |
109 Description : Getter/setter for the gene's end coordinate. | |
110 Return type : Int | |
111 Exceptions : none | |
112 Caller : general | |
113 Status : At Risk | |
114 : under development | |
115 | |
116 =cut | |
117 | |
118 sub end { | |
119 my $self = shift; | |
120 $self->[6] = shift if (@_); | |
121 return $self->[6]; | |
122 } | |
123 | |
124 | |
125 =head2 strand | |
126 | |
127 Arg[1] : (optional) Int - the gene's strand | |
128 Description : Getter/setter for the gene's strand. | |
129 Return type : Int | |
130 Exceptions : none | |
131 Caller : general | |
132 Status : At Risk | |
133 : under development | |
134 | |
135 =cut | |
136 | |
137 sub strand { | |
138 my $self = shift; | |
139 $self->[7] = shift if (@_); | |
140 return $self->[7]; | |
141 } | |
142 | |
143 | |
144 =head2 seq_region_name | |
145 | |
146 Arg[1] : (optional) String - seq_region name | |
147 Description : Getter/setter for the seq_region name of the slice the gene is | |
148 on. | |
149 Return type : String | |
150 Exceptions : none | |
151 Caller : general | |
152 Status : At Risk | |
153 : under development | |
154 | |
155 =cut | |
156 | |
157 sub seq_region_name { | |
158 my $self = shift; | |
159 $self->[8] = shift if (@_); | |
160 return $self->[8]; | |
161 } | |
162 | |
163 | |
164 =head2 biotype | |
165 | |
166 Arg[1] : (optional) String - the gene's biotype | |
167 Description : Getter/setter for the gene's biotype. | |
168 Return type : String | |
169 Exceptions : none | |
170 Caller : general | |
171 Status : At Risk | |
172 : under development | |
173 | |
174 =cut | |
175 | |
176 sub biotype { | |
177 my $self = shift; | |
178 $self->[9] = shift if (@_); | |
179 return $self->[9]; | |
180 } | |
181 | |
182 | |
183 =head2 strand | |
184 | |
185 Arg[1] : (optional) String - the gene's status | |
186 Description : Getter/setter for the gene's status. | |
187 Return type : String | |
188 Exceptions : none | |
189 Caller : general | |
190 Status : At Risk | |
191 : under development | |
192 | |
193 =cut | |
194 | |
195 sub status { | |
196 my $self = shift; | |
197 $self->[10] = shift if (@_); | |
198 return $self->[10]; | |
199 } | |
200 | |
201 | |
202 =head2 logic_name | |
203 | |
204 Arg[1] : (optional) String - the gene's analysis' logic_name | |
205 Description : Getter/setter for the gene's analysis' logic_name. | |
206 Return type : String | |
207 Exceptions : none | |
208 Caller : general | |
209 Status : At Risk | |
210 : under development | |
211 | |
212 =cut | |
213 | |
214 sub logic_name { | |
215 my $self = shift; | |
216 $self->[11] = shift if (@_); | |
217 return $self->[11]; | |
218 } | |
219 | |
220 | |
221 =head2 is_known | |
222 | |
223 Arg[1] : (optional) Boolean - the gene's "known" status | |
224 Description : Getter/setter for the gene's "known" status. | |
225 Return type : Boolean | |
226 Exceptions : none | |
227 Caller : general | |
228 Status : At Risk | |
229 : under development | |
230 | |
231 =cut | |
232 | |
233 sub is_known { | |
234 my $self = shift; | |
235 $self->[12] = shift if (@_); | |
236 return $self->[12]; | |
237 } | |
238 | |
239 | |
240 =head2 add_Transcript | |
241 | |
242 Arg[1] : Bio::EnsEMBL::IdMapping::TinyTranscript $tr - the transcript to | |
243 add | |
244 Example : $tiny_gene->add_Transcript($tiny_transcript); | |
245 Description : Adds a transcript to a gene. | |
246 Return type : none | |
247 Exceptions : thrown on wrong or missing argument | |
248 Caller : general | |
249 Status : At Risk | |
250 : under development | |
251 | |
252 =cut | |
253 | |
254 sub add_Transcript { | |
255 my $self = shift; | |
256 my $tr = shift; | |
257 | |
258 unless ($tr && $tr->isa('Bio::EnsEMBL::IdMapping::TinyTranscript')) { | |
259 throw('Need a Bio::EnsEMBL::IdMapping::TinyTranscript.'); | |
260 } | |
261 | |
262 push @{ $self->[13] }, $tr; | |
263 } | |
264 | |
265 | |
266 =head2 get_all_Transcripts | |
267 | |
268 Example : foreach my $tr (@{ $tiny_gene->get_all_Transcripts }) { | |
269 # do something with transcript | |
270 } | |
271 Description : Returns all transcripts attached to that gene. | |
272 Return type : Arrayref of Bio::EnsEMBL::IdMapping::TinyTranscript objects | |
273 Exceptions : none | |
274 Caller : general | |
275 Status : At Risk | |
276 : under development | |
277 | |
278 =cut | |
279 | |
280 sub get_all_Transcripts { | |
281 return $_[0]->[13] || []; | |
282 } | |
283 | |
284 | |
285 =head2 length | |
286 | |
287 Description : Returns the gene length (distance between start and end). | |
288 Return type : Int | |
289 Exceptions : none | |
290 Caller : general | |
291 Status : At Risk | |
292 : under development | |
293 | |
294 =cut | |
295 | |
296 sub length { | |
297 my $self = shift; | |
298 return ($self->end - $self->start + 1); | |
299 } | |
300 | |
301 | |
302 1; | |
303 |