ensembl-hive  2.6
DataflowTarget.pm
Go to the documentation of this file.
1 =pod
2 
3 =head1 NAME
4 
6 
7 =head1 LICENSE
8 
9  Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
10  Copyright [2016-2024] EMBL-European Bioinformatics Institute
11 
12  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
13  You may obtain a copy of the License at
14 
15  http://www.apache.org/licenses/LICENSE-2.0
16 
17  Unless required by applicable law or agreed to in writing, software distributed under the License
18  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and limitations under the License.
20 
21 =head1 CONTACT
22 
23  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
24 
25 =cut
26 
27 
28 package Bio::EnsEMBL::Hive::DataflowTarget;
29 
30 use strict;
31 use warnings;
32 
33 use Bio::EnsEMBL::Hive::Utils ('stringify', 'throw');
35 
36 use base ( 'Bio::EnsEMBL::Hive::Storable' );
37 
38 
39 sub unikey { # override the default from Cacheable parent
40  return [ 'source_dataflow_rule', 'on_condition', 'input_id_template', 'to_analysis_url' ];
41 }
42 
43 
44 =head1 AUTOLOADED
45 
46  source_dataflow_rule_id / source_dataflow_rule
47 
48 =cut
49 
50 
51 =head2 on_condition
52 
53  Function: getter/setter method for the on_condition of the dataflow target
54 
55 =cut
56 
57 sub on_condition {
58  my $self = shift @_;
59 
60  if(@_) {
61  $self->{'_on_condition'} = shift @_;
62  }
63  return $self->{'_on_condition'};
64 }
65 
66 
67 =head2 input_id_template
68 
69  Function: getter/setter method for the input_id_template of the dataflow target
70 
71 =cut
72 
73 sub input_id_template {
74  my $self = shift @_;
75 
76  if(@_) {
77  my $input_id_template = shift @_;
78  $self->{'_input_id_template'} = (ref($input_id_template) ? stringify($input_id_template) : $input_id_template),
79  }
80  return $self->{'_input_id_template'};
81 }
82 
83 
84 =head2 extend_param_stack
85 
86  Function: getter/setter method. The boolean value defines whether the newly created jobs will inherit both the parameters and the accu of the prev_job.
87 
88 =cut
89 
90 sub extend_param_stack {
91  my $self = shift @_;
92 
93  if(@_) {
94  $self->{'_extend_param_stack'} = shift @_;
95  }
96  return $self->{'_extend_param_stack'};
97 }
98 
99 
100 =head2 to_analysis_url
101 
102  Arg[1] : (optional) string $url
103  Usage : $self->to_analysis_url($url);
104  Function: Get/set method for the 'to' analysis objects URL for this rule
105  Returns : string
106 
107 =cut
108 
109 sub to_analysis_url {
110  my $self = shift @_;
111 
112  if(@_) {
113  $self->{'_to_analysis_url'} = shift @_;
114  if( $self->{'_to_analysis'} ) {
115  $self->{'_to_analysis'} = undef;
116  }
117  } elsif( !$self->{'_to_analysis_url'} and my $target_object=$self->{'_to_analysis'} ) {
118 
119  my $ref_pipeline = $self->from_analysis && $self->from_analysis->hive_pipeline;
120  $self->{'_to_analysis_url'} = $target_object->relative_url( $ref_pipeline ); # the URL may be shorter if hive_pipeline is the same for source and target
121  }
122 
123  return $self->{'_to_analysis_url'};
124 }
125 
126 
127 =head2 to_analysis
128 
129  Usage : $self->to_analysis($analysis);
130  Function: Get/set method for the goal analysis object of this rule.
133 
134 =cut
135 
136 sub to_analysis {
137  my ($self, $target_object) = @_;
138 
139  if( defined $target_object ) {
140  unless ($target_object->can('url')) {
141  throw( "to_analysis arg must support 'url' method, '$target_object' does not know how to do it");
142  }
143  $self->{'_to_analysis'} = $target_object;
144  }
145 
146  if( !$self->{'_to_analysis'} and my $to_analysis_url = $self->to_analysis_url ) { # lazy-load through TheApiary
147 
148  $self->{'_to_analysis'} = Bio::EnsEMBL::Hive::TheApiary->find_by_url( $to_analysis_url, $self->hive_pipeline );
149  }
150 
151  return $self->{'_to_analysis'};
152 }
153 
154 
155 =head2 toString
156 
157  Args : (none)
158  Example : print $df_rule->toString()."\n";
159  Description: returns a stringified representation of the rule
160  Returntype : string
161 
162 =cut
163 
164 sub toString {
165  my $self = shift @_;
166  my $short = shift @_;
167 
168  my $on_condition = $self->on_condition;
169 
170  return join('',
171  $short ? () : ( 'DataflowTarget: ' ),
172  defined($on_condition) ? 'WHEN '.$on_condition : 'DEFAULT ',
173  '--> ',
174  $self->to_analysis_url,
175  ($self->input_id_template ? (' WITH TEMPLATE: '.$self->input_id_template) : ''),
176  );
177 }
178 
179 1;
180 
Bio::EnsEMBL::Hive::Utils
Definition: Collection.pm:4
Bio::EnsEMBL::Hive::NakedTable
Definition: NakedTable.pm:10
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
Bio::EnsEMBL::Hive::Accumulator
Definition: Accumulator.pm:11
Bio::EnsEMBL::Hive::TheApiary::find_by_url
public find_by_url()
Bio::EnsEMBL::Hive::DataflowTarget
Definition: DataflowTarget.pm:6
Bio::EnsEMBL::Hive
Definition: Hive.pm:38
Bio::EnsEMBL::Hive::TheApiary
Definition: TheApiary.pm:16
Bio::EnsEMBL::Hive::Analysis
Definition: Analysis.pm:18