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