Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/OperonTranscript.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 | |
2 =head1 LICENSE | |
3 | |
4 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
5 Genome Research Limited. All rights reserved. | |
6 | |
7 This software is distributed under a modified Apache license. | |
8 For license details, please see | |
9 | |
10 http://www.ensembl.org/info/about/code_licence.html | |
11 | |
12 =head1 CONTACT | |
13 | |
14 Please email comments or questions to the public Ensembl | |
15 developers list at <dev@ensembl.org>. | |
16 | |
17 Questions may also be sent to the Ensembl help desk at | |
18 <helpdesk@ensembl.org>. | |
19 | |
20 =cut | |
21 | |
22 =head1 NAME | |
23 | |
24 Bio::EnsEMBL::OperonTranscript - Object representing a polycistronic transcript that is part of an operon | |
25 | |
26 =head1 SYNOPSIS | |
27 | |
28 my $operon_transcript = | |
29 Bio::EnsEMBL::OperonTranscript->new( -START => $start, | |
30 -END => $end, | |
31 -STRAND => $strand, | |
32 -SLICE => $slice ); | |
33 $operon->add_OperonTranscript($operon_transcript); | |
34 | |
35 =head1 DESCRIPTION | |
36 | |
37 A representation of a polycistronic transcript from an operon within the Ensembl system. An operon is a collection of one or more polycistronic transcripts, which contain one or more genes. | |
38 | |
39 =head1 METHODS | |
40 | |
41 =cut | |
42 | |
43 package Bio::EnsEMBL::OperonTranscript; | |
44 | |
45 use strict; | |
46 use warnings; | |
47 | |
48 use Bio::EnsEMBL::Feature; | |
49 use Bio::EnsEMBL::Utils::Argument qw(rearrange); | |
50 use Bio::EnsEMBL::Utils::Exception qw(throw warning deprecate); | |
51 use Bio::EnsEMBL::Utils::Scalar qw(assert_ref); | |
52 | |
53 use vars qw(@ISA); | |
54 @ISA = qw(Bio::EnsEMBL::Feature); | |
55 | |
56 =head2 new | |
57 | |
58 Arg [-START] : | |
59 int - start postion of the operon transcript | |
60 Arg [-END] : | |
61 int - end position of the operon transcript | |
62 Arg [-STRAND] : | |
63 int - 1,-1 tehe strand the operon transcript is on | |
64 Arg [-SLICE] : | |
65 Bio::EnsEMBL::Slice - the slice the operon transcript is on | |
66 Arg [-STABLE_ID] : | |
67 string - the stable identifier of this operon transcript | |
68 Arg [-VERSION] : | |
69 int - the version of the stable identifier of this operon transcript | |
70 Arg [-CREATED_DATE]: | |
71 string - the date the operon transcript was created | |
72 Arg [-MODIFIED_DATE]: | |
73 string - the date the operon transcript was last modified | |
74 | |
75 Example : $gene = Bio::EnsEMBL::OperonTranscript->new(...); | |
76 Description: Creates a new operon transcript object | |
77 Returntype : Bio::EnsEMBL::OperonTranscript | |
78 Exceptions : none | |
79 Caller : general | |
80 Status : Stable | |
81 | |
82 =cut | |
83 | |
84 sub new { | |
85 my $caller = shift; | |
86 | |
87 my $class = ref($caller) || $caller; | |
88 my $self = $class->SUPER::new(@_); | |
89 my ( $stable_id, $version, $created_date, $modified_date, $display_label ) = | |
90 rearrange( [ 'STABLE_ID', 'VERSION', | |
91 'CREATED_DATE', 'MODIFIED_DATE', 'DISPLAY_LABEL' ], | |
92 @_ ); | |
93 | |
94 $self->stable_id($stable_id); | |
95 $self->version($version); | |
96 $self->{'created_date'} = $created_date; | |
97 $self->{'modified_date'} = $modified_date; | |
98 $self->display_label($display_label); | |
99 return $self; | |
100 } | |
101 | |
102 =head2 created_date | |
103 | |
104 Arg [1] : (optional) String - created date to set (as a UNIX time int) | |
105 Example : $gene->created_date('1141948800'); | |
106 Description: Getter/setter for attribute created_date | |
107 Returntype : String | |
108 Exceptions : none | |
109 Caller : general | |
110 Status : Stable | |
111 | |
112 =cut | |
113 | |
114 sub created_date { | |
115 my $self = shift; | |
116 $self->{'created_date'} = shift if ( @_ ); | |
117 return $self->{'created_date'}; | |
118 } | |
119 | |
120 | |
121 =head2 modified_date | |
122 | |
123 Arg [1] : (optional) String - modified date to set (as a UNIX time int) | |
124 Example : $gene->modified_date('1141948800'); | |
125 Description: Getter/setter for attribute modified_date | |
126 Returntype : String | |
127 Exceptions : none | |
128 Caller : general | |
129 Status : Stable | |
130 | |
131 =cut | |
132 | |
133 sub modified_date { | |
134 my $self = shift; | |
135 $self->{'modified_date'} = shift if ( @_ ); | |
136 return $self->{'modified_date'}; | |
137 } | |
138 | |
139 | |
140 =head2 display_label | |
141 | |
142 Arg [1] : (optional) String - the name/label to set | |
143 Example : $operon->name('accBCD'); | |
144 Description: Getter/setter for attribute name. | |
145 Returntype : String or undef | |
146 Exceptions : none | |
147 Caller : general | |
148 Status : Stable | |
149 | |
150 =cut | |
151 | |
152 sub display_label { | |
153 my $self = shift; | |
154 $self->{'display_label'} = shift if (@_); | |
155 return $self->{'display_label'}; | |
156 } | |
157 | |
158 =head2 stable_id | |
159 | |
160 Arg [1] : (optional) String - the stable ID to set | |
161 Example : $operon->stable_id("accR2A"); | |
162 Description: Getter/setter for stable id for this operon transcript. | |
163 Returntype : String | |
164 Exceptions : none | |
165 Caller : general | |
166 Status : Stable | |
167 | |
168 =cut | |
169 | |
170 sub stable_id { | |
171 my $self = shift; | |
172 $self->{'stable_id'} = shift if (@_); | |
173 return $self->{'stable_id'}; | |
174 } | |
175 | |
176 =head2 version | |
177 | |
178 Arg [1] : (optional) Int - the stable ID version to set | |
179 Example : $operon->version(1); | |
180 Description: Getter/setter for stable id version for this operon transcript. | |
181 Returntype : Int | |
182 Exceptions : none | |
183 Caller : general | |
184 Status : Stable | |
185 | |
186 =cut | |
187 sub version { | |
188 my $self = shift; | |
189 $self->{'version'} = shift if(@_); | |
190 return $self->{'version'}; | |
191 } | |
192 | |
193 =head2 operon | |
194 | |
195 Example : $operon = $ot->operon(); | |
196 Description: getter for the operon to which this transcript belongs | |
197 Returntype : Bio::EnsEMBL::Operon | |
198 Exceptions : none | |
199 Caller : general | |
200 Status : Stable | |
201 | |
202 =cut | |
203 sub operon { | |
204 my $self = shift; | |
205 if ( !exists $self->{'operon'} ) { | |
206 if ( defined $self->adaptor() ) { | |
207 my $ta = $self->adaptor()->db()->get_OperonAdaptor(); | |
208 my $operon = $ta->fetch_by_operon_transcript($self); | |
209 $self->{'operon'} = $operon; | |
210 } | |
211 } | |
212 return $self->{'operon'}; | |
213 } | |
214 | |
215 =head2 get_all_Genes | |
216 | |
217 Example : $genes = $ot->get_all_Genes(); | |
218 Description: get all the genes that are attached to this operon transcript | |
219 Returntype : Arrayref of Bio::EnsEMBL::Gene | |
220 Exceptions : none | |
221 Caller : general | |
222 Status : Stable | |
223 | |
224 =cut | |
225 sub get_all_Genes { | |
226 my $self = shift; | |
227 if(! defined $self->{_gene_array}) { | |
228 if(defined $self->dbID() && defined $self->adaptor()) { | |
229 my $ta = $self->adaptor()->db()->get_OperonTranscriptAdaptor(); | |
230 my $transcripts = $ta->fetch_genes_by_operon_transcript($self); | |
231 $self->{_gene_array} = $transcripts; | |
232 } | |
233 else { | |
234 $self->{_gene_array} = []; | |
235 } | |
236 } | |
237 return $self->{_gene_array}; | |
238 } | |
239 =head2 add_gene | |
240 | |
241 Arg [1] : Bio::EnsEMBL::Gene - gene to attach to this polycistronic transcript | |
242 Example : $operon->add_gene($gene); | |
243 Description: Attach a gene to this polycistronic transcript | |
244 Exceptions : if argument is not Bio::EnsEMBL::Gene | |
245 Caller : general | |
246 Status : Stable | |
247 | |
248 =cut | |
249 sub add_gene { | |
250 my ($self,$gene) = @_; | |
251 assert_ref($gene,'Bio::EnsEMBL::Gene'); | |
252 push @{$self->get_all_Genes()},$gene; | |
253 return; | |
254 } | |
255 | |
256 =head2 add_DBEntry | |
257 | |
258 Arg [1] : Bio::EnsEMBL::DBEntry $dbe | |
259 The dbEntry to be added | |
260 Example : my $dbe = Bio::EnsEMBL::DBEntery->new(...); | |
261 $operon->add_DBEntry($dbe); | |
262 Description: Associates a DBEntry with this operon. Note that adding DBEntries | |
263 will prevent future lazy-loading of DBEntries for this operon | |
264 (see get_all_DBEntries). | |
265 Returntype : none | |
266 Exceptions : thrown on incorrect argument type | |
267 Caller : general | |
268 Status : Stable | |
269 | |
270 =cut | |
271 | |
272 sub add_DBEntry { | |
273 my $self = shift; | |
274 my $dbe = shift; | |
275 | |
276 unless($dbe && ref($dbe) && $dbe->isa('Bio::EnsEMBL::DBEntry')) { | |
277 throw('Expected DBEntry argument'); | |
278 } | |
279 | |
280 $self->{'dbentries'} ||= []; | |
281 push @{$self->{'dbentries'}}, $dbe; | |
282 } | |
283 | |
284 | |
285 =head2 get_all_Attributes | |
286 | |
287 Arg [1] : (optional) String $attrib_code | |
288 The code of the attribute type to retrieve values for | |
289 Example : my ($author) = @{ $ot->get_all_Attributes('author') }; | |
290 my @ot_attributes = @{ $ot->get_all_Attributes }; | |
291 Description: Gets a list of Attributes of this operon transcript. | |
292 Optionally just get Attributes for given code. | |
293 Returntype : Listref of Bio::EnsEMBL::Attribute | |
294 Exceptions : warning if gene does not have attached adaptor and attempts lazy | |
295 load. | |
296 Caller : general | |
297 Status : Stable | |
298 | |
299 =cut | |
300 | |
301 sub get_all_Attributes { | |
302 my $self = shift; | |
303 my $attrib_code = shift; | |
304 | |
305 if ( !exists $self->{'attributes'} ) { | |
306 if ( !$self->adaptor() ) { | |
307 return []; | |
308 } | |
309 | |
310 my $attribute_adaptor = $self->adaptor->db->get_AttributeAdaptor(); | |
311 $self->{'attributes'} = $attribute_adaptor->fetch_all_by_OperonTranscript($self); | |
312 } | |
313 | |
314 if ( defined $attrib_code ) { | |
315 my @results = | |
316 grep { uc( $_->code() ) eq uc($attrib_code) } | |
317 @{ $self->{'attributes'} }; | |
318 return \@results; | |
319 } else { | |
320 return $self->{'attributes'}; | |
321 } | |
322 } | |
323 | |
324 =head2 get_all_DBEntries | |
325 | |
326 Arg [1] : (optional) String, external database name | |
327 | |
328 Arg [2] : (optional) String, external_db type | |
329 | |
330 Example : @dbentries = @{ $gene->get_all_DBEntries() }; | |
331 | |
332 Description: Retrieves DBEntries (xrefs) for this operon transcript. This does | |
333 *not* include DBEntries that are associated with the | |
334 transcripts and corresponding translations of this | |
335 gene (see get_all_DBLinks()). | |
336 | |
337 This method will attempt to lazy-load DBEntries | |
338 from a database if an adaptor is available and no | |
339 DBEntries are present on the gene (i.e. they have not | |
340 already been added or loaded). | |
341 | |
342 Return type: Listref of Bio::EnsEMBL::DBEntry objects | |
343 Exceptions : none | |
344 Caller : get_all_DBLinks, OperontTranscriptAdaptor::store | |
345 Status : Stable | |
346 | |
347 =cut | |
348 | |
349 sub get_all_DBEntries { | |
350 my ( $self, $db_name_exp, $ex_db_type ) = @_; | |
351 | |
352 my $cache_name = 'dbentries'; | |
353 | |
354 if ( defined($db_name_exp) ) { | |
355 $cache_name .= $db_name_exp; | |
356 } | |
357 | |
358 if ( defined($ex_db_type) ) { | |
359 $cache_name .= $ex_db_type; | |
360 } | |
361 | |
362 # if not cached, retrieve all of the xrefs for this gene | |
363 if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) ) { | |
364 $self->{$cache_name} = | |
365 $self->adaptor()->db()->get_DBEntryAdaptor() | |
366 ->fetch_all_by_Operon( $self->operon(), $db_name_exp, $ex_db_type ); | |
367 } | |
368 | |
369 $self->{$cache_name} ||= []; | |
370 | |
371 return $self->{$cache_name}; | |
372 } | |
373 | |
374 1; | |
375 |