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