Archive Ensembl HomeArchive Ensembl Home
TinyExon.pm
Go to the documentation of this file.
00001 =head1 LICENSE
00002 
00003   Copyright (c) 1999-2012 The European Bioinformatics Institute and
00004   Genome Research Limited.  All rights reserved.
00005 
00006   This software is distributed under a modified Apache license.
00007   For license details, please see
00008 
00009     http://www.ensembl.org/info/about/code_licence.html
00010 
00011 =head1 CONTACT
00012 
00013   Please email comments or questions to the public Ensembl
00014   developers list at <dev@ensembl.org>.
00015 
00016   Questions may also be sent to the Ensembl help desk at
00017   <helpdesk@ensembl.org>.
00018 
00019 =cut
00020 
00021 =head1 NAME
00022 
00023 Bio::EnsEMBL::IdMapping::TinyExon - lightweight exon object
00024 
00025 =head1 SYNOPSIS
00026 
00027   # fetch an exon from the db and create a lightweight exon object
00028   # from it
00029   my $exon = $exon_adaptor->fetch_by_stable_id('ENSE000345437');
00030   my $lightweight_exon = Bio::EnsEMBL::IdMapping::TinyExon->new_fast( [
00031       $exon->dbID,
00032       $exon->stable_id,
00033       $exon->version,
00034       $exon->created_date,
00035       $exon->modified_date,
00036       $exon->start,
00037       $exon->end,
00038       $exon->strand,
00039       $exon->slice->seq_region_name,
00040       $exon->slice->coord_system_name,
00041       $exon->slice->coord_system->version,
00042       $exon->slice->subseq( $exon->start, $exon->end, $exon->strand ),
00043       $exon->phase,
00044       $need_project,
00045   ] );
00046 
00047 =head1 DESCRIPTION
00048 
00049 This is a lightweight exon object for the stable Id mapping. See the
00050 documentation in TinyFeature for general considerations about its
00051 design.
00052 
00053 =head1 METHODS
00054 
00055   start
00056   end
00057   strand
00058   seq_region_name
00059   coord_system_name
00060   coord_system_version
00061   seq
00062   phase
00063   need_project
00064   common_start
00065   common_end
00066   common_strand
00067   common_sr_name
00068   length
00069   is_known
00070 
00071 =cut
00072 
00073 
00074 package Bio::EnsEMBL::IdMapping::TinyExon;
00075 
00076 # internal data structure (array indices):
00077 #
00078 #  0-4 see TinyFeature
00079 #  5  start
00080 #  6  end
00081 #  7  strand
00082 #  8  seq_region_name
00083 #  9  coord_system_name
00084 # 10  coord_system_version
00085 # 11  seq
00086 # 12  phase
00087 # 13  need_project
00088 # 14  common_start
00089 # 15  common_end
00090 # 16  common_strand
00091 # 17  common_sr_name
00092 
00093 
00094 use strict;
00095 use warnings;
00096 no warnings 'uninitialized';
00097 
00098 use Bio::EnsEMBL::IdMapping::TinyFeature;
00099 our @ISA = qw(Bio::EnsEMBL::IdMapping::TinyFeature);
00100 
00101 use Bio::EnsEMBL::Utils::Exception qw(throw warning);
00102 
00103 
00104 =head2 start
00105 
00106   Arg[1]      : (optional) Int - the exon's start coordinate
00107   Description : Getter/setter for the exon's start coordinate.
00108   Return type : Int
00109   Exceptions  : none
00110   Caller      : general
00111   Status      : At Risk
00112               : under development
00113 
00114 =cut
00115 
00116 sub start {
00117   my $self = shift;
00118   $self->[5] = shift if (@_);
00119   return $self->[5];
00120 }
00121 
00122 
00123 =head2 end
00124 
00125   Arg[1]      : (optional) Int - the exon's end coordinate
00126   Description : Getter/setter for the exon's end coordinate.
00127   Return type : Int
00128   Exceptions  : none
00129   Caller      : general
00130   Status      : At Risk
00131               : under development
00132 
00133 =cut
00134 
00135 sub end {
00136   my $self = shift;
00137   $self->[6] = shift if (@_);
00138   return $self->[6];
00139 }
00140 
00141 
00142 =head2 strand
00143 
00144   Arg[1]      : (optional) Int - the exon's strand
00145   Description : Getter/setter for the exon's strand.
00146   Return type : Int
00147   Exceptions  : none
00148   Caller      : general
00149   Status      : At Risk
00150               : under development
00151 
00152 =cut
00153 
00154 sub strand {
00155   my $self = shift;
00156   $self->[7] = shift if (@_);
00157   return $self->[7];
00158 }
00159 
00160 
00161 =head2 seq_region_name
00162 
00163   Arg[1]      : (optional) String - seq_region name
00164   Description : Getter/setter for the seq_region name of the slice the exon is
00165                 on.
00166   Return type : String
00167   Exceptions  : none
00168   Caller      : general
00169   Status      : At Risk
00170               : under development
00171 
00172 =cut
00173 
00174 sub seq_region_name {
00175   my $self = shift;
00176   $self->[8] = shift if (@_);
00177   return $self->[8];
00178 }
00179 
00180 
00181 =head2 coord_system_name
00182 
00183   Arg[1]      : (optional) String - coord_system name
00184   Description : Getter/setter for the coord_system name of the slice the exon is
00185                 on.
00186   Return type : String
00187   Exceptions  : none
00188   Caller      : general
00189   Status      : At Risk
00190               : under development
00191 
00192 =cut
00193 
00194 sub coord_system_name {
00195   my $self = shift;
00196   $self->[9] = shift if (@_);
00197   return $self->[9];
00198 }
00199 
00200 
00201 =head2 coord_system_version
00202 
00203   Arg[1]      : (optional) String - coord_system version
00204   Description : Getter/setter for the coord_system version of the slice the
00205                 exon is on.
00206   Return type : String
00207   Exceptions  : none
00208   Caller      : general
00209   Status      : At Risk
00210               : under development
00211 
00212 =cut
00213 
00214 sub coord_system_version {
00215   my $self = shift;
00216   $self->[10] = shift if (@_);
00217   return $self->[10];
00218 }
00219 
00220 
00221 =head2 seq
00222 
00223   Arg[1]      : (optional) String - the exon's sequence
00224   Description : Getter/setter for the exon's sequence.
00225   Return type : String
00226   Exceptions  : none
00227   Caller      : general
00228   Status      : At Risk
00229               : under development
00230 
00231 =cut
00232 
00233 sub seq {
00234   my $self = shift;
00235   $self->[11] = shift if (@_);
00236   return $self->[11];
00237 }
00238 
00239 
00240 =head2 phase
00241 
00242   Arg[1]      : (optional) Int - the exon's phase
00243   Description : Getter/setter for the exon's phase.
00244   Return type : Int
00245   Exceptions  : none
00246   Caller      : general
00247   Status      : At Risk
00248               : under development
00249 
00250 =cut
00251 
00252 sub phase {
00253   my $self = shift;
00254   $self->[12] = shift if (@_);
00255   return $self->[12];
00256 }
00257 
00258 
00259 =head2 need_project
00260 
00261   Arg[1]      : (optional) Boolean - attribute to set
00262   Description : Getter/setter for the attribute determining whether an exon
00263                 needs to be projected onto a common coord_system. You don't need
00264                 to do so if the native coord_system is common to the source and
00265                 target assemblies, or if no common coord_system is found (the
00266                 Cache object has methods to determine this).
00267   Return type : Boolean
00268   Exceptions  : none
00269   Caller      : general
00270   Status      : At Risk
00271               : under development
00272 
00273 =cut
00274 
00275 sub need_project {
00276   my $self = shift;
00277   $self->[13] = shift if (@_);
00278   return $self->[13];
00279 }
00280 
00281 
00282 =head2 common_start
00283 
00284   Arg[1]      : (optional) Int - the exon's start in common coord_system
00285                 coordinates
00286   Description : Getter/setter for the exon's start in common coord_system
00287                 coordinates. Will return $self->start if no projection to a
00288                 common coord_system is required.
00289   Return type : Int
00290   Exceptions  : none
00291   Caller      : general
00292   Status      : At Risk
00293               : under development
00294 
00295 =cut
00296 
00297 sub common_start {
00298   my $self = shift;
00299 
00300   # when used as a setter, always set a value
00301   $self->[14] = shift if (@_);
00302 
00303   # when used as a getter
00304   if (scalar(@$self) > 14) {
00305     # return value for common coord_system if available (but avoid
00306     # autovivification gotcha!)
00307     return $self->[14];
00308   } elsif ($self->need_project) {
00309     # return undef if common value expected but not there (e.g. no projection
00310     # found
00311     return undef;
00312   } else {
00313     # return native value
00314     return $self->start;
00315   }
00316 }
00317 
00318 
00319 =head2 common_end
00320 
00321   Arg[1]      : (optional) Int - the exon's end in common coord_system
00322                 coordinates
00323   Description : Getter/setter for the exon's end in common coord_system
00324                 coordinates. Will return $self->end if no projection to a
00325                 common coord_system is required.
00326   Return type : Int
00327   Exceptions  : none
00328   Caller      : general
00329   Status      : At Risk
00330               : under development
00331 
00332 =cut
00333 
00334 sub common_end {
00335   my $self = shift;
00336 
00337   # when used as a setter, always set a value
00338   $self->[15] = shift if (@_);
00339 
00340   # when used as a getter
00341   if (scalar(@$self) > 14) {
00342     # return value for common coord_system if available (but avoid
00343     # autovivification gotcha!)
00344     return $self->[15];
00345   } elsif ($self->need_project) {
00346     # return undef if common value expected but not there (e.g. no projection
00347     # found
00348     return undef;
00349   } else {
00350     # return native value
00351     return $self->end;
00352   }
00353 }
00354 
00355 
00356 =head2 common_strand
00357 
00358   Arg[1]      : (optional) Int - the exon's strand in common coord_system
00359                 coordinates
00360   Description : Getter/setter for the exon's strand in common coord_system
00361                 coordinates. Will return $self->strand if no projection to a
00362                 common coord_system is required.
00363   Return type : Int
00364   Exceptions  : none
00365   Caller      : general
00366   Status      : At Risk
00367               : under development
00368 
00369 =cut
00370 
00371 sub common_strand {
00372   my $self = shift;
00373 
00374   # when used as a setter, always set a value
00375   $self->[16] = shift if (@_);
00376 
00377   # when used as a getter
00378   if (scalar(@$self) > 14) {
00379     # return value for common coord_system if available (but avoid
00380     # autovivification gotcha!)
00381     return $self->[16];
00382   } elsif ($self->need_project) {
00383     # return undef if common value expected but not there (e.g. no projection
00384     # found
00385     return undef;
00386   } else {
00387     # return native value
00388     return $self->strand;
00389   }
00390 }
00391 
00392 
00393 =head2 common_sr_name
00394 
00395   Arg[1]      : (optional) String - seq_region name of the exon's slice on the
00396                 common coord_system
00397   Description : Getter/setter for the seq_region name of the exon's slice on the
00398                 common coord_system coordinates. Will return
00399                 $self->seq_region_name if no projection to a common coord_system
00400                 is required.
00401   Return type : String
00402   Exceptions  : none
00403   Caller      : general
00404   Status      : At Risk
00405               : under development
00406 
00407 =cut
00408 
00409 sub common_sr_name {
00410   my $self = shift;
00411 
00412   # when used as a setter, always set a value
00413   $self->[17] = shift if (@_);
00414 
00415   # when used as a getter
00416   if (scalar(@$self) > 14) {
00417     # return value for common coord_system if available (but avoid
00418     # autovivification gotcha!)
00419     return $self->[17];
00420   } elsif ($self->need_project) {
00421     # return undef if common value expected but not there (e.g. no projection
00422     # found
00423     return undef;
00424   } else {
00425     # return native value
00426     return $self->seq_region_name;
00427   }
00428 }
00429 
00430 
00431 =head2 length
00432 
00433   Description : Returns the exon length (distance between start and end).
00434   Return type : Int
00435   Exceptions  : none
00436   Caller      : general
00437   Status      : At Risk
00438               : under development
00439 
00440 =cut
00441 
00442 sub length {
00443   my $self = shift;
00444   return ($self->end - $self->start + 1);
00445 }
00446 
00447 
00448 =head2 is_known
00449 
00450   Description : Determine whether an exon is known. In the context of stable Id
00451                 mapping, this is true for all exons.
00452   Return type : Boolean
00453   Exceptions  : none
00454   Caller      : general
00455   Status      : At Risk
00456               : under development
00457 
00458 =cut
00459 
00460 sub is_known {
00461   return 1;
00462 }
00463 
00464 
00465 1;
00466