Mercurial > repos > willmclaren > ensembl_vep
comparison variant_effect_predictor/Bio/EnsEMBL/IdMapping/TinyTranscript.pm @ 0:21066c0abaf5 draft
Uploaded
author | willmclaren |
---|---|
date | Fri, 03 Aug 2012 10:04:48 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:21066c0abaf5 |
---|---|
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::TinyTranscript - lightweight transcript object | |
24 | |
25 =head1 SYNOPSIS | |
26 | |
27 # fetch a transcript from the db and create a lightweight | |
28 # transcript object from it | |
29 my $tr = $transcript_adaptor->fetch_by_stable_id('ENST000345437'); | |
30 my $lightweight_tr = | |
31 Bio::EnsEMBL::IdMapping::TinyTranscript->new_fast( [ | |
32 $tr->dbID, $tr->stable_id, | |
33 $tr->version, $tr->created_date, | |
34 $tr->modified_date, $tr->start, | |
35 $tr->end, $tr->strand, | |
36 $tr->length, md5_hex( $tr->spliced_seq ), | |
37 ( $tr->is_known ? 1 : 0 ), | |
38 ] ); | |
39 | |
40 =head1 DESCRIPTION | |
41 | |
42 This is a lightweight transcript object for the stable Id mapping. See | |
43 the documentation in TinyFeature for general considerations about its | |
44 design. | |
45 | |
46 =head1 METHODS | |
47 | |
48 start | |
49 end | |
50 strand | |
51 length | |
52 seq_md5_sum | |
53 is_known | |
54 add_Translation | |
55 translation | |
56 add_Exon | |
57 get_all_Exons | |
58 | |
59 =cut | |
60 | |
61 package Bio::EnsEMBL::IdMapping::TinyTranscript; | |
62 | |
63 # internal data structure (array indices): | |
64 # | |
65 # 0-4 see TinyFeature | |
66 # 5 start | |
67 # 6 end | |
68 # 7 strand | |
69 # 8 length | |
70 # 9 seq_md5_sum | |
71 # 10 is_known | |
72 # 11 translation | |
73 # 12 [exons] | |
74 # 13 biotype | |
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 transcript's start coordinate | |
90 Description : Getter/setter for the transcript'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 transcript's end coordinate | |
109 Description : Getter/setter for the transcript'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 transcript's strand | |
128 Description : Getter/setter for the transcript'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 length | |
145 | |
146 Arg[1] : (optional) Int - the transcript's length | |
147 Description : Getter/setter for the transcript's length. Note that this is | |
148 *not* the distance between start and end, but rather the sum of | |
149 the lengths of all exons. | |
150 Return type : Int | |
151 Exceptions : none | |
152 Caller : general | |
153 Status : At Risk | |
154 : under development | |
155 | |
156 =cut | |
157 | |
158 sub length { | |
159 my $self = shift; | |
160 $self->[8] = shift if (@_); | |
161 return $self->[8]; | |
162 } | |
163 | |
164 | |
165 =head2 seq_md5_sum | |
166 | |
167 Arg[1] : (optional) String - the md5 digest of the transcript's sequence | |
168 Description : Getter/setter for the md5 digest of the transcript's sequence. | |
169 Note that when used as a setter, you are expected to pass a | |
170 digest, not the raw sequence (i.e. the digest is not created for | |
171 you). | |
172 Return type : String | |
173 Exceptions : none | |
174 Caller : general | |
175 Status : At Risk | |
176 : under development | |
177 | |
178 =cut | |
179 | |
180 sub seq_md5_sum { | |
181 my $self = shift; | |
182 $self->[9] = shift if (@_); | |
183 return $self->[9]; | |
184 } | |
185 | |
186 | |
187 =head2 is_known | |
188 | |
189 Arg[1] : (optional) Boolean - the transcript's "known" status | |
190 Description : Getter/setter for the transcript's "known" status. | |
191 Return type : Boolean | |
192 Exceptions : none | |
193 Caller : general | |
194 Status : At Risk | |
195 : under development | |
196 | |
197 =cut | |
198 | |
199 sub is_known { | |
200 my $self = shift; | |
201 $self->[10] = shift if (@_); | |
202 return $self->[10]; | |
203 } | |
204 | |
205 | |
206 =head2 add_Translation | |
207 | |
208 Arg[1] : Bio::EnsEMBL::IdMapping::TinyTranslation $tl - the translation | |
209 to add | |
210 Example : $tiny_transcript->add_Translation($tiny_translation); | |
211 Description : Adds a translation to this transcript. | |
212 Return type : none | |
213 Exceptions : thrown on wrong or missing argument | |
214 Caller : general | |
215 Status : At Risk | |
216 : under development | |
217 | |
218 =cut | |
219 | |
220 sub add_Translation { | |
221 my $self = shift; | |
222 my $tl = shift; | |
223 | |
224 unless ($tl && $tl->isa('Bio::EnsEMBL::IdMapping::TinyTranslation')) { | |
225 throw('Need a Bio::EnsEMBL::IdMapping::TinyTranslation.'); | |
226 } | |
227 | |
228 $self->[11] = $tl; | |
229 } | |
230 | |
231 | |
232 =head2 translation | |
233 | |
234 Description : Getter for the transcript's translation. | |
235 Return type : Bio::EnsEMBL::IdMapping::TinyTranslation | |
236 Exceptions : none | |
237 Caller : general | |
238 Status : At Risk | |
239 : under development | |
240 | |
241 =cut | |
242 | |
243 sub translation { | |
244 return $_[0]->[11]; | |
245 } | |
246 | |
247 | |
248 =head2 add_Exon | |
249 | |
250 Arg[1] : Bio::EnsEMBL::IdMapping::TinyExon $exon - the exon to add | |
251 Example : $tiny_transcript->add_Exon($tiny_exon); | |
252 Description : Adds an exon to this transcript. | |
253 Return type : none | |
254 Exceptions : thrown on wrong or missing argument | |
255 Caller : general | |
256 Status : At Risk | |
257 : under development | |
258 | |
259 =cut | |
260 | |
261 sub add_Exon { | |
262 my $self = shift; | |
263 my $exon = shift; | |
264 | |
265 unless ($exon && $exon->isa('Bio::EnsEMBL::IdMapping::TinyExon')) { | |
266 throw('Need a Bio::EnsEMBL::IdMapping::TinyExon.'); | |
267 } | |
268 | |
269 push @{ $self->[12] }, $exon; | |
270 } | |
271 | |
272 | |
273 =head2 get_all_Exons | |
274 | |
275 Example : foreach my $exon (@{ $tiny_transcript->get_all_Exons }) { | |
276 # do something with exon | |
277 } | |
278 Description : Returns all exons attached to that transcript. | |
279 Return type : Arrayref of Bio::EnsEMBL::IdMapping::TinyExon objects | |
280 Exceptions : none | |
281 Caller : general | |
282 Status : At Risk | |
283 : under development | |
284 | |
285 =cut | |
286 | |
287 sub get_all_Exons { | |
288 return $_[0]->[12] || []; | |
289 } | |
290 | |
291 sub biotype { | |
292 my $self = shift; | |
293 $self->[13] = shift if (@_); | |
294 return $self->[13]; | |
295 } | |
296 | |
297 | |
298 1; | |
299 |