ensembl-hive  2.6
AnalysisCtrlRule.pm
Go to the documentation of this file.
1 =pod
2 
3 =head1 NAME
4 
6 
7 =head1 DESCRIPTION
8 
9  An 'analysis control rule' is a high level blocking control structure where there is
10  a 'ctrled_analysis' which is 'BLOCKED' from running until all of its 'condition_analysis' are 'DONE'.
11  If a ctrled_analysis requires multiple analysis to be DONE before it can run, a separate
12  AnalysisCtrlRule must be created/stored for each condtion analysis.
13 
14  Allows the 'condition' analysis to be specified with a network savy URL like
15  mysql://ensadmin:<pass>@ecs2:3361/compara_hive_test?analysis.logic_name='blast_NCBI34'
16 
17 =head1 LICENSE
18 
19  Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
20  Copyright [2016-2024] EMBL-European Bioinformatics Institute
21 
22  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
23  You may obtain a copy of the License at
24 
25  http://www.apache.org/licenses/LICENSE-2.0
26 
27  Unless required by applicable law or agreed to in writing, software distributed under the License
28  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  See the License for the specific language governing permissions and limitations under the License.
30 
31 =head1 CONTACT
32 
33  Please subscribe to the Hive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss Hive-related questions or to be notified of our updates
34 
35 =head1 APPENDIX
36 
37  The rest of the documentation details each of the object methods.
38  Internal methods are usually preceded with a _
39 
40 =cut
41 
42 
43 package Bio::EnsEMBL::Hive::AnalysisCtrlRule;
44 
45 use strict;
46 use warnings;
47 
48 use Bio::EnsEMBL::Hive::Utils ('throw');
50 
51 use base ( 'Bio::EnsEMBL::Hive::Storable' );
52 
53 
54 sub unikey { # override the default from Cacheable parent
55  return [ 'condition_analysis_url', 'ctrled_analysis' ];
56 }
57 
58 
59 =head1 AUTOLOADED
60 
61  ctrled_analysis_id / ctrled_analysis
62 
63 =cut
64 
65 
66 =head2 condition_analysis_url
67 
68  Arg[1] : (optional) string $url
69  Usage : $self->condition_analysis_url($url);
70  Function: Get/set method for the analysis which must be 'DONE' in order for
71  the controlled analysis to be un-BLOCKED. Specified as a URL.
72  Returns : string
73 
74 =cut
75 
76 sub condition_analysis_url {
77  my $self = shift @_;
78 
79  if(@_) {
80  $self->{'_condition_analysis_url'} = shift @_;
81  if( $self->{'_condition_analysis'} ) {
82  $self->{'_condition_analysis'} = undef;
83  }
84  } elsif( !$self->{'_condition_analysis_url'} and my $condition_analysis=$self->{'_condition_analysis'} ) {
85 
86  my $ref_pipeline = $self->ctrled_analysis && $self->ctrled_analysis->hive_pipeline;
87  $self->{'_condition_analysis_url'} = $condition_analysis->relative_url( $ref_pipeline ); # the URL may be shorter if hive_pipeline is the same for source and target
88  }
89 
90  return $self->{'_condition_analysis_url'};
91 }
92 
93 
94 =head2 condition_analysis
95 
96  Arg[1] : (optional) Bio::EnsEMBL::Hive::Analysis object
97  Usage : $self->condition_analysis($anal);
98  Function: Get/set method for the analysis which must be 'DONE' in order for
99  the controlled analysis to be un-BLOCKED
101 
102 =cut
103 
104 sub condition_analysis {
105  my ($self, $analysis, $no_die) = @_;
106 
107  if( defined $analysis ) {
108  unless ($analysis->isa('Bio::EnsEMBL::Hive::Analysis')) {
109  throw( "condition_analysis arg must be a [Bio::EnsEMBL::Hive::Analysis] not a [$analysis]");
110  }
111  $self->{'_condition_analysis'} = $analysis;
112  }
113 
114  if( !$self->{'_condition_analysis'} and my $condition_analysis_url = $self->condition_analysis_url ) { # lazy-load through TheApiary
115 
116  $self->{'_condition_analysis'} = Bio::EnsEMBL::Hive::TheApiary->find_by_url( $condition_analysis_url, $self->hive_pipeline, $no_die );
117  }
118 
119  return $self->{'_condition_analysis'};
120 }
121 
122 
123 =head2 toString
124 
125  Args : (none)
126  Example : print $c_rule->toString()."\n";
127  Description: returns a stringified representation of the rule
128  Returntype : string
129 
130 =cut
131 
132 sub toString {
133  my $self = shift;
134 
135  return join('',
136  'AnalysisCtrlRule: ',
137  $self->condition_analysis_url,
138  ' ---| ',
139  $self->ctrled_analysis->logic_name,
140  );
141 }
142 
143 1;
144 
Bio::EnsEMBL::Hive::Utils
Definition: Collection.pm:4
Bio::EnsEMBL::Hive::Version
Definition: Version.pm:19
Bio::EnsEMBL::Hive::Cacheable::hive_pipeline
public hive_pipeline()
Bio::EnsEMBL::Hive::Cacheable
Definition: Cacheable.pm:6
run
public run()
Bio::EnsEMBL::Hive::TheApiary::find_by_url
public find_by_url()
Bio::EnsEMBL::Hive::AnalysisCtrlRule
Definition: AnalysisCtrlRule.pm:17
Bio::EnsEMBL::Hive
Definition: Hive.pm:38
Bio::EnsEMBL::Hive::TheApiary
Definition: TheApiary.pm:16
Bio::EnsEMBL::Hive::Analysis
Definition: Analysis.pm:18