Commit 3dc78d6b authored by Leo Gordon's avatar Leo Gordon
Browse files

fixed the broken analysis_topup by finally providing a unikey to DfR

parent 562a109d
......@@ -57,7 +57,7 @@ use base ( 'Bio::EnsEMBL::Hive::Cacheable', 'Bio::EnsEMBL::Hive::Storable' );
sub unikey {
return undef; # unfortunately, this object is no longer unique
return [ 'from_analysis', 'branch_code', 'funnel_dataflow_rule', 'unitargets' ];
}
......@@ -107,6 +107,21 @@ sub get_my_targets_grouped_by_condition {
}
sub unitargets {
my $self = shift @_;
my $targets = shift @_ || $self->get_my_targets;
if(ref($targets)) {
my $unitargets = join( ';', map { ($_->on_condition//'').':'.($_->input_id_template//'').':'.$_->to_analysis_url }
sort { ($a->on_condition//'') cmp ($b->on_condition//'')
or ($a->input_id_template//'') cmp ($b->input_id_template//'') }
@$targets);
return $unitargets;
}
}
=head2 toString
Args : (none)
......
......@@ -77,7 +77,7 @@ sub find_by_url_query {
unless($accu = $self->collection_of('Accumulator')->find_one_by( 'struct_name', $tparam_name, 'signature_template', $tparam_value )) {
$accu = $self->add_new_or_update( 'Accumulator',
($accu) = $self->add_new_or_update( 'Accumulator', # NB: add_new_or_update returns a list
$self->hive_dba ? (adaptor => $self->hive_dba->get_AccumulatorAdaptor) : (),
struct_name => $tparam_name,
signature_template => $tparam_value,
......@@ -95,7 +95,7 @@ sub find_by_url_query {
unless($naked_table = $self->collection_of('NakedTable')->find_one_by( 'table_name', $table_name )) {
$naked_table = $self->add_new_or_update( 'NakedTable',
($naked_table) = $self->add_new_or_update( 'NakedTable', # NB: add_new_or_update returns a list
$self->hive_dba ? (adaptor => $self->hive_dba->get_NakedTableAdaptor( 'table_name' => $table_name ) ) : (),
table_name => $table_name,
$tparam_value ? (insertion_method => $tparam_value) : (),
......@@ -170,6 +170,7 @@ sub add_new_or_update {
my $class = 'Bio::EnsEMBL::Hive::'.$type;
my $object;
my $newly_made = 0;
if( my $unikey_keys = $class->unikey() ) {
my %other_pairs = @_;
......@@ -197,6 +198,7 @@ sub add_new_or_update {
unless( $object ) {
$object = $class->can('new') ? $class->new( @_ ) : { @_ };
$newly_made = 1;
$self->collection_of( $type )->add( $object );
......@@ -206,7 +208,7 @@ sub add_new_or_update {
warn "Created a new $found_display\n";
}
return $object;
return ($object, $newly_made);
}
......
......@@ -419,14 +419,14 @@ sub add_objects_from_config {
die "-rc_id syntax is no longer supported, please use the new resource notation (-rc_name)";
}
my $resource_class = $pipeline->add_new_or_update( 'ResourceClass',
my ($resource_class) = $pipeline->add_new_or_update( 'ResourceClass', # NB: add_new_or_update returns a list
'name' => $rc_name,
);
while( my($meadow_type, $resource_param_list) = each %{ $resource_classes_hash->{$rc_name} } ) {
$resource_param_list = [ $resource_param_list ] unless(ref($resource_param_list)); # expecting either a scalar or a 2-element array
my $resource_description = $pipeline->add_new_or_update( 'ResourceDescription',
my ($resource_description) = $pipeline->add_new_or_update( 'ResourceDescription', # NB: add_new_or_update returns a list
'resource_class' => $resource_class,
'meadow_type' => $meadow_type,
'submission_cmd_args' => $resource_param_list->[0],
......@@ -483,7 +483,7 @@ sub add_objects_from_config {
$parameters_hash ||= {}; # in case nothing was given
die "'-parameters' has to be a hash" unless(ref($parameters_hash) eq 'HASH');
$analysis = $pipeline->add_new_or_update( 'Analysis',
($analysis) = $pipeline->add_new_or_update( 'Analysis', # NB: add_new_or_update returns a list
'logic_name' => $logic_name,
'module' => $module,
'language' => $language,
......@@ -498,7 +498,7 @@ sub add_objects_from_config {
);
$analysis->get_compiled_module_name(); # check if it compiles and is named correctly
$stats = $pipeline->add_new_or_update( 'AnalysisStats',
($stats) = $pipeline->add_new_or_update( 'AnalysisStats', # NB: add_new_or_update returns a list
'analysis' => $analysis,
'batch_size' => $batch_size,
'hive_capacity' => $hive_capacity,
......@@ -546,7 +546,7 @@ sub add_objects_from_config {
my $condition_analysis = $pipeline->collection_of('Analysis')->find_one_by('logic_name', $condition_url)
or die "Could not find a local analysis '$condition_url' to create a control rule (in '".($analysis->logic_name)."')\n";
}
my $c_rule = $pipeline->add_new_or_update( 'AnalysisCtrlRule',
my ($c_rule) = $pipeline->add_new_or_update( 'AnalysisCtrlRule', # NB: add_new_or_update returns a list
'condition_analysis_url' => $condition_url,
'ctrled_analysis' => $analysis,
);
......
......@@ -43,7 +43,7 @@ sub standaloneJob {
my $hive_pipeline = Bio::EnsEMBL::Hive::HivePipeline->new();
my $dummy_analysis = $hive_pipeline->add_new_or_update( 'Analysis',
my ($dummy_analysis) = $hive_pipeline->add_new_or_update( 'Analysis', # NB: add_new_or_update returns a list
'logic_name' => 'Standalone_Dummy_Analysis', # looks nicer when printing out DFRs
'module' => ref($runnable_object),
'dbID' => -1,
......
......@@ -86,6 +86,20 @@ sub add_once {
}
sub forget {
my $self = shift @_;
my $candidate = shift @_;
my $listref = $self->listref;
for(my $i=scalar(@$listref)-1;$i>=0;$i--) {
if($listref->[$i] == $candidate) {
splice @$listref, $i, 1;
}
}
}
sub find_one_by {
my ($self, %method_to_filter_value) = @_;
......
......@@ -120,12 +120,6 @@ sub parse_flow_into {
my $this_cond_group_marker = shift @$cond_group;
die "Expecting $cond_group_marker, got $this_cond_group_marker" unless($this_cond_group_marker eq $cond_group_marker);
my $df_rule = $pipeline->add_new_or_update( 'DataflowRule',
'from_analysis' => $from_analysis,
'branch_code' => $branch_name_or_code,
'funnel_dataflow_rule' => $funnel_dataflow_rule,
);
while(@$cond_group) {
my $on_condition = shift @$cond_group;
my $heirs = shift @$cond_group;
......@@ -145,8 +139,8 @@ sub parse_flow_into {
foreach my $input_id_template (@$input_id_template_list) {
my $df_target = $pipeline->add_new_or_update( 'DataflowTarget',
'source_dataflow_rule' => $df_rule,
my ($df_target) = $pipeline->add_new_or_update( 'DataflowTarget', # NB: add_new_or_update returns a list
'source_dataflow_rule' => undef, # NB: had to create the "suspended targets" to break the dependence circle
'on_condition' => $on_condition,
'input_id_template' => $input_id_template,
'to_analysis_url' => $heir_url,
......@@ -156,6 +150,26 @@ sub parse_flow_into {
} # /for all heirs
} # /for each condition and heir
my $suspended_targets = $pipeline->collection_of('DataflowTarget')->find_all_by( 'source_dataflow_rule', undef );
my ($df_rule, $df_rule_is_new) = $pipeline->add_new_or_update( 'DataflowRule', # NB: add_new_or_update returns a list
'from_analysis' => $from_analysis,
'branch_code' => $branch_name_or_code,
'funnel_dataflow_rule' => $funnel_dataflow_rule,
'unitargets' => Bio::EnsEMBL::Hive::DataflowRule->unitargets($suspended_targets),
# 'unitargets' => $suspended_targets,
);
if( $df_rule_is_new ) {
foreach my $suspended_target (@$suspended_targets) {
$suspended_target->source_dataflow_rule( $df_rule );
}
} else {
foreach my $suspended_target (@$suspended_targets) {
$pipeline->collection_of('DataflowTarget')->forget( $suspended_target );
}
}
if($group_role eq 'funnel') {
if($group_tag_to_funnel_dataflow_rule{$group_tag}) {
die "More than one funnel dataflow_rule defined for group '$group_tag'\n";
......
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