my ($dba) = @_;
my $pre_hook;
my $config_sub;
# At some point we hope to set the group in the DBadaptor, hence this
# long check etc. should be simpler.
if ( $dba->isa('Bio::EnsEMBL::Compara::DBSQL::DBAdaptor') ) {
if ( !defined( $dba->group() ) ) {
$dba->group('compara');
}
} elsif ( $dba->isa('Bio::EnsEMBL::Lite::DBAdaptor') ) {
if ( !defined( $dba->group() ) ) {
$dba->group('lite');
}
$config_sub = \&Bio::EnsEMBL::Utils::ConfigRegistry::load_lite;
} elsif ( $dba->isa('Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor') ) {
if ( !defined( $dba->group() ) ) {
$dba->group('pipeline');
}
} elsif ( $dba->isa('Bio::EnsEMBL::Hive::DBSQL::DBAdaptor') ) {
if ( !defined( $dba->group() ) ) {
$dba->group('hive');
}
} elsif ( $dba->isa('Bio::EnsEMBL::Variation::DBSQL::DBAdaptor') ) {
if ( !defined( $dba->group() ) ) {
$dba->group('variation');
}
} elsif ( $dba->isa('Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor') ) {
if ( !defined( $dba->group() ) ) {
$dba->group('funcgen');
}
} elsif ( $dba->isa('Bio::EnsEMBL::DBSQL::OntologyDBAdaptor') || $dba->isa('Bio::Ensembl::DBSQL::OntologyTermAdaptor') ) {
if ( !defined( $dba->group() ) ) {
$dba->group('ontology');
}
} elsif ( $dba->isa('Bio::EnsEMBL::DBSQL::DBAdaptor') ) {
#vega uses the core DBAdaptor so test if vega is in the dbname
if ( !defined( $dba->group() ) ) {
$dba->group('core');
}
if ( $dba->group eq "estgene" ) {
} elsif ( $dba->group eq "otherfeatures" ) {
$config_sub =
} elsif ( $dba->group eq "rnaseq" ) {
$config_sub =
} elsif ( $dba->group eq 'vega' || $dba->group eq 'vega_update' ) {
} else {
}
} else {
# none standard DBA adaptor
if ( !defined( $dba->group() ) ) {
$dba->group('none_standard');
}
$config_sub =
# throw("Unknown DBAdaptor type $dba\n");
}
#Run the pre-hook if one was defined
$pre_hook->($dba) if $pre_hook;
# return if the connection and species, group are the same
if ( defined( $dba->species ) ) {
my $db_reg = $reg->get_DBAdaptor( $dba->species, $dba->group, 1 );
if ( defined($db_reg) ) {
if ( $dba->dbc->equals( $db_reg->dbc ) ) { return $db_reg }
else {
my $msg =
sprintf( 'WARN: Species (%s) and group (%s) '
. 'same for two seperate databases',
$dba->species(), $dba->group() );
warn "${msg}\nModify species name for one of these\n";
$dba->species(
}
}
} 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 ( $dba->species ne "DEFAULT" ) {
warn "WARN: For multiple species "
. "use species attribute in DBAdaptor->new()\n";
}
}
$dba );
#call the loading subroutine. (add the adaptors to the DBAdaptor)
&{$config_sub}($dba);
return $dba;