Databases.pm is the main configuration file which holds the different
parameters (usernames, hosts, passwords, ports, database-names) to
connect to different databases used in the Ensembl-Analysis pipeline.
It imports and sets a number of standard global variables into the
calling package. Without arguments all the standard variables are set,
and with a list, only those variables whose names are provided are set.
The module will die if a variable which doesn\'t appear in its
%Config hash is asked to be set.
A common way to get an DBAdaptor in a module is
print "Loading database : ". $$DATABASES{REFERENCE_DB}{"-dbname"} . "\n";
my $ref_db = new Bio::EnsEMBL::DBSQL::DBAdaptor( %{ $$DATABASES{REFERENCE_DB} }) ;
OR if you write a RunnableDB:
use Bio::EnsEMBL::Analysis::RunnableDB::BaseGeneBuild;
@ISA = qw ( Bio::EnsEMBL::Analysis::RunnableDB::BaseGeneBuild )
my $genes_db = $self->get_dbadaptor("GENEBUILD_DB");
OR for normal scripts :
use Bio::EnsEMBL::Analysis::Tools::Utilities qw( get_db_adaptor_by_string );
get_db_adaptor_by_string("GENEBUILD_DB")
The variables can also be references to arrays or hashes.
Edit %Config to add or alter variables.
All the variables are in capitals, so that they resemble environment
variables.
Databases is a pure ripoff of humConf written by James Gilbert.
humConf is based upon ideas from the standard perl Env environment
module.
None available.
sub import
{ my ($callpack) = caller(0); my $pack = shift;
my @vars = @_ ? @_ : keys(%Config);
return unless @vars;
eval "package $callpack; use vars qw("
. join(' ', map { '$'.$_ } @vars) . ")";
die $@ if $@;
foreach (@vars) {
if (defined $Config{ $_ }) {
no strict 'refs';
*{"${callpack}::$_"} =\$ Config{ $_ };
} else {
die "Error: Config: $_ not known\n";
}
}
}
1; } |