Archive Ensembl HomeArchive Ensembl Home
Qtl.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::Map::Qtl
00024 
00025 =head1 SYNOPSIS
00026 
00027 =head1 DESCRIPTION
00028 
00029 Represents a Qtl in the EnsEMBL database. A quantitative trait locus is
00030 defined by three markers, two flanking and one peak (optional) marker.
00031 Its a region (or more often a group of regions) which is likely to
00032 affect the phenotype (trait) described in this Qtl.
00033 
00034 =head1 METHODS
00035 
00036 =cut
00037 
00038 package Bio::EnsEMBL::Map::Qtl;
00039 
00040 use strict;
00041 use vars qw(@ISA);
00042 
00043 use Bio::EnsEMBL::Storable;
00044 use Bio::EnsEMBL::Utils::Exception qw(throw deprecate);
00045 
00046 @ISA = qw(Bio::EnsEMBL::Storable);
00047 
00048 
00049 
00050 =head2 new
00051 
00052   Arg [1]    : int $dbID
00053   Arg [2]    : Bio::EnsEMBL::Map::DBSQL::QtlAdaptor $adaptor
00054   Arg [3]    : Bio::EnsEMBL::Map::Marker $flank_marker_1
00055   Arg [4]    : Bio::EnsEMBL::Map::Marker $peak_marker
00056   Arg [5]    : Bio::EnsEMBL::Map::Marker $flank_marker_2
00057   Arg [6]    : string $trait
00058   Arg [7]    : float $lod_score
00059   Arg [8]    : hashref $synonyms
00060                A hashref with source keys and identifier values
00061   Example    : none
00062   Description: Creates a new Qtl object. Usually done by Adaptor
00063   Returntype : Bio::EnsEMBL::Map::Qtl
00064   Exceptions : none
00065   Caller     : general, DBSQL::QtlAdaptor, DBSQL::QtlFeatureAdaptor
00066   Status     : stable
00067 
00068 =cut
00069 
00070 sub new {
00071   my ( $class, $dbID, $adaptor, $flank_marker_1, $peak_marker,
00072        $flank_marker_2, $trait, $lod_score,
00073        $synonyms ) = @_;
00074 
00075   $class = ref( $class ) ||$class;
00076   my $self = bless( {
00077              'dbID'           => $dbID,
00078              'flank_marker_1' => $flank_marker_1,
00079              'flank_marker_2' => $flank_marker_2,
00080              'peak_marker'    => $peak_marker,
00081              'trait'          => $trait,
00082              'lod_score'      => $lod_score,
00083              'synonyms'       => $synonyms
00084             }, $class );
00085   $self->adaptor($adaptor);
00086   return $self;
00087 }
00088 
00089 
00090 =head2 add_synonym
00091 
00092   Arg [1]    : string $source
00093                The source of the synonym
00094   Arg [2]    : string $identifier
00095                The identifier from this source
00096   Example    : $qtl->add_synonym('rat genome database', '65516');
00097   Description: Adds a synonym to this qtl
00098   Returntype : none
00099   Exceptions : thrown if arguments are not provided
00100   Caller     : general
00101   Status     : stable
00102 
00103 =cut
00104 
00105 sub add_synonym {
00106   my $self = shift;
00107   my $source = shift;
00108   my $identifier = shift;
00109 
00110   unless($source && $identifier) {
00111     throw('Source and identifier arguments are required');
00112   }
00113 
00114   $self->{'synonyms'}->{$source} = $identifier;
00115 }
00116 
00117 
00118 =head2 get_synonyms
00119 
00120   Arg [1]    : none
00121   Example    :
00122      foreach my $source ($keys %{$qtl->get_synonyms}) {
00123        print $source . ':'. $qtl->get_synonyms->{$source};
00124      }
00125   Description: Returns a hashref of synonyms keyed on their source name 
00126   Returntype : hashref of synonyms keyed on their source name
00127   Exceptions : none
00128   Caller     : general
00129   Status     : stable
00130 
00131 =cut
00132 
00133 sub get_synonyms {
00134   my $self = shift;
00135 
00136   return $self->{'synonyms'} || {};
00137 }
00138 
00139 
00140 
00141 =head2 trait
00142 
00143   Arg [1]    : string $trait
00144                Phenotype of this Qtl
00145   Example    : none
00146   Description: Getter/Setter for the trait attribute
00147   Returntype : string
00148   Exceptions : none
00149   Caller     : general
00150   Status     : stable
00151 
00152 =cut
00153 
00154 sub trait {
00155   my $self = shift;
00156 
00157   if(@_) {
00158     $self->{'trait'} = shift;
00159   }
00160 
00161   return $self->{'trait'};
00162 }
00163 
00164 
00165 =head2 lod_score
00166 
00167   Arg [1]    : float $lod_score
00168                A score for the Qtl
00169   Example    : none
00170   Description: Getter/Setter for attribute lod_score
00171   Returntype : float
00172   Exceptions : none
00173   Caller     : general
00174   Status     : stable
00175 
00176 =cut
00177 
00178 sub lod_score {
00179   my $self = shift;
00180 
00181   if(@_) {
00182     $self->{'lod_score'} = shift;
00183   }
00184 
00185   return $self->{'lod_score'};
00186 }
00187 
00188 
00189 =head2 peak_marker
00190 
00191   Arg [1]    : Bio::EnsEMBL::Map::Marker $peak_marker
00192                an optional Marker which has the peak probablitity
00193                for this traits occurence
00194   Example    : none
00195   Description: Getter/Setter for attribute peak_marker
00196   Returntype : Bio::EnsEMBL::Map::Marker
00197   Exceptions : none
00198   Caller     : general
00199   Status     : stable
00200 
00201 =cut
00202 
00203 sub peak_marker {
00204   my $self = shift;
00205 
00206   if(@_) {
00207     $self->{'peak_marker'} = shift;
00208   }
00209 
00210   return $self->{'peak_marker'};
00211 }
00212 
00213 
00214 =head2 flank_marker_1
00215 
00216   Arg [1]    : Bio::EnsEMBL::Map::Marker $flank_marker_1
00217                One flanking marker of the interest region, the two flanking
00218                markers define the region
00219   Example    : none
00220   Description: Getter/Setter attribute flanking_marker_1
00221   Returntype : Bio::EnsEMBL::Map::Marker
00222   Exceptions : none
00223   Caller     : general
00224   Status     : stable
00225 
00226 =cut
00227 
00228 sub flank_marker_1 {
00229   my $self = shift;
00230 
00231   if(@_) {
00232     $self->{'flank_marker_1'} = shift;
00233   }
00234 
00235   return $self->{'flank_marker_1'};
00236 }
00237 
00238 
00239 
00240 =head2 flank_marker_2
00241 
00242   Arg [1]    : Bio::EnsEMBL::Map::Marker $flank_marker_2
00243                One flanking marker of the interest region, the two flanking
00244                markers define the region
00245   Example    : none
00246   Description: Getter/Setter attribute flanking_marker_2
00247   Returntype : Bio::EnsEMBL::Map::Marker
00248   Exceptions : none
00249   Caller     : general
00250   Status     : stable
00251 
00252 =cut
00253 
00254 
00255 sub flank_marker_2 {
00256   my $self = shift;
00257 
00258   if(@_) {
00259     $self->{'flank_marker_2'} = shift;
00260   }
00261 
00262   return $self->{'flank_marker_2'};
00263 }
00264 
00265 
00266 
00267 =head2 get_QtlFeatures
00268 
00269   Args       : none
00270   Example    : none
00271   Description: return the qtl feature which is associated with this
00272                Qtl. It comes in chromosomal slice coordinates. There can 
00273                only be one.
00274   Returntype : Bio::EnsEMBL::Map::QtlFeature
00275   Exceptions : only works with adaptored Qtls
00276   Caller     : general
00277   Status     : stable
00278 
00279 =cut
00280 
00281 sub get_QtlFeature {
00282   my $self = shift;
00283 
00284   my $adaptor = $self->adaptor();
00285   return undef unless $adaptor;
00286   my $result = $adaptor->db()->get_QtlFeatureAdaptor()->
00287     fetch_all_by_Qtl( $self );
00288 
00289   if( @$result ) {
00290     return $result->[0];
00291   } else {
00292     return;
00293   }
00294 }
00295 
00296 
00297 
00298 
00299 
00300 =head2 source_database
00301 
00302 This method is deprecated.  Use get_synonyms or add_synonym instead.
00303 
00304 =cut
00305 
00306 sub source_database {
00307   my $self = shift;
00308 
00309   deprecate('Use get_synonyms or add_synonym instead');
00310 
00311   my $syns = $self->get_synonyms;
00312   my ($source) = keys %$syns;
00313 
00314   return $source || '';
00315 }
00316 
00317 
00318 =head2 source_primary_id
00319 
00320 This method is deprecated. Use get_synonyms or add_synonym instead.
00321 
00322 =cut
00323 
00324 sub source_primary_id {
00325   my $self = shift;
00326 
00327   deprecate('Use get_synonyms or add_synonym instead');
00328 
00329   my $syns = $self->get_synonyms;
00330   my ($source) = keys %$syns;
00331 
00332   if($source) {
00333     return $syns->{$source};
00334   }
00335 
00336   return '';
00337 }
00338 
00339 
00340 1;