ProxySNPAdaptor.pm 3.99 KB
Newer Older
1 2
=head1 LICENSE

3
Copyright [1999-2013] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
4

5 6 7 8 9 10 11 12 13 14 15 16 17
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=cut
18 19 20 21 22


=head1 CONTACT

  Please email comments or questions to the public Ensembl
Magali Ruffier's avatar
Magali Ruffier committed
23
  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
24 25

  Questions may also be sent to the Ensembl help desk at
Magali Ruffier's avatar
Magali Ruffier committed
26
  <http://www.ensembl.org/Help/Contact>.
27 28

=cut
29 30 31 32 33 34 35

=head1 NAME

Bio::EnsEMBL::DBSQL::ProxySNPAdaptor

=head1 SYNOPSIS

36 37 38 39 40
Designed as an abstraction over the database specific SNPAdaptors. This
is written right now to serve as a replacement for a core SNPadaptor
which doesn''t even exist yet and probably never will since SNPs are
taken from external databases. In the future some sort of DBRegistry may
remove the need for this class.
41

42
=head1 METHODS
43 44 45

=cut

46 47
package Bio::EnsEMBL::DBSQL::ProxySNPAdaptor;

48 49
use strict;

50
use Bio::EnsEMBL::DBSQL::BaseAdaptor;
51
use Bio::EnsEMBL::Utils::Exception qw(throw);
52

53
use vars ('@ISA', '$AUTOLOAD');
54

55
@ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
56

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
=head2 fetch_attributes_only

  Arg [1]    : int refsnp_id
  Arg [2]    : (optional) string source
  Example    : none
  Description: Retrieves a snp objcet from the SNP database but does not
               populate the location information.  This is necessary given 
               the current state of the snp database because location 
               information has to be retrieved differently for different 
               species!
  Returntype : Bio::EnsEMBL::SNP
  Exceptions : none
  Caller     : snpview

=cut



sub fetch_attributes_only{
    my ( $self, @args ) = @_;

  my $lite_db = Bio::EnsEMBL::Registry->get_db($self->db(),'lite');
  my $snp_db = Bio::EnsEMBL::Registry->get_db($self->db(),'SNP');

  if( defined $snp_db ) {
      my $snp_adaptor = $snp_db->get_SNPAdaptor();
      return $snp_adaptor->fetch_attributes_only( @args );
  }

  if( defined $lite_db ) {
      my $snp_adaptor = $lite_db->get_SNPAdaptor();
      return $snp_adaptor->fetch_attributes_only( @args );
  }

}


Ian Longden's avatar
Ian Longden committed
94

95

96
=head2 AUTOLOAD
97

98 99 100 101 102 103 104 105 106 107 108 109 110
  Arg [1]    : list of arbitrary values @args
               a list of arguments to pass to the request method
  Example    : -
  Description: AUTOLOAD method should not be called directly.  It is called
               implicitly when a method requested from this class cannot be
               found. This method first tries to execute the requested method
               in the primary adaptor.  If the method cannot be found then 
               it searches the other attached databases for equivalent adaptors
               and tries then one at a time.
  Returntype : arbitrary
  Exceptions : thrown if the requested method cannot be found on the primary
               adaptor or on any of the attached databases.
  Caller     : called implicitly by perl
111 112 113

=cut

114 115 116 117 118 119 120 121 122 123 124
sub AUTOLOAD {
  my ($self, @args) =  @_;
  
  #determine the method which was called
  my $method = $AUTOLOAD;
  
  #strip out fully qualified method name
  $method =~ s/.*:://;

  my $lite_db = Bio::EnsEMBL::Registry->get_db($self->db(),'lite');
  my $snp_db = Bio::EnsEMBL::Registry->get_db($self->db(),'SNP');
125

126 127 128 129 130
  if( defined $lite_db ) {
      my $snp_adaptor = $lite_db->get_SNPAdaptor();
      if($snp_adaptor->can($method)) {
	  return $snp_adaptor->$method(@args);
      } 
131
  }
132 133 134 135 136 137

  if( defined $snp_db ) {
      my $snp_adaptor = $snp_db->get_SNPAdaptor();
      if($snp_adaptor->can($method)) {
	  return $snp_adaptor->$method(@args);
      }
138 139 140
  }


141

142 143
  throw("The requested method $method could not be found in lite or snp" );
}
144

Ian Longden's avatar
Ian Longden committed
145 146
sub DESTROY {
}
147 148 149 150

1;

__END__