Commit 7cacc925 authored by Ensembl Account's avatar Ensembl Account
Browse files

Avoid using bioperl before adaptors are requested from registry

parent e3fbf042
......@@ -259,52 +259,6 @@ sub get_db_adaptor {
return Bio::EnsEMBL::Registry->get_db($self, $name);
}
sub get_SNPAdaptor {
my ($self) = @_;
my $primary_adaptor;
# try new method
my $new = 0;
$primary_adaptor = $reg->get_adaptor($self->species(),'lite','SNP');
if(defined($primary_adaptor)){
$new = 1;
}
else{
$primary_adaptor = $reg->get_adaptor($self->species(),'SNP','SNP');
if(defined($primary_adaptor)){
$new = 1;
$primary_adaptor->ensembl_db( $self );
}
}
if($new){ # found a primary adaptor
my $ret = $self->get_adaptor("ProxySNP");
$ret->set_primary($primary_adaptor);
return $ret;
}
my $lite = $self->get_db_adaptor('lite'); #### use register directly here
if($lite) {
$primary_adaptor = $lite->get_SNPAdaptor();
} else {
my $snp = $self->get_db_adaptor('SNP');
unless($snp) {
warn("No lite or SNP database, cannot get snp adaptor");
return undef;
}
$primary_adaptor = $snp->get_SNPAdaptor();
$primary_adaptor->ensembl_db( $self );
}
#return a proxy adaptor which can use the lite or the core database
my $ret = $self->get_adaptor("ProxySNP");
$ret->set_primary($primary_adaptor);
return $ret;
# return $self->get_adaptor("ProxySNP", $primary_adaptor);
}
###########################################################
......
......@@ -2,9 +2,6 @@
#
# Copyright EMBL-EBI 2002
#
# Author: Graham McVicker
#
# Date : 05.08.2002
#
=head1 NAME
......@@ -21,110 +18,73 @@ need for this class.
=head1 CONTACT
Arne Stabenau: stabenau@ebi.ac.uk
Ewan Birney : birney@ebi.ac.uk
Graham McVicker : mcvicker@ebi.ac.uk
Post questions to the Ensembl development list <ensembl-dev@ebi.ac.uk>
=head1 APPENDIX
=head1 METHODS
=cut
use strict;
package Bio::EnsEMBL::DBSQL::ProxySNPAdaptor;
use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Bio::EnsEMBL::DBSQL::ProxyAdaptor;
use vars '@ISA';
use vars ('@ISA', '$AUTOLOAD');
@ISA = qw(Bio::EnsEMBL::DBSQL::ProxyAdaptor);
@ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
sub set_primary{
my ($self, $primary_adaptor) = @_;
#
# For old style code i will have to add primary db later when get is called
#
unless($primary_adaptor) {
throw("The primary_adaptor argument is required\n");
return undef;
}
#
# #determine the type of adaptor the proxy is filling in for
$self->{'_proxy_type'} = ref($primary_adaptor);
#
#strip out fully qualified package name
$self->{'_proxy_type'} =~ s/.*:://;
$self->{'_primary_adaptor'} = $primary_adaptor;
#
}
=head2 fetch_by_Slice
=head2 AUTOLOAD
Arg [1] : list of arbitrary args @args
Example : none
Description: Forwards request to the Lite database if it is available
If the lite database is not available the request is
forwarded to the SNP database.
Returntype : listref of Bio::EnsEMBL::ExternalData::Variation
Exceptions : thrown if neither the SNP nor Lite databases are available
Caller : snpview
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
=cut
sub fetch_all_by_Slice {
my ($self, @args) = @_;
my $lite_db = Bio::EnsEMBL::Registry->get_db($self->db(),'lite');#$self->db()->get_db_adaptor('lite');
my $snp_db = Bio::EnsEMBL::Registry->get_db($self->db(),'SNP'); #$self->db()->get_db_adaptor('SNP');
if(defined $lite_db) {
#use the Lite database if it is available
my $lite_adaptor = Bio::EnsEMBL::Registry->get_adaptor(
$lite_db->species, $lite_db->group ,"lite");
return $lite_adaptor->fetch_all_by_Slice(@args);
} elsif(defined $snp_db) {
#use the snp database if it is available
my $snp_adaptor = Bio::EnsEMBL::Registry->get_adaptor(
$snp_db->species, $snp_db->group ,"SNP");
return $snp_adaptor->fetch_all_by_Slice(@args);
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');
#
# First try the primary adaptor
#
if( defined $lite_db ) {
my $snp_adaptor = $lite_db->get_SNPAdaptor();
if($snp_adaptor->can($method)) {
return $snp_adaptor->$method(@args);
}
}
#There is no core SNPAdaptor so throw an exception if lite and SNP
#databases are unavailable
$self->throw("Lite and SNP databases are unavailable. " .
"Unable to create SNP adaptor");
return undef;
}
=head2 fetch_by_SNP_id
Arg [1] : list of arbitrary args @args
Example : none
Description: Forwards request to the Lite database if it is available
If the lite database is not available the request is
forwarded to the SNP database.
Returntype : Bio::EnsEMBL::ExternalData::Variation
Exceptions : thrown if neither the SNP nor Lite databases are available
Caller : snpview
=cut
sub fetch_by_SNP_id {
my ($self, @args) = @_;
my $snp_db = $self->db()->get_db_adaptor('SNP');
if(defined $snp_db) {
return $snp_db->get_SNPAdaptor()->fetch_by_SNP_id(@args);
my $snp_adaptor = $snp_db->get_SNPAdaptor();
if($snp_adaptor->can($method)) {
return $snp_adaptor->$method(@args);
}
$self->throw("SNP database unavailable. Unable to create SNP adaptor");
}
throw("The requested method $method could not be found in lite or snp" );
}
1;
......
......@@ -35,108 +35,8 @@ package Bio::EnsEMBL::Lite::DBAdaptor;
use vars qw(@ISA);
use strict;
use Bio::EnsEMBL::Registry;
my $reg = "Bio::EnsEMBL::Registry";
use Bio::EnsEMBL::DBSQL::DBConnection;
use Bio::EnsEMBL::Utils::Exception qw(deprecate);
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
@ISA = qw(Bio::EnsEMBL::DBSQL::DBAdaptor);
=head2 get_SNPAdaptor
Arg [1] : none
Example : my $snp_adaptor = $db->get_SNPAdaptor();
Description: Retrieves a SNPAdaptor that can be used to retrieve SNP
information from the lite database.
Returntype : Bio::EnsEMBL::Lite::SNPAdaptor
Exceptions : none
Caller : webcode, snpview
=cut
sub get_SNPAdaptor {
my $self = shift;
# return $self->_get_adaptor("Bio::EnsEMBL::Lite::SNPAdaptor");
return Bio::EnsEMBL::Registry->get_adaptor( $self->species(), "lite", "ProxySNP");
}
=head2 get_GeneAdaptor
Description: DEPRECATED, use core GeneAdaptor instead.
=cut
sub get_GeneAdaptor {
my $self = shift;
deprecate("Genes are no longer stored in the lite database.\n" .
"Use the core GeneAdaptor instead.");
my $core = $self->get_db_adaptor('core');
return ($core) ? $core->get_GeneAdaptor() : undef;
}
=head2 get_RepeatFeatureAdaptor
Description: DEPRECATED, use core RepeatFeatureAdaptor instead.
=cut
sub get_RepeatFeatureAdaptor {
my $self = shift;
deprecate("Repeats are no longer stored in the lite database.\n" .
"Use the core RepeatAdaptor instead.");
my $core = $self->get_db_adaptor('core');
return ($core) ? $core->get_RepeatFeatureAdaptor : undef;
}
=head2 get_ChromosomeAdaptor
Description: DEPRECATED, use core SliceAdaptor instead.
=cut
sub get_ChromosomeAdaptor {
my $self = shift;
deprecate("Chromosomes are no longer stored in the lite database.\n" .
"Use the core SliceAdaptor instead.");
my $core = $self->get_db_adaptor('core');
return ($core) ? $core->get_SliceAdaptor() : undef;
}
=head2 get_DensityAdaptor
Description: DEPRECATED, use core DenstiyFeatureAdaptor instead.
=cut
sub get_DensityAdaptor {
my $self = shift;
deprecate("DensityFeatures are no longer stored in the lite database.\n" .
"Use the core DensityFeatureAdaptor instead.");
my $core = $self->get_db_adaptor('core');
return ($core) ? $core->get_DensityFeatureAdaptor() : undef;
}
1;
......@@ -125,38 +125,34 @@ $registry_register{'_WARN'} = 0;
=cut
sub load_all{
my $class = shift;
my $web_reg = shift;
#$registry_register{'_WARN'} = 0; # default report overwriting
if(!defined($registry_register{'seen'})){
$registry_register{'seen'}=1;
if(defined($web_reg)){
# print STDERR "Loading conf from site defs file ".$web_reg."\n";
if(-e $web_reg){
unless (my $return = do $web_reg ){
throw "Error in Configuration\n $!\n";
my $class = shift;
my $web_reg = shift;
#$registry_register{'_WARN'} = 0; # default report overwriting
if(!defined($registry_register{'seen'})){
$registry_register{'seen'}=1;
if(defined($web_reg)){
print STDERR "Loading conf from site defs file ".$web_reg."\n";
if(-e $web_reg){
unless (my $return = do $web_reg ){
throw "Error in Configuration\n $!\n";
}
# other wise it gets done again by the web initialisation stuff
delete $INC{$web_reg};
}
}
# other wise it gets done again by the web initialisation stuff
delete $INC{$web_reg};
}
}
elsif(defined($ENV{ENSEMBL_REGISTRY}) and -e $ENV{ENSEMBL_REGISTRY}){
# print STDERR "Loading conf from ".$ENV{ENSEMBL_REGISTRY}."\n";
unless (my $return = do $ENV{ENSEMBL_REGISTRY}){
throw "Error in Configuration\n $!\n";
}
}
elsif(-e $ENV{HOME}."/.ensembl_init"){
do($ENV{HOME}."/.ensembl_init");
elsif(defined($ENV{ENSEMBL_REGISTRY}) and -e $ENV{ENSEMBL_REGISTRY}){
print STDERR "Loading conf from ".$ENV{ENSEMBL_REGISTRY}."\n";
unless (my $return = do $ENV{ENSEMBL_REGISTRY}){
throw "Error in Configuration\n $!\n";
}
}
elsif(-e $ENV{HOME}."/.ensembl_init"){
do($ENV{HOME}."/.ensembl_init");
}
print STDERR "NO default configuration to load\n";
}
# else{
# print STDERR "NO default configuration to load\n";
# }
}
# else{
# print STDERR "Already configured???\n";
# }
print STDERR "Already configured???\n";
}
#=head2 check_if_already_there
......
......@@ -43,7 +43,7 @@ my $reg = "Bio::EnsEMBL::Registry";
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::DBSQL::DBConnection;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::DBSQL::ProxySNPAdaptor;
use Bio::EnsEMBL::Utils::Exception qw(warning throw deprecate stack_trace_dump);
#use vars qw(@ISA @EXPORT_OK);
#@ISA = qw(Exporter);
......@@ -215,7 +215,7 @@ sub load_core{
'ProteinFeature' => 'Bio::EnsEMBL::DBSQL::ProteinFeatureAdaptor',
'ProteinAlignFeature' =>
'Bio::EnsEMBL::DBSQL::ProteinAlignFeatureAdaptor',
'ProxySNP' => 'Bio::EnsEMBL::DBSQL::ProxySNPAdaptor',
'SNP' => 'Bio::EnsEMBL::DBSQL::ProxySNPAdaptor',
'QtlFeature' => 'Bio::EnsEMBL::Map::DBSQL::QtlFeatureAdaptor',
'Qtl' => 'Bio::EnsEMBL::Map::DBSQL::QtlAdaptor',
'RepeatConsensus' => 'Bio::EnsEMBL::DBSQL::RepeatConsensusAdaptor',
......@@ -242,34 +242,19 @@ sub load_core{
sub load_lite{
my ($dba) = @_;
# Bio::EnsEMBL::Registry->add_DBAdaptor($dba->species, $dba->group, $dba);
eval "require Bio::EnsEMBL::Lite::SNPAdaptor";
my $adap = Bio::EnsEMBL::Lite::SNPAdaptor->new($dba);
my $prim_adap = Bio::EnsEMBL::DBSQL::ProxySNPAdaptor->new($dba,$adap);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, $dba->group, $adap);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, "ProxySNP", $prim_adap);
my ($dba) = @_;
Bio::EnsEMBL::Registry->add_DBAdaptor($dba->species, $dba->group, $dba);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, "SNP", "Bio::EnsEMBL::Lite::SNPAdaptor" );
}
sub load_SNP{
my ($dba) = @_;
# require Bio::EnsEMBL::ExternalData::SNPSQL::DBAdaptor;
require Bio::EnsEMBL::ExternalData::SNPSQL::SNPAdaptor;
# eval "require Bio::EnsEMBL::ExternalData::SNPSQL::DBAdaptor";
my $adap = Bio::EnsEMBL::ExternalData::SNPSQL::SNPAdaptor->new($dba);
my $prim_adap = Bio::EnsEMBL::DBSQL::ProxySNPAdaptor->new($dba,$adap);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, "SNP", $adap);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, "ProxySNP", $prim_adap);
Bio::EnsEMBL::Registry->add_DBAdaptor($dba->species, $dba->group, $dba);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, "SNP",
"Bio::EnsEMBL::ExternalData::SNPSQL::SNPAdaptor" );
}
sub attach_database{
......@@ -296,13 +281,11 @@ sub attach_dna{
sub load_blast{
my ($dba) = @_;
my ($dba) = @_;
eval "require Bio::EnsEMBL::External::BlastAdaptor";
my $objadap = Bio::EnsEMBL::External::BlastAdaptor->new($dba);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, 'Blast', $objadap);
Bio::EnsEMBL::Registry->add_DBAdaptor($dba->species, $dba->group, $dba);
Bio::EnsEMBL::Registry->add_adaptor($dba->species, $dba->group, 'Blast',
"Bio::EnsEMBL::External::BlastAdaptor");
}
......@@ -540,17 +523,9 @@ sub load_hive{
sub load_go{
my ($class, @args) = @_;
my ($species) = rearrange([qw(SPECIES)],@args);
require Bio::EnsEMBL::ExternalData::GO::GOAdaptor;
my $adap = new Bio::EnsEMBL::ExternalData::GO::GOAdaptor(@args);
Bio::EnsEMBL::Registry->add_alias($species,$species);
my ($class, $dba) = @_;
#not a dba adaptor but stored as one
Bio::EnsEMBL::Registry->add_DBAdaptor($species,"go",$adap );
# shouldnt go into the registry ... sorry
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment