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