Commit 14810a43 authored by Leo Gordon's avatar Leo Gordon
Browse files

added optional Accumulator::accu_input_variable parameter, changed examples+tests accordingly

parent 743984ec
......@@ -40,7 +40,7 @@ use base ( 'Bio::EnsEMBL::Hive::Cacheable', 'Bio::EnsEMBL::Hive::Storable' );
sub unikey { # override the default from Cacheable parent
return [ 'accu_name', 'accu_address' ];
return [ 'accu_name', 'accu_address', 'accu_input_variable' ];
}
......@@ -64,19 +64,36 @@ sub accu_address {
}
sub accu_input_variable {
my $self = shift @_;
if(@_) {
$self->{'_accu_input_variable'} = shift @_;
}
return ( $self->{'_accu_input_variable'} // $self->accu_name );
}
sub url {
my ($self, $ref_dba) = @_; # if reference dba is the same as 'my' dba, a shorter url is generated
my $my_dba = $self->adaptor && $self->adaptor->db;
return ( ($my_dba and $my_dba ne ($ref_dba//'') ) ? $my_dba->dbc->url : '' )
. '?accu_name=' . $self->accu_name
. ( $self->accu_address ? '&accu_address='.$self->accu_address : '');
. '?'
. join('&',
'accu_name='.$self->accu_name,
( $self->accu_address ? ('accu_address='.$self->accu_address) : () ),
'accu_input_variable='.$self->accu_input_variable,
);
}
sub display_name {
my ($self) = @_;
return $self->accu_name . ($self->accu_address // '');
return $self->accu_name
. ($self->accu_address // '')
. ':='
. $self->accu_input_variable;
}
......@@ -88,6 +105,7 @@ sub dataflow {
my $accu_name = $self->accu_name;
my $accu_address = $self->accu_address;
my $accu_input_variable = $self->accu_input_variable;
my @rows = ();
......@@ -101,7 +119,7 @@ sub dataflow {
'receiving_job_id' => $receiving_job_id,
'struct_name' => $accu_name,
'key_signature' => $key_signature,
'value' => stringify( $emitting_job->_param_possibly_overridden($accu_name, $output_id) ),
'value' => stringify( $emitting_job->_param_possibly_overridden($accu_input_variable, $output_id) ),
};
}
......@@ -112,7 +130,7 @@ sub dataflow {
sub toString {
my $self = shift @_;
return 'Accumulator(' . $self->accu_name . '<--' . ($self->accu_address // ''). ')';
return 'Accumulator(' . $self->display_name . ')';
}
1;
......
......@@ -92,7 +92,9 @@ sub pipeline_analyses {
-module => 'Bio::EnsEMBL::Hive::Examples::LongMult::RunnableDB::PartMultiply',
-analysis_capacity => 4, # use per-analysis limiter
-flow_into => {
1 => [ '?table_name=intermediate_result' ],
1 => {
'?table_name=intermediate_result' => { 'a_multiplier' => '#a_multiplier#', 'digit' => '#digit#', 'partial_product' => '#product#' },
}
},
},
];
......
......@@ -157,7 +157,7 @@ sub pipeline_analyses {
-module => 'Bio::EnsEMBL::Hive::Examples::LongMult::RunnableDB::PartMultiply',
-analysis_capacity => 4, # use per-analysis limiter
-flow_into => {
1 => [ '?accu_name=partial_product&accu_address={digit}' ],
1 => [ '?accu_name=partial_product&accu_address={digit}&accu_input_variable=product' ],
},
},
......
......@@ -151,9 +151,9 @@ sub pipeline_analyses {
-module => 'Bio::EnsEMBL::Hive::Examples::LongMult::RunnableDB::PartMultiply',
-analysis_capacity => 4, # use per-analysis limiter
-flow_into => {
1 => [
'?table_name=intermediate_result',
],
1 => {
'?table_name=intermediate_result' => { 'a_multiplier' => '#a_multiplier#', 'digit' => '#digit#', 'partial_product' => '#product#' },
},
},
-can_be_empty => 1,
},
......
......@@ -150,7 +150,7 @@ sub pipeline_analyses {
-module => 'Bio::EnsEMBL::Hive::Examples::LongMult::RunnableDB::PartMultiply',
-analysis_capacity => 4, # use per-analysis limiter
-flow_into => {
1 => [ '?accu_name=partial_product&accu_address={digit}' ],
1 => [ '?accu_name=partial_product&accu_address={digit}&accu_input_variable=product' ],
},
},
......
......@@ -12,7 +12,7 @@
=head1 DESCRIPTION
'Bio::EnsEMBL::Hive::Examples::LongMult::RunnableDB::PartMultiply' has a separate task of multiplying 'a_multiplier' by the given 'digit',
then it passes its partial_product on.
then it passes its partial product on.
=head1 LICENSE
......@@ -85,7 +85,7 @@ sub run { # call the recursive function that will compute the stuff
my $a_multiplier = $self->param_required('a_multiplier');
my $digit = $self->param_required('digit');
$self->param('partial_product', _rec_multiply($a_multiplier, $digit, 0) || 0);
$self->param('product', _rec_multiply($a_multiplier, $digit, 0) || 0);
sleep( $self->param('take_time') );
}
......@@ -101,7 +101,7 @@ sub write_output { # but this time we have something to store
my $self = shift @_;
$self->dataflow_output_id( {
'partial_product' => $self->param('partial_product')
'product' => $self->param('product')
}, 1);
}
......
......@@ -164,14 +164,19 @@ BEGIN {
}
{ # NEW style accu URL:
my $url = '?accu_name=intermediate_result&accu_address={digit}';
my $url = '?accu_name=intermediate_results&accu_address={digit}&accu_input_variable=partial_product';
my $url_hash = Bio::EnsEMBL::Hive::Utils::URL::parse( $url );
ok($url_hash, "parser returned something for $url");
isa_ok( $url_hash, 'HASH' );
is_deeply( $url_hash->{'query_params'}, { 'object_type' => 'Accumulator', 'accu_name' => 'intermediate_result', 'accu_address' => '{digit}' }, 'query_params hash correct' );
is_deeply( $url_hash->{'query_params'}, {
'object_type' => 'Accumulator',
'accu_name' => 'intermediate_results',
'accu_address' => '{digit}',
'accu_input_variable' => 'partial_product',
}, 'query_params hash correct' );
}
{ # NEW style registry DB URL:
......
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