Bio::EnsEMBL::Analysis::RunnableDB BaseGeneBuild
Included librariesPackage variablesGeneral documentationMethods
Toolbar
WebCvsRaw content
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Analysis::Config::Databases qw ( DATABASES DNA_DBNAME )
Bio::EnsEMBL::Analysis::RunnableDB
Bio::EnsEMBL::Analysis::Tools::Logger qw ( logger_info )
Bio::EnsEMBL::DBSQL::DBAdaptor
Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor
Bio::EnsEMBL::Utils::Exception qw ( throw warning verbose )
Inherit
Bio::EnsEMBL::Analysis::RunnableDB
Synopsis
No synopsis!
Description
No description!
Methods
database_hash
No description
Code
get_dbadaptorDescriptionCode
Methods description
get_dbadaptorcode    nextTop
  Arg [1]   : String - key of database hash
Arg [2] : return a pipeline db adaptor flag
Function : Returns a Bio::EnsEMBL::DBSQL::DBAdaptor for a given hash key.
or a Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor if requested
Requires proper configuration of
Bio::EnsEMBL::Analysis::Config::Databases

Returntype: Bio::EnsEMBL:DBSQL::DBAdaptor or Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor
Exceptions: throw if key can't be found in Databases.pm
Methods code
database_hashdescriptionprevnextTop
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'};
}
get_dbadaptordescriptionprevnextTop
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;
}
General documentation
No general documentation available.