line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::Workflow::Command::run::Rules::Directives; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
8266
|
use namespace::autoclean; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
11
|
|
5
|
1
|
|
|
1
|
|
112
|
use Moose::Util qw/apply_all_roles/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::HPC'; |
8
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::Path'; |
9
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::List'; |
10
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::Stash'; |
11
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::Hash'; |
12
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::Array'; |
13
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::CSV'; |
14
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::Config'; |
15
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Interpolate'; |
16
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Sample'; |
17
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Walk'; |
18
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::Utils::Log'; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
450
|
use Try::Tiny; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1298
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 Other Directives |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'register_types' => ( |
27
|
|
|
|
|
|
|
traits => ['Hash'], |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
isa => 'HashRef', |
30
|
|
|
|
|
|
|
default => sub { return {} }, |
31
|
|
|
|
|
|
|
handles => { |
32
|
|
|
|
|
|
|
'get_register_types' => 'get', |
33
|
|
|
|
|
|
|
'set_register_types' => 'set', |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'register_process_directives' => ( |
38
|
|
|
|
|
|
|
traits => ['Hash'], |
39
|
|
|
|
|
|
|
is => 'rw', |
40
|
|
|
|
|
|
|
isa => 'HashRef', |
41
|
|
|
|
|
|
|
default => sub { return {} }, |
42
|
|
|
|
|
|
|
handles => { |
43
|
|
|
|
|
|
|
'get_register_process_directives' => 'get', |
44
|
|
|
|
|
|
|
'set_register_process_directives' => 'set', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
##TODO add this so that we can have user defined types |
49
|
|
|
|
|
|
|
has 'register_namespace' => ( |
50
|
|
|
|
|
|
|
traits => ['Array'], |
51
|
|
|
|
|
|
|
is => 'rw', |
52
|
|
|
|
|
|
|
isa => 'ArrayRef', |
53
|
|
|
|
|
|
|
default => sub { [] }, |
54
|
|
|
|
|
|
|
handles => { |
55
|
|
|
|
|
|
|
'all_register_namespace' => 'elements', |
56
|
|
|
|
|
|
|
'count_register_namespace' => 'count', |
57
|
|
|
|
|
|
|
'has_register_namespace' => 'count', |
58
|
|
|
|
|
|
|
'has_no_register_namespace' => 'is_empty', |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
trigger => sub { |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
foreach my $role ( $self->all_register_namespace ) { |
63
|
|
|
|
|
|
|
try { |
64
|
|
|
|
|
|
|
apply_all_roles( $self, $role ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
catch { |
67
|
|
|
|
|
|
|
$self->app_log->warn( |
68
|
|
|
|
|
|
|
'There was an error registering role ' . $role ); |
69
|
|
|
|
|
|
|
$self->app_log->warn("$_\n"); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has 'override_process' => ( |
76
|
|
|
|
|
|
|
traits => ['Bool'], |
77
|
|
|
|
|
|
|
is => 'rw', |
78
|
|
|
|
|
|
|
isa => 'Bool', |
79
|
|
|
|
|
|
|
default => 0, |
80
|
|
|
|
|
|
|
predicate => 'has_override_process', |
81
|
|
|
|
|
|
|
documentation => |
82
|
|
|
|
|
|
|
q(Instead of for my $sample (@sample){ DO STUFF } just DOSTUFF), |
83
|
|
|
|
|
|
|
handles => { |
84
|
|
|
|
|
|
|
set_override_process => 'set', |
85
|
|
|
|
|
|
|
clear_override_process => 'unset', |
86
|
|
|
|
|
|
|
}, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
##Add in support for chunks |
90
|
|
|
|
|
|
|
##This is useful for features where we want to do things like |
91
|
|
|
|
|
|
|
##split a file into parts |
92
|
|
|
|
|
|
|
##count by kmers, etc |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 create_attr |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Add attributes to $self-> namespace |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub create_attr { |
101
|
0
|
|
|
0
|
|
|
my $self = shift; |
102
|
0
|
|
|
|
|
|
my $data = shift; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $meta = __PACKAGE__->meta; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$meta->make_mutable; |
107
|
0
|
|
|
|
|
|
my $seen = {}; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
for my $attr ( $meta->get_all_attributes ) { |
110
|
0
|
0
|
|
|
|
|
next if $attr->name eq 'stash'; |
111
|
0
|
|
|
|
|
|
$seen->{ $attr->name } = 1; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Get workflow_data structure |
115
|
|
|
|
|
|
|
# Workflow is an array of hashes |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
foreach my $href ( @{$data} ) { |
|
0
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
0
|
0
|
|
|
|
|
if ( !ref($href) eq 'HASH' ) { |
120
|
|
|
|
|
|
|
##TODO add more informative structure options here |
121
|
|
|
|
|
|
|
##TODO Add app_log |
122
|
0
|
|
|
|
|
|
warn 'Your variable declarations should be key/value!'; |
123
|
0
|
|
|
|
|
|
return; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each( %{$href} ) ) { |
|
0
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
|
if ( !exists $seen->{$k} ) { |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
if ( $k eq 'stash' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$self->merge_stash($v); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
elsif ( $self->can($k) ) { |
134
|
|
|
|
|
|
|
##Should this be next of just skip ? |
135
|
0
|
|
|
|
|
|
next; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
elsif ( $self->search_registered_types( $meta, $k, $v ) ) { |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# next; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
elsif ( ref($v) eq 'HASH' ) { |
142
|
0
|
|
|
|
|
|
$self->create_HASH_attr( $meta, $k ); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
elsif ( ref($v) eq 'ARRAY' ) { |
145
|
0
|
|
|
|
|
|
$self->create_ARRAY_attr( $meta, $k ); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
else { |
148
|
0
|
|
|
|
|
|
$self->create_reg_attr( $meta, $k ); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
try{ |
153
|
0
|
0
|
|
0
|
|
|
$self->$k($v) if defined $v; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
catch{ |
156
|
0
|
|
|
0
|
|
|
$self->app_log->warn( |
157
|
|
|
|
|
|
|
'There was an assiging key. ' . $k ); |
158
|
0
|
|
|
|
|
|
$self->app_log->warn("$_\n"); |
159
|
|
|
|
|
|
|
} |
160
|
0
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
$meta->make_immutable; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub search_registered_types { |
168
|
0
|
|
|
0
|
|
|
my $self = shift; |
169
|
0
|
|
|
|
|
|
my $meta = shift; |
170
|
0
|
|
|
|
|
|
my $k = shift; |
171
|
0
|
|
|
|
|
|
my $v = shift; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
foreach my $key ( keys %{ $self->register_types } ) { |
|
0
|
|
|
|
|
|
|
174
|
0
|
0
|
|
|
|
|
next unless exists $self->register_types->{$key}->{lookup}; |
175
|
0
|
0
|
|
|
|
|
next unless exists $self->register_types->{$key}->{builder}; |
176
|
0
|
|
|
|
|
|
my $lookup_ref = $self->register_types->{$key}->{lookup}; |
177
|
0
|
|
|
|
|
|
my $builder = $self->register_types->{$key}->{builder}; |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
foreach my $lookup ( @{$lookup_ref} ) { |
|
0
|
|
|
|
|
|
|
180
|
0
|
0
|
|
|
|
|
if ( $k =~ m/$lookup/ ) { |
181
|
0
|
|
|
|
|
|
$self->$builder( $meta, $k, $v ); |
182
|
0
|
|
|
|
|
|
return 1; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
return 0; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub create_reg_attr { |
191
|
0
|
|
|
0
|
|
|
my $self = shift; |
192
|
0
|
|
|
|
|
|
my $meta = shift; |
193
|
0
|
|
|
|
|
|
my $k = shift; |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
$meta->add_attribute( |
196
|
|
|
|
|
|
|
$k => ( |
197
|
|
|
|
|
|
|
is => 'rw', |
198
|
|
|
|
|
|
|
lazy_build => 1, |
199
|
|
|
|
|
|
|
) |
200
|
|
|
|
|
|
|
); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head3 create_blank_attr |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
placeholder for some types |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub create_blank_attr { |
210
|
0
|
|
|
0
|
|
|
my $self = shift; |
211
|
0
|
|
|
|
|
|
my $meta = shift; |
212
|
0
|
|
|
|
|
|
my $k = shift; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
$meta->add_attribute( |
215
|
|
|
|
|
|
|
$k => ( |
216
|
|
|
|
|
|
|
is => 'rw', |
217
|
|
|
|
|
|
|
default => '', |
218
|
|
|
|
|
|
|
) |
219
|
|
|
|
|
|
|
); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub BUILD { } |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
after 'BUILD' => sub { |
225
|
|
|
|
|
|
|
my $self = shift; |
226
|
|
|
|
|
|
|
$self->interpol_directive_cache( {} ); |
227
|
|
|
|
|
|
|
}; |
228
|
|
|
|
|
|
|
|
229
|
1
|
|
|
1
|
|
27
|
no Moose; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
7
|
|
230
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
1; |