AnalysisCtrlRuleAdaptor.pm 2.92 KB
Newer Older
1
=pod
2
3

=head1 NAME
Jessica Severin's avatar
Jessica Severin committed
4

5
6
7
  Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor 

=head1 SYNOPSIS
Jessica Severin's avatar
Jessica Severin committed
8

9
10
  $analysis_ctrl_rule_adaptor = $db_adaptor->get_AnalysisCtrlRuleAdaptor;
  $analysis_ctrl_rule_adaptor = $analysisCtrlRuleObj->adaptor;
11
12

=head1 DESCRIPTION
Jessica Severin's avatar
Jessica Severin committed
13

14
15
16
17
  Module to encapsulate all db access for persistent class AnalysisCtrlRule.
  There should be just one per application and database connection.

=head1 CONTACT
Jessica Severin's avatar
Jessica Severin committed
18

19
  Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
20
21
22
23
24
25
26
27
28

=cut


package Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor;

use strict;
use Bio::EnsEMBL::Hive::AnalysisCtrlRule;

29
use base ('Bio::EnsEMBL::Hive::DBSQL::BaseAdaptor');
30
31


32
33
sub default_table_name {
    return 'analysis_ctrl_rule';
34
35
36
}


37
38
sub default_insertion_method {
    return 'INSERT_IGNORE';
39
40
}

Jessica Severin's avatar
Jessica Severin committed
41

42
43
44
sub object_class {
    return 'Bio::EnsEMBL::Hive::AnalysisCtrlRule';
}
45
46


47
48


49
=head2 remove_by_condition_analysis_url
50

51
52
53
  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
54
  Returns : -
55

56
57
58
59
60
61
62
  NB: This method is not called by ensembl-hive code itself,
  however it is used by two Compara pipeline modules,
        Bio/EnsEMBL/Compara/Production/GenomicAlignBlock/CreateAlignmentChainsJobs.pm
      and
        Bio/EnsEMBL/Compara/Production/GenomicAlignBlock/CreateAlignmentNetsJobs.pm
  in order to avoid blocking by an empty analysis. It should be re-written by using can_be_empty=1 analyses.

63
=cut
Jessica Severin's avatar
Jessica Severin committed
64

65
66
sub remove_by_condition_analysis_url {
  my ( $self, $condition_analysis_url ) = @_;
67

68
69
  my $sth = $self->prepare("DELETE FROM analysis_ctrl_rule WHERE condition_analysis_url =?");
  $sth->execute($condition_analysis_url);
70
71
}

72

Jessica Severin's avatar
Jessica Severin committed
73
74
75
76
77
78
79
80
81
82
83
=head2 create_rule

  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
84
  Caller      : HiveGeneric_conf.pm and various pipeline-creating scripts
Jessica Severin's avatar
Jessica Severin committed
85
86
87
  
=cut

88
sub create_rule {
89
    my ($self, $conditionAnalysis, $ctrledAnalysis) = @_;
90

91
92
93
94
95
96
97
    return unless($conditionAnalysis and $ctrledAnalysis);

    my $rule = Bio::EnsEMBL::Hive::AnalysisCtrlRule->new();
    # NB: ctrled_analysis must be set first in order for internal logic to abbreviate 'to_url'
    $rule->ctrled_analysis($ctrledAnalysis);
    $rule->condition_analysis($conditionAnalysis);

98
    return $self->store($rule, 1);  # avoid redundancy
99
100
101
102
}


1;