Archive Ensembl HomeArchive Ensembl Home
KaryotypeBand.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::DBSQL::KaryotypeBand
00024 
00025 =head1 SYNOPSIS
00026 
00027   use Bio::EnsEMBL::KaryotypeBand;
00028 
00029   # Create and populate a karyotype band (normally done by adaptor)
00030   $kb = Bio::EnsEMBL::KaryotyeBand(
00031     -START   => 1,
00032     -END     => 1_000_000,
00033     -SLICE   => $chrX_slice,
00034     -NAME    => 'q31',
00035     -STAIN   => 'gpos50',
00036     -ADAPTOR => $db->get_KaryotypeBandAdaptor(),
00037     -DBID    => 10
00038   );
00039 
00040   # Can tranform this band into other coord systems, just like other
00041   # features
00042   $kb = $kb->transform('supercontig');
00043 
00044   $start      = $kb->start();
00045   $end        = $kb->end();
00046   $seq_region = $kb->slice->seq_region_name();
00047 
00048   # Karyotypes have internal ids as well
00049   $kary_id = $kb->dbID();
00050 
00051 =head1 DESCRIPTION
00052 
00053 KaryotypeBand objects encapsulate data pertaining to a
00054 single karyotype band.  Access these objects through a
00055 Bio::EnsEMBL::DBSQL::KaryotypeBandAdaptor.
00056 
00057 KarytoypeBand inherits from Bio::EnsEMBL::Feature and can be used just
00058 as any other feature can be.
00059 
00060 =head1 METHODS
00061 
00062 =cut
00063 
00064 package Bio::EnsEMBL::KaryotypeBand;
00065 
00066 use strict;
00067 use vars qw(@ISA);
00068 
00069 use Bio::EnsEMBL::Feature;
00070 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
00071 use Bio::EnsEMBL::Utils::Exception qw(deprecate warning);
00072 
00073 @ISA = qw(Bio::EnsEMBL::Feature);
00074 
00075 
00076 =head2 new
00077 
00078   Arg [NAME] : string (optional)
00079                The name of this band
00080   Arg [STAIN]: string (optional)
00081                The stain of this band
00082   Arg [...]  : Arguments passed to superclass constructor.
00083                See Bio::EnsEMBL::Feature
00084   Example    : $kb = Bio::EnsEMBL::KaryotypeBand->new(-START => $start,
00085                                                       -END   => $end,
00086                                                       -SLICE => $slice,
00087                                                       -NAME  => 'q11.21',
00088                                                       -STAIN => 'gneg');
00089   Description: Constructor.  Creates a new KaryotypeBand object, which can be
00090                treated as any other feature object. Note that karyotypes
00091                bands always have strand = 0.
00092   Returntype : Bio::EnsEMBL::KarytotypeBand
00093   Exceptions : none
00094   Caller     : Bio::EnsEMBL::KaryotypeBandAdaptor
00095   Status     : Stable
00096 
00097 =cut
00098 
00099 sub new {
00100   my $class = shift;
00101 
00102   my $self = $class->SUPER::new(@_);
00103 
00104   my ($name, $stain) = rearrange(['NAME','STAIN'],@_);
00105   $self->{'name'} = $name;
00106   $self->{'stain'} = $stain;
00107   $self->{'strand'} = 0;
00108 
00109   return $self;
00110 }
00111 
00112 
00113 =head2 name
00114 
00115   Arg [1]    : (optional) string $value
00116   Example    : my $band_name = $band->name(); 
00117   Description: Getter/Setter for the name of this band
00118   Returntype : string
00119   Exceptions : none
00120   Caller     : general
00121   Status     : Stable
00122 
00123 =cut
00124 
00125 sub name{
00126   my $self = shift;
00127   $self->{'name'} = shift if(@_);
00128   return $self->{'name'};
00129 }
00130 
00131 
00132 
00133 =head2 stain
00134 
00135   Arg [1]    : (optional) string $value
00136   Example    : my $band_stain = $band->stain();
00137   Description: get/set for the band stain (e.g. 'gpos50')
00138   Returntype : string
00139   Exceptions : none
00140   Caller     : general
00141   Status     : Stable
00142 
00143 =cut
00144 
00145 sub stain{
00146   my $self = shift;
00147   $self->{'stain'} = shift if(@_);
00148   return $self->{'stain'};
00149 }
00150 
00151 
00152 
00153 =head2 strand
00154 
00155   Arg [1]    : none
00156     Example    : $strand = $qtl_feat->strand();
00157   Description: Overrides the Feature strand method to always return a
00158                value of 0 for qtl features (they are unstranded features)
00159   Returntype : int (always 0)
00160   Exceptions : none
00161   Caller     : general
00162   Status     : Stable
00163 
00164 =cut
00165 
00166 sub strand {
00167     my $self = shift;
00168   return 0;
00169 }
00170 
00171 
00172 =head2 move
00173 
00174   Arg [1]    : $start - The new end of this band
00175   Arg [2]    : $end - The new start of this band
00176   Arg [3]    : $strand - ignored always set to 0
00177   Example    : $kb->move(1, 10_000);
00178   Description: Overrides superclass move() method to ensure strand is always 0.
00179                See Bio::EnsEMBL::Feature::move
00180   Returntype : none
00181   Exceptions : none
00182   Caller     : general
00183   Status     : Stable
00184 
00185 =cut
00186 
00187 sub move {
00188   my ($self, $start, $end, $strand) = @_;
00189 
00190   #maintain a strandedness of 0
00191   return $self->SUPER::move($start,$end,0);
00192 }
00193 
00194 
00195 =head2 display_id
00196 
00197   Arg [1]    : none
00198   Example    : print $kb->display_id();
00199   Description: This method returns a string that is considered to be
00200                the 'display' identifier.  For karyotype bands this is the
00201                name of the karyotype band or '' if no name is defined.
00202   Returntype : string
00203   Exceptions : none
00204   Caller     : web drawing code
00205   Status     : Stable
00206 
00207 =cut
00208 
00209 sub display_id {
00210   my $self = shift;
00211   return $self->{'name'} || '';
00212 }
00213 
00214 
00215 =head2 chr_name
00216 
00217   Description: DEPRECATED - use $kary_band->slice()->seq_region_name() instead
00218 
00219 =cut
00220 
00221 sub chr_name {
00222   my $self = shift;
00223 
00224   deprecate('Use $kary_band->slice()->seq_region_name() instead.');
00225   if(!$self->slice) {
00226     warning('KaryotypeBand does not have Slice - cannot get seq_region_name.');
00227     return '';
00228   }
00229 
00230   return $self->slice->seq_region_name();
00231 }
00232 
00233 
00234 1;