Archive Ensembl HomeArchive Ensembl Home
ProxySNPAdaptor.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::ProxySNPAdaptor
00024 
00025 =head1 SYNOPSIS
00026 
00027 Designed as an abstraction over the database specific SNPAdaptors. This
00028 is written right now to serve as a replacement for a core SNPadaptor
00029 which doesn''t even exist yet and probably never will since SNPs are
00030 taken from external databases. In the future some sort of DBRegistry may
00031 remove the need for this class.
00032 
00033 =head1 METHODS
00034 
00035 =cut
00036 
00037 package Bio::EnsEMBL::DBSQL::ProxySNPAdaptor;
00038 
00039 use strict;
00040 
00041 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
00042 use Bio::EnsEMBL::Utils::Exception qw(throw);
00043 
00044 use vars ('@ISA', '$AUTOLOAD');
00045 
00046 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
00047 
00048 =head2 fetch_attributes_only
00049 
00050   Arg [1]    : int refsnp_id
00051   Arg [2]    : (optional) string source
00052   Example    : none
00053   Description: Retrieves a snp objcet from the SNP database but does not
00054                populate the location information.  This is necessary given 
00055                the current state of the snp database because location 
00056                information has to be retrieved differently for different 
00057                species!
00058   Returntype : Bio::EnsEMBL::SNP
00059   Exceptions : none
00060   Caller     : snpview
00061 
00062 =cut
00063 
00064 
00065 
00066 sub fetch_attributes_only{
00067     my ( $self, @args ) = @_;
00068 
00069   my $lite_db = Bio::EnsEMBL::Registry->get_db($self->db(),'lite');
00070   my $snp_db = Bio::EnsEMBL::Registry->get_db($self->db(),'SNP');
00071 
00072   if( defined $snp_db ) {
00073       my $snp_adaptor = $snp_db->get_SNPAdaptor();
00074       return $snp_adaptor->fetch_attributes_only( @args );
00075   }
00076 
00077   if( defined $lite_db ) {
00078       my $snp_adaptor = $lite_db->get_SNPAdaptor();
00079       return $snp_adaptor->fetch_attributes_only( @args );
00080   }
00081 
00082 }
00083 
00084 
00085 
00086 
00087 =head2 AUTOLOAD
00088 
00089   Arg [1]    : list of arbitrary values @args
00090                a list of arguments to pass to the request method
00091   Example    : -
00092   Description: AUTOLOAD method should not be called directly.  It is called
00093                implicitly when a method requested from this class cannot be
00094                found. This method first tries to execute the requested method
00095                in the primary adaptor.  If the method cannot be found then 
00096                it searches the other attached databases for equivalent adaptors
00097                and tries then one at a time.
00098   Returntype : arbitrary
00099   Exceptions : thrown if the requested method cannot be found on the primary
00100                adaptor or on any of the attached databases.
00101   Caller     : called implicitly by perl
00102 
00103 =cut
00104 
00105 sub AUTOLOAD {
00106   my ($self, @args) =  @_;
00107   
00108   #determine the method which was called
00109   my $method = $AUTOLOAD;
00110   
00111   #strip out fully qualified method name
00112   $method =~ s/.*:://;
00113 
00114   my $lite_db = Bio::EnsEMBL::Registry->get_db($self->db(),'lite');
00115   my $snp_db = Bio::EnsEMBL::Registry->get_db($self->db(),'SNP');
00116 
00117   if( defined $lite_db ) {
00118       my $snp_adaptor = $lite_db->get_SNPAdaptor();
00119       if($snp_adaptor->can($method)) {
00120       return $snp_adaptor->$method(@args);
00121       } 
00122   }
00123 
00124   if( defined $snp_db ) {
00125       my $snp_adaptor = $snp_db->get_SNPAdaptor();
00126       if($snp_adaptor->can($method)) {
00127       return $snp_adaptor->$method(@args);
00128       }
00129   }
00130 
00131 
00132 
00133   throw("The requested method $method could not be found in lite or snp" );
00134 }
00135 
00136 sub DESTROY {
00137 }
00138 
00139 1;
00140 
00141 __END__