Bio::EnsEMBL::Hive::DBSQL
AnalysisCtrlRuleAdaptor
Toolbar
Summary
Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
$AnalysisCtrlRuleAdaptor = $db_adaptor->get_AnalysisCtrlRuleAdaptor;
$analysisCtrlRuleAdaptor = $analysisCtrlRuleObj->adaptor;
Description
Module to encapsulate all db access for persistent class AnalysisCtrlRule.
There should be just one per application and database connection.
Methods
Methods description
Arg[1] : condition analysis object (Bio::EnsEMBL::Analysis object) Arg[2] : controled analysis object (Bio::EnsEMBL::Analysis object) Example : $dba->get_AnalysisCtrlRuleAdaptor->create_rule($conditionAnalysis, $ctrledAnalysis); Description : Creates an AnalysisCtrlRule where the condition analysis must be completely DONE with all jobs in order for the controlled analysis to be unblocked and allowed to proceed. If an analysis requires multiple conditions, simply create multiple rules and controlled analysis will only unblock if ALL conditions are satisified. Returntype : none Exceptions : none Caller : general |
Arg : None Example : my $all_rules = $ctrlRuleDBA->fetch_all(); Description: fetches all AnalysisCtrlRule objects from database Returntype : array reference of Bio::EnsEMBL::Hive::AnalysisCtrlRule objects Exceptions : none Caller : general |
Arg [1] : int $id the unique database identifier for the feature to be obtained Example : $ctrlRuleArray = $adaptor->fetch_by_ctrled_analysis_id($ctrled_analysis->dbID); Description: Returns an array reference of all the AnalysisCtrlRule objects for the specified controled analysis. Returntype : listref of Bio::EnsEMBL::Hive::AnalysisCtrlRule objects Exceptions : thrown if $id is not defined Caller : general |
Arg[1] : string condition_analysis_url Usage : $self->remove_by_condition_analysis_url("ThisAnalysisLogicName"); Function: removes all the control rules for this condition analysis URL Returns : - |
Arg[1] : Bio::EnsEMBL::Hive::AnalysisCtrlRule object Usage : $self->store( $rule ); Function : Stores a rule in db Sets adaptor and dbID in AnalysisCtrlRule object Returntype : none |
Methods code
sub _columns
{ my $self = shift;
return qw (r.ctrled_analysis_id
r.condition_analysis_url
); } |
sub _default_where_clause
{ my $self = shift;
return ''; } |
sub _final_clause
{ my $self = shift;
return '';
}
} |
sub _generic_fetch
{ my ($self, $constraint, $join) = @_;
my @tables = $self->_tables;
my $columns = join(', ', $self->_columns());
if ($join) {
foreach my $single_join (@{$join}) {
my ($tablename, $condition, $extra_columns) = @{$single_join};
if ($tablename && $condition) {
push @tables, $tablename;
if($constraint) {
$constraint .= " AND $condition";
} else {
$constraint = " $condition";
}
}
if ($extra_columns) {
$columns .= ", " . join(', ', @{$extra_columns});
}
}
}
my $tablenames = join(', ', map({ join(' ', @$_) } @tables));
my $sql = "SELECT $columns FROM $tablenames";
my $default_where = $self->_default_where_clause;
my $final_clause = $self->_final_clause;
if($constraint) {
$sql .= " WHERE $constraint ";
if($default_where) {
$sql .= " AND $default_where ";
}
} elsif($default_where) {
$sql .= " WHERE $default_where ";
}
$sql .= " $final_clause";
my $sth = $self->prepare($sql);
$sth->execute;
return $self->_objs_from_sth($sth);
}
1; } |
sub _objs_from_sth
{ my ($self, $sth) = @_;
my @rules = ();
my ($ctrled_analysis_id, $condition_analysis_url);
$sth->bind_columns(\$ctrled_analysis_id,\$ condition_analysis_url);
while ($sth->fetch()) {
my $rule = Bio::EnsEMBL::Hive::AnalysisCtrlRule->new;
$rule->adaptor($self);
$rule->ctrled_analysis_id($ctrled_analysis_id);
$rule->condition_analysis_url($condition_analysis_url);
push @rules, $rule;
}
return\@ rules; } |
sub _tables
{ my $self = shift;
return (['analysis_ctrl_rule', 'r']); } |
sub create_rule
{ my ($self, $conditionAnalysis, $ctrledAnalysis) = @_;
return unless($conditionAnalysis and $ctrledAnalysis);
my $rule = Bio::EnsEMBL::Hive::AnalysisCtrlRule->new();
$rule->ctrled_analysis($ctrledAnalysis);
$rule->condition_analysis($conditionAnalysis);
$self->store($rule);
}
} |
sub fetch_all
{ my $self = shift;
return $self->_generic_fetch(); } |
sub fetch_by_ctrled_analysis_id
{ my ($self,$id) = @_;
unless(defined $id) {
throw("fetch_by_ctrled_analysis_id must have an id");
}
my $constraint = "r.ctrled_analysis_id = $id";
return $self->_generic_fetch($constraint); } |
sub remove_by_condition_analysis_url
{ my ( $self, $condition_analysis_url ) = @_;
my $sth = $self->prepare("DELETE FROM analysis_ctrl_rule WHERE condition_analysis_url =?");
$sth->execute($condition_analysis_url); } |
sub store
{ my ( $self, $rule ) = @_;
my $sth = $self->prepare(q{INSERT ignore INTO analysis_ctrl_rule (ctrled_analysis_id, condition_analysis_url) VALUES(?,?) });
if($sth->execute($rule->ctrled_analysis_id, $rule->condition_analysis_url)) {
$sth->finish();
}
$rule->adaptor( $self ); } |
General documentation
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _