line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::Workflow::Command::run::Utils::Attributes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1519
|
use MooseX::App::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
15
|
|
4
|
1
|
|
|
1
|
|
11119
|
use BioX::Workflow::Command::Utils::Traits qw(ArrayRefOfStrs); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
5
|
1
|
|
|
1
|
|
1378
|
use Storable qw(dclone); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
74
|
|
6
|
1
|
|
|
1
|
|
431
|
use File::Copy; |
|
1
|
|
|
|
|
2892
|
|
|
1
|
|
|
|
|
74
|
|
7
|
1
|
|
|
1
|
|
8
|
use File::Spec; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
28
|
|
8
|
1
|
|
|
1
|
|
7
|
use File::Basename; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
82
|
|
9
|
1
|
|
|
1
|
|
8
|
use DateTime; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
866
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 Name |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BioX::Workflow::Command::run::Utils::Attributes |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 Description |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Attributes that are used for the duration of run |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 Command Line Options |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
option 'samples' => ( |
26
|
|
|
|
|
|
|
traits => ['Array'], |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
required => 0, |
29
|
|
|
|
|
|
|
isa => ArrayRefOfStrs, |
30
|
|
|
|
|
|
|
documentation => 'Choose a subset of samples', |
31
|
|
|
|
|
|
|
default => sub { [] }, |
32
|
|
|
|
|
|
|
cmd_split => qr/,/, |
33
|
|
|
|
|
|
|
handles => { |
34
|
|
|
|
|
|
|
all_samples => 'elements', |
35
|
|
|
|
|
|
|
has_samples => 'count', |
36
|
|
|
|
|
|
|
join_samples => 'join', |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
cmd_aliases => ['s'], |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
option 'run_stats' => ( |
42
|
|
|
|
|
|
|
is => 'rw', |
43
|
|
|
|
|
|
|
isa => 'Bool', |
44
|
|
|
|
|
|
|
default => 1, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'cached_workflow' => ( |
48
|
|
|
|
|
|
|
is => 'rw', |
49
|
|
|
|
|
|
|
isa => 'Str', |
50
|
|
|
|
|
|
|
lazy => 1, |
51
|
|
|
|
|
|
|
default => '', |
52
|
|
|
|
|
|
|
default => sub { |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my ( $file, $dir, $ext ) = fileparse( $self->workflow, qr/\.[^.]*/ ); |
56
|
|
|
|
|
|
|
my $now = DateTime->now; |
57
|
|
|
|
|
|
|
my $ymd = $now->ymd; |
58
|
|
|
|
|
|
|
my $hms = $now->hms; |
59
|
|
|
|
|
|
|
$hms =~ s/:/-/g; |
60
|
|
|
|
|
|
|
return File::Spec->catdir( $self->cache_dir, '.biox-cache', 'workflows', |
61
|
|
|
|
|
|
|
$file . "_$ymd" . "_$hms" . $ext ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 Attributes |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head3 local_rule1 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Rule we are currently evaluating |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has 'local_rule' => ( |
77
|
|
|
|
|
|
|
is => 'rw', |
78
|
|
|
|
|
|
|
isa => 'HashRef', |
79
|
|
|
|
|
|
|
lazy_build => 1, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head3 global_attr |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Attributes defined in the global key of the config |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
has 'global_attr' => ( |
89
|
|
|
|
|
|
|
is => 'rw', |
90
|
|
|
|
|
|
|
isa => 'BioX::Workflow::Command::run::Rules::Directives', |
91
|
|
|
|
|
|
|
required => 0, |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 local_attr |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Attributes in the local key of the rule |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
has 'local_attr' => ( |
101
|
|
|
|
|
|
|
is => 'rw', |
102
|
|
|
|
|
|
|
isa => 'BioX::Workflow::Command::run::Rules::Directives', |
103
|
|
|
|
|
|
|
required => 0, |
104
|
|
|
|
|
|
|
); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
has 'p_local_attr' => ( |
107
|
|
|
|
|
|
|
is => 'rw', |
108
|
|
|
|
|
|
|
isa => 'BioX::Workflow::Command::run::Rules::Directives', |
109
|
|
|
|
|
|
|
required => 0, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
has 'rule_name' => ( |
113
|
|
|
|
|
|
|
is => 'rw', |
114
|
|
|
|
|
|
|
isa => 'Str', |
115
|
|
|
|
|
|
|
lazy_build => 1, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
has 'rule_names' => ( |
119
|
|
|
|
|
|
|
traits => ['Array'], |
120
|
|
|
|
|
|
|
is => 'rw', |
121
|
|
|
|
|
|
|
isa => 'ArrayRef', |
122
|
|
|
|
|
|
|
default => sub { [] }, |
123
|
|
|
|
|
|
|
handles => { |
124
|
|
|
|
|
|
|
all_rule_names => 'elements', |
125
|
|
|
|
|
|
|
has_rule_names => 'count', |
126
|
|
|
|
|
|
|
join_rule_names => 'join', |
127
|
|
|
|
|
|
|
first_index_rule_names => 'first_index', |
128
|
|
|
|
|
|
|
grep_rule_names => 'grep', |
129
|
|
|
|
|
|
|
}, |
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
has 'select_rule_keys' => ( |
133
|
|
|
|
|
|
|
traits => ['Array'], |
134
|
|
|
|
|
|
|
is => 'rw', |
135
|
|
|
|
|
|
|
isa => 'ArrayRef', |
136
|
|
|
|
|
|
|
default => sub { [] }, |
137
|
|
|
|
|
|
|
handles => { |
138
|
|
|
|
|
|
|
all_select_rule_keys => 'elements', |
139
|
|
|
|
|
|
|
has_select_rule_keys => 'count', |
140
|
|
|
|
|
|
|
join_select_rule_keys => 'join', |
141
|
|
|
|
|
|
|
first_index_select_rule_keys => 'first_index', |
142
|
|
|
|
|
|
|
add_select_rule_key => 'push', |
143
|
|
|
|
|
|
|
}, |
144
|
|
|
|
|
|
|
); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
has 'omit_rule_keys' => ( |
147
|
|
|
|
|
|
|
traits => ['Array'], |
148
|
|
|
|
|
|
|
is => 'rw', |
149
|
|
|
|
|
|
|
isa => 'ArrayRef', |
150
|
|
|
|
|
|
|
default => sub { [] }, |
151
|
|
|
|
|
|
|
handles => { |
152
|
|
|
|
|
|
|
all_omit_rule_keys => 'elements', |
153
|
|
|
|
|
|
|
has_omit_rule_keys => 'count', |
154
|
|
|
|
|
|
|
join_omit_rule_keys => 'join', |
155
|
|
|
|
|
|
|
first_index_omit_rule_keys => 'first_index', |
156
|
|
|
|
|
|
|
add_omit_rule_key => 'push', |
157
|
|
|
|
|
|
|
}, |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
has 'p_rule_name' => ( |
161
|
|
|
|
|
|
|
is => 'rw', |
162
|
|
|
|
|
|
|
isa => 'Str', |
163
|
|
|
|
|
|
|
lazy_build => 1, |
164
|
|
|
|
|
|
|
); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head3 process_obj |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Store all the text from processing the rules |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
At the end we will decide which rules to print |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
has 'process_obj' => ( |
175
|
|
|
|
|
|
|
traits => ['Hash'], |
176
|
|
|
|
|
|
|
is => 'rw', |
177
|
|
|
|
|
|
|
isa => 'HashRef', |
178
|
|
|
|
|
|
|
default => sub { {} }, |
179
|
|
|
|
|
|
|
handles => { |
180
|
|
|
|
|
|
|
seen_process_obj_pairs => 'kv', |
181
|
|
|
|
|
|
|
clear_seen_process_obj => 'clear', |
182
|
|
|
|
|
|
|
}, |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub apply_local_attr { |
186
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
187
|
|
|
|
|
|
|
|
188
|
0
|
0
|
|
|
|
|
return unless exists $self->local_rule->{ $self->rule_name }->{local}; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
$self->local_attr->create_attr( |
191
|
0
|
|
|
|
|
|
$self->local_rule->{ $self->rule_name }->{local} ); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub apply_global_attributes { |
196
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
197
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
my $global_attr = BioX::Workflow::Command::run::Rules::Directives->new(); |
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
$self->global_attr($global_attr); |
201
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
|
return unless exists $self->workflow_data->{global}; |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
$self->global_attr->create_attr( $self->workflow_data->{global} ); |
205
|
|
|
|
|
|
|
|
206
|
0
|
0
|
|
|
|
|
if ( exists $self->global_attr->chunks->{start} ) { |
207
|
0
|
|
|
|
|
|
$self->global_attr->use_chunks(1); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
1; |