Bio::EnsEMBL::Pipeline::DBSQL
DBAdaptor
Toolbar
Summary
Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor -
adapter class for EnsEMBL Pipeline DB
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
my $dbobj = new Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor;
$dbobj->do_funky_db_stuff;
Description
Interface for the connection to the analysis database
Methods
DESTROY | Description | Code |
_db_handle | Description | Code |
get_available_adaptors | No description | Code |
get_meta_value_by_key | No description | Code |
make_hash_from_meta_value | No description | Code |
make_meta_value_from_hash | No description | Code |
pipeline_lock | No description | Code |
pipeline_unlock | No description | Code |
prepare | No description | Code |
remove_meta_key | No description | Code |
store_meta_key_value | No description | Code |
Methods description
Title : DESTROY Usage : Function: Example : Returns : Args : |
Title : _db_handle Usage : $sth = $dbobj->_db_handle($dbh); Function: Get/set method for the database handle Example : Returns : A database handle object Args : A database handle object |
Methods code
sub DESTROY
{ my ($obj) = @_;
if( $obj->{'_db_handle'} ) {
$obj->{'_db_handle'}->disconnect;
$obj->{'_db_handle'} = undef;
} } |
sub _db_handle
{ my ($self,$arg) = @_;
if (defined($arg)) {
$self->{_db_handle} = $arg;
}
return $self->{_db_handle}; } |
sub get_available_adaptors
{ my ($self) = @_;
my $pairs = $self->SUPER::get_available_adaptors();
$pairs->{'Analysis'} = 'Bio::EnsEMBL::Pipeline::DBSQL::AnalysisAdaptor';
$pairs->{'Job'} = 'Bio::EnsEMBL::Pipeline::DBSQL::JobAdaptor';
$pairs->{'PmatchFeature'} = 'Bio::EnsEMBL::Pipeline::DBSQL::PmatchFeatureAdaptor';
$pairs->{'Rule'} = 'Bio::EnsEMBL::Pipeline::DBSQL::RuleAdaptor';
$pairs->{'StateInfoContainer'} = 'Bio::EnsEMBL::Pipeline::DBSQL::StateInfoContainer';
$pairs->{'CompressedDnaAlignFeature'} = 'Bio::EnsEMBL::Pipeline::DBSQL::CompressedDnaAlignFeatureAdaptor';
return $pairs; } |
sub get_meta_value_by_key
{ my ($self, $key, $value) = @_;
$self->throw("No key to get supplied") unless $key;
my $sth = $self->prepare(qq{
SELECT meta_value
FROM meta
WHERE meta_key = ? LIMIT 1
}); $sth->execute($key);
my $row = $sth->fetchrow_arrayref();
$value = $row->[0] if $row;
$sth->finish();
return $value; } |
sub make_hash_from_meta_value
{ my ($self,$string) = @_;
if($string){
my $hash = { eval $string };
$@ ? die "error evaluating $string" : return $hash || {};
}
return {};
}
1; } |
sub make_meta_value_from_hash
{ my ($self, $hash) = @_;
my $dbh = $self->_db_handle();
return join(",\n", map{ $dbh->quote($_)." => ".$dbh->quote($hash->{$_}) } keys(%$hash)); } |
sub pipeline_lock
{ my ($self, $string) = @_;
my $lock = 'pipeline.lock';
return $string ? $self->store_meta_key_value($lock, $string) : $self->get_meta_value_by_key($lock); } |
sub pipeline_unlock
{ my ($self) = @_;
$self->remove_meta_key('pipeline.lock'); } |
sub prepare
{ my ($self, @args) = @_;
$self->dbc->prepare(@args); } |
sub remove_meta_key
{ my ($self, $key) = @_;
$self->throw("No key to remove supplied") unless $key;
my $sth = $self->prepare(qq{
DELETE
FROM meta
WHERE meta_key = ?
});
$sth->execute($key);
$sth->finish;
return undef; } |
store_meta_key_value | description | prev | next | Top |
sub store_meta_key_value
{ my ($self, $key, $value) = @_;
$self->throw("No key|value to insert supplied") unless $key && $value;
my $sth = $self->prepare(qq{
INSERT INTO meta (meta_key, meta_value) VALUES (?, ?)
});
$sth->execute($key, $value);
$sth->finish();
return undef; } |
General documentation
Post general queries to ensembl-dev@ebi.ac.uk
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
Title : get_JobAdaptor
Usage : $db->get_JobAdaptor
Function: The Adaptor for Job objects in this db
Example :
Returns : Bio::EnsEMBL::Pipeline::DBSQL::JobAdaptor
Args : nothing
Title : get_RuleAdaptor
Usage : $db->get_RuleAdaptor
Function: The Adaptor for Rule objects in this db
Example :
Returns : Bio::EnsEMBL::Pipeline::DBSQL::RuleAdaptor
Args : nothing
get_StateInfoContainer | Top |
Title : get_StateInfoContainer
Usage : $db->get_StateInfoContainer
Function:
Example :
Returns : Bio::EnsEMBL::Pipeline::DBSQL::StateInfoContainer
Args : nothing
Access to the meta table of the schema including
pipeline_lock - write a lock to the meta table
pipeline_unlock - remove the lock
get_meta_value_by_key - retrieve value by key
store_meta_key_value - write key, value pair
remove_meta_key - delete by key name
make_meta_value_from_hash - flatten a hash to a string (uses dbi->quote to escape)
make_hash_from_meta_value - returns a hash from a previously flattened string
$lock_string = 'whatever to lock';
$dbA->pipeline_lock($lock_string);
my $lock_string = $dbA->pipeline_lock();
$dbA->pipeline_unlock();
$dbA->store_meta_key_value('my_key', 'the value');
my $value = $dbA->get_meta_value_by_key('my_key');
$dbA->remove_meta_key('my_key');
my %hash = ('-host' => 'pfam', '-port' => '3306'...);
my $flat = $dbA->make_meta_value_from_hash(\%hash);
my %retrieved = %{$dbA->make_hash_from_meta_value($flat)};