line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::Workflow::Command::run::Utils::Files::ResolveDeps; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
987
|
use MooseX::App::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
4
|
1
|
|
|
1
|
|
6326
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
450
|
use String::Approx 'amatch'; |
|
1
|
|
|
|
|
2829
|
|
|
1
|
|
|
|
|
56
|
|
7
|
1
|
|
|
1
|
|
258
|
use Algorithm::Dependency::Source::HoA; |
|
1
|
|
|
|
|
2402
|
|
|
1
|
|
|
|
|
26
|
|
8
|
1
|
|
|
1
|
|
248
|
use Algorithm::Dependency::Ordered; |
|
1
|
|
|
|
|
350
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
7
|
use Try::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
10
|
1
|
|
|
1
|
|
7
|
use Path::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
11
|
1
|
|
|
1
|
|
360
|
use Text::ASCIITable; |
|
1
|
|
|
|
|
4859
|
|
|
1
|
|
|
|
|
41
|
|
12
|
1
|
|
|
1
|
|
8
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
838
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
option 'auto_deps' => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => 'Bool', |
17
|
|
|
|
|
|
|
default => 0, |
18
|
|
|
|
|
|
|
documentation => |
19
|
|
|
|
|
|
|
'Create a dependency tree using the INPUT/OUTPUTs of a rule', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'rule_deps' => ( |
23
|
|
|
|
|
|
|
traits => ['Hash'], |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
isa => 'HashRef', |
26
|
|
|
|
|
|
|
default => sub { {} }, |
27
|
|
|
|
|
|
|
handles => { |
28
|
|
|
|
|
|
|
seen_rule_deps_pairs => 'kv', |
29
|
|
|
|
|
|
|
clear_seen_rule_deps => 'clear', |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'graph' => ( |
34
|
|
|
|
|
|
|
traits => ['Hash'], |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
isa => 'HashRef', |
37
|
|
|
|
|
|
|
default => sub { {} }, |
38
|
|
|
|
|
|
|
handles => { |
39
|
|
|
|
|
|
|
seen_graph_pairs => 'kv', |
40
|
|
|
|
|
|
|
clear_seen_graph => 'clear', |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub add_graph { |
45
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
46
|
0
|
|
|
|
|
|
my $cond = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
return unless $self->files; |
49
|
0
|
0
|
|
|
|
|
return unless $self->has_files; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for my $file ( $self->all_files ) { |
52
|
0
|
0
|
|
|
|
|
if ( !exists $self->rule_deps->{ $self->rule_name }->{$cond}->{$file} ) |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
|
$self->rule_deps->{ $self->rule_name }->{$cond}->{$file} = 1; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub post_process_rules { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#Create flags for outputs that have a similar input |
63
|
0
|
|
|
|
|
|
$self->app_log->info(); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->dedeps; |
66
|
0
|
|
|
|
|
|
$self->process_auto_deps; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->print_process_workflow; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub print_process_workflow { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->app_log->info('Post processing rules and printing workflow...'); |
75
|
0
|
|
|
|
|
|
foreach my $rule ( $self->all_rule_names ) { |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#TODO This should be named select_rule_names |
78
|
0
|
|
|
0
|
|
|
my $index = $self->first_index_select_rule_keys( sub { $_ eq $rule } ); |
|
0
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
next if $index == -1; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
0
|
|
|
|
my $meta = $self->process_obj->{$rule}->{meta} || []; |
82
|
0
|
|
0
|
|
|
|
my $text = $self->process_obj->{$rule}->{text} || []; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
map { $self->fh->say($_) } @{$meta}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->fh->say(''); |
86
|
0
|
|
|
|
|
|
map { $self->fh->say($_); $self->fh->say('') } @{$text}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->print_stats_rules($rule); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub print_stats_rules { |
94
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
my $rule = shift; |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
return unless $self->process_obj->{$rule}->{run_stats}; |
98
|
0
|
|
|
|
|
|
$self->fh->say(""); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->fh->say( $self->comment_char ); |
101
|
0
|
|
|
|
|
|
$self->fh->say( |
102
|
|
|
|
|
|
|
$self->comment_char . " Starting " . $rule . "_biox_stats" ); |
103
|
0
|
|
|
|
|
|
$self->fh->say( $self->comment_char ); |
104
|
0
|
|
|
|
|
|
$self->fh->say(""); |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$self->fh->say( $self->comment_char ); |
107
|
0
|
|
|
|
|
|
$self->fh->say( '### HPC Directives' . "\n" ); |
108
|
0
|
|
|
|
|
|
$self->fh->say( $self->comment_char ); |
109
|
0
|
|
|
|
|
|
$self->fh->say( '#HPC jobname=' . $rule . "_biox_stats" ); |
110
|
0
|
|
|
|
|
|
$self->fh->say( '#HPC deps=' . $rule ); |
111
|
0
|
|
|
|
|
|
$self->fh->say('#HPC mem=2GB'); |
112
|
0
|
|
|
|
|
|
$self->fh->say('#HPC cpus_per_task=1'); |
113
|
0
|
|
|
|
|
|
$self->fh->say('#HPC commands_per_node=1000'); |
114
|
0
|
|
|
|
|
|
$self->fh->say( $self->comment_char ); |
115
|
0
|
|
|
|
|
|
$self->fh->say(""); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
foreach my $sample ($self->all_samples){ |
118
|
0
|
|
|
|
|
|
$self->fh->say(""); |
119
|
0
|
|
|
|
|
|
$self->fh->say( |
120
|
|
|
|
|
|
|
"biox stats --samples " . $sample . " \\" ); |
121
|
0
|
|
|
|
|
|
$self->fh->say( "--select_rules " . $rule . " \\" ); |
122
|
0
|
|
|
|
|
|
$self->fh->say( "-w " . $self->cached_workflow ); |
123
|
0
|
|
|
|
|
|
$self->fh->say(""); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head3 dedeps |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
If using select_rules comment out the #HPC deps portion on the first rule |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#TODO add this in to iter_hash_hpc instead of here, account for select_btwn |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub dedeps { |
136
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
137
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
return unless $self->has_select_rule_keys; |
139
|
0
|
0
|
|
|
|
|
return unless $self->select_effect; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my $first_rule = $self->select_rule_keys->[0]; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my $meta = $self->process_obj->{$first_rule}->{meta}; |
144
|
0
|
0
|
|
|
|
|
$meta = [] unless $meta; |
145
|
0
|
|
|
|
|
|
my $before_meta = join( "\n", @{$meta} ); |
|
0
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$before_meta =~ s/#HPC deps=/##HPC deps=/g; |
148
|
0
|
|
|
|
|
|
my @text = split( "\n", $before_meta ); |
149
|
0
|
|
|
|
|
|
$self->process_obj->{$first_rule}->{meta} = \@text; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head3 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Iterate over rule_names |
155
|
|
|
|
|
|
|
If they are in select_rules use those also |
156
|
|
|
|
|
|
|
Otherwise only use the schedule |
157
|
|
|
|
|
|
|
If using timestamps we have a timestamp, but in no particular order |
158
|
|
|
|
|
|
|
If select rules we have select_rules, but also in no particular Ordered |
159
|
|
|
|
|
|
|
for $s @schedule { if print_rule (print the process_obj)} |
160
|
|
|
|
|
|
|
We also need to update the #HPC meta to include deps |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub process_auto_deps { |
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
166
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
return unless $self->auto_deps; |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
foreach my $rule ( $self->all_select_rule_keys ) { |
170
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
$self->graph->{$rule} = [] if !exists $self->graph->{$rule}; |
172
|
0
|
|
|
|
|
|
my $meta = $self->process_obj->{$rule}->{meta}; |
173
|
0
|
0
|
|
|
|
|
$meta = [] unless $meta; |
174
|
0
|
|
|
|
|
|
my $before_meta = join( "\n", @{$meta} ); |
|
0
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
if ( $before_meta =~ m/#HPC deps=/ ) { |
177
|
0
|
|
|
|
|
|
next; |
178
|
|
|
|
|
|
|
} |
179
|
0
|
|
|
|
|
|
my @deps = @{ $self->graph->{$rule} }; |
|
0
|
|
|
|
|
|
|
180
|
0
|
0
|
|
|
|
|
if (@deps) { |
181
|
0
|
|
|
|
|
|
chomp($before_meta); |
182
|
0
|
|
|
|
|
|
$before_meta .= "\n#HPC deps=" . join( ',', @deps ) . "\n\n"; |
183
|
|
|
|
|
|
|
} |
184
|
0
|
|
|
|
|
|
my @text = split( "\n", $before_meta ); |
185
|
0
|
|
|
|
|
|
$self->process_obj->{$rule}->{meta} = \@text; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |