Archive Ensembl HomeArchive Ensembl Home
Coordinate.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::Mapper::Coordinate
00024 
00025 =head1 SYNOPSIS
00026 
00027 =head1 DESCRIPTION
00028 
00029 Representation of a mapped region in a sequence; returned from Mapper.pm
00030 when the target region maps on to valid sequence.
00031 
00032 =head1 METHODS
00033 
00034 =cut
00035 
00036 package Bio::EnsEMBL::Mapper::Coordinate;
00037 
00038 use strict;
00039 
00040 =head2 new
00041 
00042   Arg [1]     char|int id of object in mapped region
00043   Arg [2]     int start of region   
00044   Arg [3]     int end of region
00045   Arg [4]     int strand if region
00046   Arg [5]     Bio::EnsEMBL::CoordSystem  coordsytem of the region
00047   Function    creates a new Coordinate object
00048   Returntype  Bio::EnsEMBL::Mapper::Coordinate
00049   Exceptions  none
00050   Status      Stable
00051 
00052 =cut
00053 
00054 sub new {
00055   my ( $proto, $id, $start, $end, $strand, $coord_system, $rank ) = @_;
00056 
00057   my $class = ref($proto) || $proto;
00058 
00059   return
00060     bless( { 'id'           => $id,
00061              'start'        => $start,
00062              'end'          => $end,
00063              'strand'       => $strand,
00064              'coord_system' => $coord_system,
00065              'rank'         => $rank || 0
00066            },
00067            $class );
00068 }
00069 
00070 
00071 =head2 start
00072 
00073   Arg  1      int $start
00074               start coordinate of object in mapped region
00075   Function    getter/setter method
00076   Returntype  int
00077   Exceptions  none
00078   Caller      Bio::EnsEMBL::Mapper::Coordinate
00079   Status      Stable
00080 
00081 =cut
00082 
00083 sub start {
00084   my ( $self, $value ) = @_;
00085 
00086   if ( defined($value) ) {
00087     $self->{'start'} = $value;
00088   }
00089 
00090   return $self->{'start'};
00091 }
00092 
00093 
00094 =head2 end
00095 
00096   Arg  1      int $end
00097               end coordinate of object in mapped region
00098   Function    getter/setter method
00099   Returntype  int
00100   Exceptions  none
00101   Caller      Bio::EnsEMBL::Mapper::Coordinate
00102   Status      Stable
00103 
00104 =cut
00105 
00106 sub end {
00107   my ( $self, $value ) = @_;
00108 
00109   if ( defined($value) ) {
00110     $self->{'end'} = $value;
00111   }
00112 
00113   return $self->{'end'};
00114 }
00115 
00116 =head2 strand
00117 
00118   Arg  1      int $strand
00119               strand of object in mapped region
00120   Function    getter/setter method
00121   Returntype  int
00122   Exceptions  none
00123   Caller      Bio::EnsEMBL::Mapper::Coordinate
00124   Status      Stable
00125 
00126 =cut
00127 
00128 sub strand {
00129   my ( $self, $value ) = @_;
00130 
00131   if ( defined($value) ) {
00132     $self->{'strand'} = $value;
00133   }
00134 
00135   return $self->{'strand'};
00136 }
00137 
00138 =head2 id
00139 
00140   Arg  1      char|int $id
00141               id of object in mapped region
00142           e.g. seq_region_id / seq_region_name
00143   Function    getter/setter method
00144   Returntype  char|int
00145   Exceptions  none
00146   Caller      Bio::EnsEMBL::Mapper::Coordinate
00147   Status      Stable
00148 
00149 =cut
00150 
00151 sub id {
00152   my ( $self, $value ) = @_;
00153 
00154   if ( defined($value) ) {
00155     $self->{'id'} = $value;
00156   }
00157 
00158   return $self->{'id'};
00159 }
00160 
00161 =head2 coord_system
00162 
00163   Arg  1      Bio::EnsEMBL::CoordSystem
00164   Function    getter/setter method
00165   Returntype  Bio::EnsEMBL::CoordSystem
00166   Exceptions  none
00167   Caller      Bio::EnsEMBL::Mapper::Coordinate
00168   Status      Stable
00169 
00170 =cut
00171 
00172 sub coord_system {
00173   my ( $self, $value ) = @_;
00174 
00175   if ( defined($value) ) {
00176     $self->{'coord_system'} = $value;
00177   }
00178 
00179   return $self->{'coord_system'};
00180 }
00181 
00182 =head2 length
00183 
00184   Function    getter method
00185   Returntype  int
00186   Exceptions  none
00187   Caller      ?
00188   Status      Stable
00189 
00190 =cut
00191 
00192 sub length {
00193   my ($self) = @_;
00194 
00195   return $self->{'end'} - $self->{'start'} + 1;
00196 }
00197 
00198 sub rank {
00199   my ( $self, $value ) = @_;
00200 
00201   if ( defined($value) ) {
00202     $self->{'rank'} = $value;
00203   }
00204 
00205   return $self->{'rank'};
00206 }
00207 
00208 1;