sub database_hash
{ my ($self, $name, $db) = @_;
if(!$self->{'db_hash'}){
$self->{'db_hash'} = {};
}
if($name && $db){
$self->{'db_hash'}->{$name} = $db;
}
return $self->{'db_hash'}; } |
sub get_dbadaptor
{ my ($self, $name, $use_pipeline_adaptor) = @_;
my $hash = $self->database_hash;
my $db;
if(!$hash->{$name}){
if (exists $DATABASES->{$name}) {
my $constructor_args = $DATABASES->{$name};
foreach my $arg ( qw ( -user -port -host -dbname) ) {
unless ( $$constructor_args{$arg}){
throw ("Database-connection-details not properly configured : Arguemnt : $arg missing in Databases.pm\n") ;
}
}
if ( $use_pipeline_adaptor ) {
$db = Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor->new(
%$constructor_args,
);
} else {
$db = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
%$constructor_args,
);
}
if($name ne $DNA_DBNAME ){
if (length($DNA_DBNAME) ne 0 ){
my $dnadb = $self->get_dbadaptor($DNA_DBNAME);
$db->dnadb($dnadb);
}else{
warning("You haven't defined a DNA_DBNAME in Config/Databases.pm");
}
}
$self->database_hash($name, $db);
} else {
throw("No entry in Config/Databases.pm hash for $name");
}
}else{
$db = $hash->{$name};
}
throw("Unable to find a db with name ".$name) if not $db;
return $db;
}
1; } |