3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
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
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.
24 Please email comments or questions to the
public Ensembl
25 developers list at <http:
27 Questions may also be sent to the Ensembl help desk at
43 -DISPLAY_LABEL => $name
46 # print operon information
47 print(
"operon start:end:strand is "
48 . join(
":",
map { $operon->$_ } qw(start end strand) )
53 A representation of an
Operon within the Ensembl system.
54 An operon is a collection of one or more polycistronic transcripts which contain one or more genes.
60 package Bio::EnsEMBL::Operon;
76 int - start postion of the operon
78 int - end position of the operon
80 int - 1,-1 the strand the operon is on
84 string - the stable identifier of
this operon
86 int - the version of the stable identifier of
this operon
88 A name/label
for this operon
90 string - the date the operon was created
92 string - the date the operon was last modified
95 Description: Creates a
new operon
object
106 my $class = ref($caller) || $caller;
107 my $self = $class->SUPER::new(@_);
108 my ( $stable_id, $version, $created_date, $modified_date,$display_label) =
109 rearrange( [
'STABLE_ID',
'VERSION',
110 'CREATED_DATE',
'MODIFIED_DATE',
114 $self->stable_id($stable_id);
115 $self->version($version);
116 $self->{
'created_date'} = $created_date;
117 $self->{
'modified_date'} = $modified_date;
118 $self->display_label($display_label);
125 Arg [1] : (optional) String - created date to set (as a UNIX time
int)
126 Example : $gene->created_date(
'1141948800');
127 Description: Getter/setter
for attribute created_date
137 $self->{
'created_date'} = shift
if ( @_ );
138 return $self->{
'created_date'};
144 Arg [1] : (optional) String - modified date to set (as a UNIX time
int)
145 Example : $gene->modified_date(
'1141948800');
146 Description: Getter/setter
for attribute modified_date
156 $self->{
'modified_date'} = shift
if ( @_ );
157 return $self->{
'modified_date'};
163 Arg [1] : (optional) String - the name/label to set
164 Example : $operon->name(
'accBCD');
165 Description: Getter/setter
for attribute name.
166 Returntype : String or undef
175 $self->{
'display_label'} = shift
if (@_);
176 return $self->{
'display_label'};
181 Arg [1] : (optional) String - the stable ID to set
182 Example : $operon->stable_id(
"accR2");
183 Description: Getter/setter
for stable
id for this operon.
193 $self->{
'stable_id'} = shift
if (@_);
194 return $self->{
'stable_id'};
199 Arg [1] : (optional) Int - the stable ID version to set
200 Example : $operon->version(1);
201 Description: Getter/setter
for stable
id version
for this operon.
210 $self->{
'version'} = shift
if(@_);
211 return $self->{
'version'};
214 =head2 stable_id_version
216 Arg [1] : (optional) String - the stable ID with version to set
217 Example : $operon->stable_id(
"accR2.3");
218 Description: Getter/setter
for stable
id with version
for this operon.
226 sub stable_id_version {
228 if(my $stable_id = shift) {
229 # See if there's an embedded period, assume that's a
230 # version, might not work for some species but you
231 # should use ->stable_id() and version() if you're worried
233 my $vindex = rindex($stable_id,
'.');
234 # Set the stable_id and version pair depending on if
235 # we found a version delimiter in the stable_id
236 ($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
237 (substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
240 return $self->{stable_id} . ($self->{version} ?
".$self->{version}" :
'');
243 =head2 get_all_OperonTranscripts
245 Example : my $ots = $operon->get_all_OperonTranscripts();
246 Description: Retrieve all operon transcripts belonging to
this operon
253 sub get_all_OperonTranscripts {
255 if ( !exists $self->{
'_operon_transcript_array'} ) {
256 if ( defined $self->adaptor() ) {
257 my $ta = $self->
adaptor()->
db()->get_OperonTranscriptAdaptor();
258 my $transcripts = $ta->fetch_all_by_Operon($self);
259 $self->{
'_operon_transcript_array'} = $transcripts;
262 return $self->{
'_operon_transcript_array'};
265 =head2 add_OperonTranscript
268 Example : $operon->add_OperonTranscript($ot);
269 Description: Attach a polycistronic operon
transcript to
this operon
275 sub add_OperonTranscript {
276 my ( $self, $trans ) = @_;
278 assert_ref($trans,
"Bio::EnsEMBL::OperonTranscript");
280 $self->{
'_operon_transcript_array'} ||= [];
281 push( @{ $self->{
'_operon_transcript_array'} }, $trans );
283 #$self->recalculate_coordinates();
290 The dbEntry to be added
291 Example : my $dbe = Bio::EnsEMBL::DBEntery->
new(...);
292 $operon->add_DBEntry($dbe);
293 Description: Associates a DBEntry with
this operon. Note that adding DBEntries
294 will prevent future lazy-loading of DBEntries
for this operon
295 (see get_all_DBEntries).
297 Exceptions : thrown on incorrect argument type
307 unless($dbe && ref($dbe) && $dbe->isa(
'Bio::EnsEMBL::DBEntry')) {
308 throw(
'Expected DBEntry argument');
311 $self->{
'dbentries'} ||= [];
312 push @{$self->{
'dbentries'}}, $dbe;
316 =head2 get_all_Attributes
318 Arg [1] : (optional) String $attrib_code
319 The code of the attribute type to retrieve values
for
320 Example : my ($author) = @{ $operon->get_all_Attributes(
'author') };
321 my @operon_attributes = @{ $operon->get_all_Attributes };
322 Description: Gets a list of Attributes of
this operon.
323 Optionally just get Attributes
for given code.
325 Exceptions : warning
if gene does not have attached adaptor and attempts lazy
332 sub get_all_Attributes {
334 my $attrib_code = shift;
336 if ( !exists $self->{
'attributes'} ) {
337 if ( !$self->adaptor() ) {
341 my $attribute_adaptor = $self->adaptor->db->get_AttributeAdaptor();
342 $self->{
'attributes'} = $attribute_adaptor->fetch_all_by_Operon($self);
345 if ( defined $attrib_code ) {
347 grep { uc( $_->code() ) eq uc($attrib_code) }
348 @{ $self->{
'attributes'} };
351 return $self->{
'attributes'};
355 =head2 get_all_DBEntries
357 Arg [1] : (optional) String, external database name
359 Arg [2] : (optional) String, external_db type
361 Example : @dbentries = @{ $gene->get_all_DBEntries() };
363 Description: Retrieves DBEntries (xrefs)
for this operon. This does
364 *not* include DBEntries that are associated with the
365 transcripts and corresponding translations of
this
366 gene (see get_all_DBLinks()).
368 This method will attempt to lazy-load DBEntries
369 from a database
if an adaptor is available and no
370 DBEntries are present on the gene (i.e. they have not
371 already been added or loaded).
375 Caller : get_all_DBLinks, OperonAdaptor::store
380 sub get_all_DBEntries {
381 my ( $self, $db_name_exp, $ex_db_type ) = @_;
383 my $cache_name =
'dbentries';
385 if ( defined($db_name_exp) ) {
386 $cache_name .= $db_name_exp;
389 if ( defined($ex_db_type) ) {
390 $cache_name .= $ex_db_type;
393 # if not cached, retrieve all of the xrefs for this gene
394 if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) ) {
395 $self->{$cache_name} =
396 $self->
adaptor()->
db()->get_DBEntryAdaptor()
397 ->fetch_all_by_Operon( $self, $db_name_exp, $ex_db_type );
400 $self->{$cache_name} ||= [];
402 return $self->{$cache_name};