Commit 05026db0 authored by Leo Gordon's avatar Leo Gordon
Browse files

ligher versions of DataflowRule and AnalysisCtrlRule that make use of magic...

ligher versions of DataflowRule and AnalysisCtrlRule that make use of magic Storable::AUTOLOADed getters/setters
parent a98dfda4
......@@ -49,130 +49,79 @@ use Bio::EnsEMBL::Hive::URLFactory;
use base ( 'Bio::EnsEMBL::Hive::Storable' );
=head2 ctrled_analysis_id
=head1 AUTOLOADED
Arg[1] : (optional) int $dbID
Usage : $self->ctrled_analysis_id($dbID);
Function: Get/set method for the analysis which will be BLOCKED until all
of its condition analyses are 'DONE'. Specified as a dbID.
Returns : integer
=cut
ctrled_analysis_id / ctrled_analysis
sub ctrled_analysis_id {
my ($self,$analysis_id) = @_;
if($analysis_id) {
$self->{'_ctrled_analysis_id'} = $analysis_id;
$self->{'_ctrled_analysis'} = undef;
}
return $self->{'_ctrled_analysis_id'};
}
=cut
=head2 condition_analysis_url
Arg[1] : (optional) string $url
Usage : $self->condition_analysis_url($url);
Function: Get/set method for the analysis which must be 'DONE' in order for
the controlled analysis to be un-BLOCKED. Specified as a URL.
Returns : string
Arg[1] : (optional) string $url
Usage : $self->condition_analysis_url($url);
Function: Get/set method for the analysis which must be 'DONE' in order for
the controlled analysis to be un-BLOCKED. Specified as a URL.
Returns : string
=cut
sub condition_analysis_url {
my ($self,$url) = @_;
if($url) {
$self->{'_condition_analysis_url'} = $url;
$self->{'_condition_analysis'} = undef;
}
return $self->{'_condition_analysis_url'};
}
=head2 ctrled_analysis
Arg[1] : (optional) Bio::EnsEMBL::Hive::Analysis object
Usage : $self->ctrled_analysis($anal);
Function: Get/set method for the analysis which will be BLOCKED until all
of its condition analyses are 'DONE'
Returns : Bio::EnsEMBL::Hive::Analysis
=cut
sub ctrled_analysis {
my ($self,$analysis) = @_;
# setter mode
if( defined $analysis ) {
unless ($analysis->isa('Bio::EnsEMBL::Hive::Analysis')) {
throw(
"ctrled_analysis arg must be a [Bio::EnsEMBL::Hive::Analysis]".
"not a [$analysis]");
my ($self,$url) = @_;
if($url) {
$self->{'_condition_analysis_url'} = $url;
$self->{'_condition_analysis'} = undef;
}
$self->{'_ctrled_analysis'} = $analysis;
$self->{'_ctrled_analysis_id'} = $analysis->dbID;
}
# lazy load the analysis object if I can
if(!defined($self->{'_ctrled_analysis'})
and defined($self->ctrled_analysis_id)
and defined($self->adaptor))
{
$self->{'_ctrled_analysis'} = $self->adaptor->db->get_AnalysisAdaptor->fetch_by_dbID($self->ctrled_analysis_id);
}
return $self->{'_ctrled_analysis'};
return $self->{'_condition_analysis_url'};
}
=head2 condition_analysis
Arg[1] : (optional) Bio::EnsEMBL::Hive::Analysis object
Usage : $self->condition_analysis($anal);
Function: Get/set method for the analysis which must be 'DONE' in order for
the controlled analysis to be un-BLOCKED
Returns : Bio::EnsEMBL::Hive::Analysis
Arg[1] : (optional) Bio::EnsEMBL::Hive::Analysis object
Usage : $self->condition_analysis($anal);
Function: Get/set method for the analysis which must be 'DONE' in order for
the controlled analysis to be un-BLOCKED
Returns : Bio::EnsEMBL::Hive::Analysis
=cut
sub condition_analysis {
my ($self,$analysis) = @_;
if( defined $analysis ) {
unless ($analysis->isa('Bio::EnsEMBL::Hive::Analysis')) {
throw(
"condition_analysis arg must be a [Bio::EnsEMBL::Hive::Analysis]".
"not a [$analysis]");
}
$self->{'_condition_analysis'} = $analysis;
#if the 'condition' and 'ctrled' share the same adaptor, then use a simple logic_name
#for the URL rather than a full network distributed URL
if($self->ctrled_analysis and ($self->ctrled_analysis->adaptor == $analysis->adaptor)) {
$self->{'_condition_analysis_url'} = $analysis->logic_name;
} else {
$self->{'_condition_analysis_url'} = $analysis->url;
my ($self,$analysis) = @_;
if( defined $analysis ) {
unless ($analysis->isa('Bio::EnsEMBL::Hive::Analysis')) {
throw( "condition_analysis arg must be a [Bio::EnsEMBL::Hive::Analysis] not a [$analysis]");
}
$self->{'_condition_analysis'} = $analysis;
#if the 'condition' and 'ctrled' share the same adaptor, then use a simple logic_name
#for the URL rather than a full network distributed URL
if($self->ctrled_analysis and ($self->ctrled_analysis->adaptor == $analysis->adaptor)) {
$self->{'_condition_analysis_url'} = $analysis->logic_name;
} else {
$self->{'_condition_analysis_url'} = $analysis->url;
}
}
}
# lazy load the analysis object if I can
if(!defined($self->{'_condition_analysis'}) and defined($self->condition_analysis_url)) {
$analysis = Bio::EnsEMBL::Hive::URLFactory->fetch($self->condition_analysis_url);
unless($analysis) {
$analysis =
$self->adaptor->db->get_AnalysisAdaptor->fetch_by_logic_name($self->condition_analysis_url);
# lazy load the analysis object if I can
if(!defined($self->{'_condition_analysis'}) and defined($self->condition_analysis_url)) {
$analysis = Bio::EnsEMBL::Hive::URLFactory->fetch($self->condition_analysis_url);
unless($analysis) {
$analysis = $self->adaptor->db->get_AnalysisAdaptor->fetch_by_logic_name($self->condition_analysis_url);
}
$self->{'_condition_analysis'} = $analysis;
}
$self->{'_condition_analysis'} = $analysis;
}
return $self->{'_condition_analysis'};
return $self->{'_condition_analysis'};
}
=head2 toString
Args : (none)
Example : print $c_rule->toString()."\n";
Description: returns a stringified representation of the rule
Returntype : string
Args : (none)
Example : print $c_rule->toString()."\n";
Description: returns a stringified representation of the rule
Returntype : string
=cut
......@@ -189,8 +138,5 @@ sub toString {
);
}
1;
......@@ -59,6 +59,15 @@ use Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor;
use base ( 'Bio::EnsEMBL::Hive::Storable' );
=head1 AUTOLOADED
from_analysis_id / from_analysis
funnel_dataflow_rule_id / funnel_dataflow_rule
=cut
=head2 branch_code
Function: getter/setter method for the branch_code of the dataflow rule
......@@ -76,22 +85,6 @@ sub branch_code {
}
=head2 funnel_dataflow_rule_id
Function: getter/setter method for the funnel_dataflow_rule_id of the dataflow rule
=cut
sub funnel_dataflow_rule_id {
my $self = shift @_;
if(@_) { # setter mode
$self->{'_funnel_dataflow_rule_id'} = shift @_;
}
return $self->{'_funnel_dataflow_rule_id'};
}
=head2 input_id_template
Function: getter/setter method for the input_id_template of the dataflow rule
......@@ -109,129 +102,75 @@ sub input_id_template {
}
=head2 from_analysis_id
Arg[1] : (optional) int $dbID
Usage : $self->from_analysis_id($dbID);
Function: Get/set method for the 'from' analysis objects dbID of this rule.
Returns : integer
=cut
sub from_analysis_id {
my ($self,$analysis_id) = @_;
if($analysis_id) {
$self->{'_from_analysis_id'} = $analysis_id;
$self->{'_from_analysis'} = undef;
}
return $self->{'_from_analysis_id'};
}
=head2 to_analysis_url
Arg[1] : (optional) string $url
Usage : $self->to_analysis_url($url);
Function: Get/set method for the 'to' analysis objects URL for this rule
Returns : string
Arg[1] : (optional) string $url
Usage : $self->to_analysis_url($url);
Function: Get/set method for the 'to' analysis objects URL for this rule
Returns : string
=cut
sub to_analysis_url {
my ($self,$url) = @_;
if($url) {
$self->{'_to_analysis_url'} = $url;
$self->{'_to_analysis'} = undef;
}
return $self->{'_to_analysis_url'};
}
=head2 from_analysis
Usage : $self->from_analysis($analysis);
Function: Get/set method for the condition analysis object of this rule.
Returns : Bio::EnsEMBL::Hive::Analysis
Args : Bio::EnsEMBL::Hive::Analysis
=cut
sub from_analysis {
my ($self,$analysis) = @_;
# setter mode
if( defined $analysis ) {
unless ($analysis->isa('Bio::EnsEMBL::Hive::Analysis')) {
throw(
"from_analysis arg must be a [Bio::EnsEMBL::Hive::Analysis]".
"not a [$analysis]");
my ($self,$url) = @_;
if($url) {
$self->{'_to_analysis_url'} = $url;
$self->{'_to_analysis'} = undef;
}
$self->{'_from_analysis'} = $analysis;
$self->{'_from_analysis_id'} = $analysis->dbID;
}
# lazy load the analysis object if I can
if(!defined($self->{'_from_analysis'})
and defined($self->from_analysis_id)
and defined($self->adaptor))
{
$self->{'_from_analysis'} =
$self->adaptor->db->get_AnalysisAdaptor->fetch_by_dbID($self->from_analysis_id);
}
return $self->{'_from_analysis'};
return $self->{'_to_analysis_url'};
}
=head2 to_analysis
Usage : $self->to_analysis($analysis);
Function: Get/set method for the goal analysis object of this rule.
Returns : Bio::EnsEMBL::Hive::Analysis
Args : Bio::EnsEMBL::Hive::Analysis
Usage : $self->to_analysis($analysis);
Function: Get/set method for the goal analysis object of this rule.
Returns : Bio::EnsEMBL::Hive::Analysis
Args : Bio::EnsEMBL::Hive::Analysis
=cut
sub to_analysis {
my ($self, $analysis_or_nt) = @_;
my ($self, $analysis_or_nt) = @_;
if( defined $analysis_or_nt ) {
unless ($analysis_or_nt->can('url')) {
throw( "to_analysis arg must support 'url' method, '$analysis_or_nt' does not know how to do it");
}
$self->{'_to_analysis'} = $analysis_or_nt;
if( defined $analysis_or_nt ) {
unless ($analysis_or_nt->can('url')) {
throw( "to_analysis arg must support 'url' method, '$analysis_or_nt' does not know how to do it");
}
$self->{'_to_analysis'} = $analysis_or_nt;
#if the 'from' and 'to' share the same adaptor, then use a simple logic_name
#for the URL rather than a full network distributed URL
#if the 'from' and 'to' share the same adaptor, then use a simple logic_name
#for the URL rather than a full network distributed URL
my $ref_rule_adaptor = $self->from_analysis && $self->from_analysis->adaptor;
my $ref_rule_adaptor = $self->from_analysis && $self->from_analysis->adaptor;
if($analysis_or_nt->can('logic_name') and $ref_rule_adaptor and ($ref_rule_adaptor == $analysis_or_nt->adaptor)) {
$self->{'_to_analysis_url'} = $analysis_or_nt->logic_name;
} else {
$self->{'_to_analysis_url'} = $analysis_or_nt->url($ref_rule_adaptor->db);
if($analysis_or_nt->can('logic_name') and $ref_rule_adaptor and ($ref_rule_adaptor == $analysis_or_nt->adaptor)) {
$self->{'_to_analysis_url'} = $analysis_or_nt->logic_name;
} else {
$self->{'_to_analysis_url'} = $analysis_or_nt->url($ref_rule_adaptor->db);
}
}
}
# lazy load the analysis object if I can
if(!defined($self->{'_to_analysis'}) and defined($self->to_analysis_url)) {
# lazy load the analysis object if I can
if(!defined($self->{'_to_analysis'}) and defined($self->to_analysis_url)) {
my $url = $self->to_analysis_url;
my $url = $self->to_analysis_url;
$self->{'_to_analysis'} = $self->adaptor
? $self->adaptor->db->get_AnalysisAdaptor->fetch_by_logic_name_or_url($url)
: Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor->fetch_by_logic_name_or_url($url)
or die "Cannot fetch analysis from logic_name or url '$url' for dataflow rule with id='".$self->dbID."'\n";
$self->{'_to_analysis'} = $self->adaptor
? $self->adaptor->db->get_AnalysisAdaptor->fetch_by_logic_name_or_url($url)
: Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor->fetch_by_logic_name_or_url($url)
or die "Cannot fetch analysis from logic_name or url '$url' for dataflow rule with id='".$self->dbID."'\n";
}
return $self->{'_to_analysis'};
}
return $self->{'_to_analysis'};
}
=head2 toString
Args : (none)
Example : print $df_rule->toString()."\n";
Description: returns a stringified representation of the rule
Returntype : string
Args : (none)
Example : print $df_rule->toString()."\n";
Description: returns a stringified representation of the rule
Returntype : string
=cut
......@@ -252,6 +191,5 @@ sub toString {
);
}
1;
......@@ -634,7 +634,7 @@ sub run {
}
my $c_rule = Bio::EnsEMBL::Hive::AnalysisCtrlRule->new(
'condition_analysis_url' => $condition_url,
'ctrled_analysis_id' => $analysis->dbID,
'ctrled_analysis' => $analysis,
);
$ctrl_rule_adaptor->store( $c_rule, 1 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment