Commit 8a8e8b4d authored by Ian Longden's avatar Ian Longden
Browse files

fix for no species being specified and more than one core database bring...

fix for no species being specified and more than one core database bring called (connection was not dropped)
parent 15a8c29a
......@@ -86,8 +86,6 @@ sub new {
bless $self,$class;
$self->dbc(new Bio::EnsEMBL::DBSQL::DBConnection(@args));
my ($species, $group, $con, $dnadb) =
rearrange([qw(SPECIES GROUP DBCONN DNADB)], @args);
......@@ -102,9 +100,9 @@ sub new {
if(defined($species)){
$self->species($species);
}
else{
$self->species("DEFAULT");
}
# else{
# $self->species("DEFAULT");
# }
if(defined($group)){
$self->group($group);
}
......
......@@ -660,6 +660,25 @@ my $self = shift;
}
}
sub get_all_DBAdaptors_by_connection{
my ($self, $dbc_orig) = @_;
my @return;
foreach my $dba ( @{$registry_register{'_DBA'}}){
my $dbc = $dba->dbc;
if($dbc->equals($dbc_orig)){
push @return, $dba;
}
}
return \@return;
}
#
# Web specific routines
#
......
......@@ -136,22 +136,49 @@ sub gen_load{
}
else{
# none standard DBA adaptor
if(!defined($dba->group())){
$dba->group('none_standard');
}
$config_sub = \&Bio::EnsEMBL::Utils::ConfigRegistry::load_and_attach_dnadb_to_core;
# throw("Unknown DBAdaptor type $dba\n");
}
# return if the connection and species, group are the same
my $db_reg = $reg->get_DBAdaptor($dba->species,$dba->group);
if(defined($db_reg)){
if($dba->dbc->equals($db_reg->dbc)){
return $db_reg;
if(defined($dba->species)){
my $db_reg = $reg->get_DBAdaptor($dba->species,$dba->group);
if(defined($db_reg)){
if($dba->dbc->equals($db_reg->dbc)){
return $db_reg;
}
else{
warn "WARN: Species and group same for two seperate databases\nModify species name for one of these\n";
$dba->species(find_unique_species($dba->species,$dba->group));
}
}
else{ # diff conn details
$dba->species(find_unique_species($dba->species,$dba->group));
}
else{ # no species
my @db_reg = @{$reg->get_all_DBAdaptors_by_connection($dba->dbc)};
foreach my $db_adaptor (@db_reg){
if($db_adaptor->group eq $dba->group){ # found same db connection and group
return $db_adaptor;
}
}
if(@db_reg){
$dba->dbc($db_reg[0]->dbc);
$dba->species($db_reg[0]->species);
}
else{
$dba->species(find_unique_species("DEFAULT",$dba->group));
if($dba->species ne "DEFAULT"){
warn "WARN: For multiple species use species attribute in DBAdaptor->new\n"
}
}
}
Bio::EnsEMBL::Registry->add_DBAdaptor($dba->species(), $dba->group(), $dba);
#call the loading subroutine. (add the adaptors to the DBAdaptor)
......
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