blib/lib/BioX/Workflow/Command/run/Utils/Files/ResolveDeps.pm

filter: Statementstmt 31.9% 31 / 97 Branchbran 0.0% 0 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 56.2% 9 / 16 Podpod 20.0% 1 / 5 totaltotal 28.8% 41 / 142 CC 16 SCAR 30.8
CC
16
Cov
26%
process_auto_deps
56.0
add_graph
30.0
dedeps
20.0
CRAP 21.7
« blib/lib/BioX/Workflow/Command/run/Utils/WriteMeta.pm ↑ Summary blib/lib/BioX/Workflow/Command/run/Rules/Directives/Inspect.pm »
1 package BioX::Workflow::Command::run::Utils::Files::ResolveDeps;
2  
3 1 ▶use MooseX::App::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use String::Approx 'amatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Algorithm::Dependency::Source::HoA;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Algorithm::Dependency::Ordered;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Text::ASCIITable;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 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 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 1 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 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 1 handles => {
39 seen_graph_pairs => 'kv',
40 clear_seen_graph => 'clear',
41 },
42 );
43  
44 sub add_graph {
45 0 ▶ my $self = shift;
Subroutine add_graph: not called CC=5 SCAR=34.0
Pod undocumented
46 0 my $cond = shift;
47  
48 0 ▶ return unless $self->files;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->files 0 0 0
49 0 ▶ return unless $self->has_files;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_files 0 0 0
50  
51 0 for my $file ( $self->all_files ) {
52 0 ▶ if ( !exists $self->rule_deps->{ $self->rule_name }->{$cond}->{$file} )
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->rule_deps->{$self->rule_name}{$cond}{$file}) 0 0 0
53 {
54 0 $self->rule_deps->{ $self->rule_name }->{$cond}->{$file} = 1;
55 }
56 }
57 }
58  
59 sub post_process_rules {
60 0 ▶ my $self = shift;
Subroutine post_process_rules: not called CC=1 SCAR=6.9
Pod undocumented
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_stats_rules {
72 0 ▶ my $self = shift;
Subroutine print_stats_rules: not called CC=3 SCAR=24.8
Pod undocumented
73 0 my $rule = shift;
74  
75 0 ▶ return unless $self->process_obj->{$rule}->{run_stats};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->process_obj->{$rule}{"run_stats"} 0 0 0
76 0 $self->fh->say("");
77  
78 0 $self->fh->say( $self->comment_char );
79 0 $self->fh->say(
80 $self->comment_char . " Starting " . $rule . "_biox_stats" );
81 0 $self->fh->say( $self->comment_char );
82 0 $self->fh->say("");
83  
84 0 $self->fh->say( $self->comment_char );
85 0 $self->fh->say( '### HPC Directives' . "\n" );
86 0 $self->fh->say( $self->comment_char );
87 0 $self->fh->say( '#HPC jobname=' . $rule . "_biox_stats" );
88 0 $self->fh->say( '#HPC deps=' . $rule );
89 0 $self->fh->say('#HPC mem=2GB');
90 0 $self->fh->say('#HPC cpus_per_task=1');
91 0 $self->fh->say('#HPC commands_per_node=1000');
92 0 $self->fh->say( $self->comment_char );
93 0 $self->fh->say("");
94  
95 0 foreach my $sample ($self->all_samples){
96 0 $self->fh->say("");
97 0 $self->fh->say(
98 "biox stats --samples " . $sample . " \\" );
99 0 $self->fh->say( "--select_rules " . $rule . " \\" );
100 0 $self->fh->say( "-w " . $self->cached_workflow );
101 0 $self->fh->say("");
102 }
103 }
104  
105 =head3 dedeps
106  
107 If using select_rules comment out the #HPC deps portion on the first rule
108  
109 #TODO add this in to iter_hash_hpc instead of here, account for select_btwn
110  
111 =cut
112  
113 sub dedeps {
114 0 ▶ my $self = shift;
Subroutine dedeps: not called CC=4 SCAR=30.0
Pod documented
115  
116 0 ▶ return unless $self->has_select_rule_keys;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_select_rule_keys 0 0 0
117 0 ▶ return unless $self->select_effect;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->select_effect 0 0 0
118  
119 0 my $first_rule = $self->select_rule_keys->[0];
120  
121 0 my $meta = $self->process_obj->{$first_rule}->{meta};
122 0 ▶ $meta = [] unless $meta;
Branch: 1 branch
BranchTrueFalseTotal
unless $meta 0 0 0
123 0 my $before_meta = join( "\n", @{$meta} );
124  
125 0 $before_meta =~ s/#HPC deps=/##HPC deps=/g;
126 0 my @text = split( "\n", $before_meta );
127 0 $self->process_obj->{$first_rule}->{meta} = \@text;
128 }
129  
130 =head3
131  
132 Iterate over rule_names
133 If they are in select_rules use those also
134 Otherwise only use the schedule
135 If using timestamps we have a timestamp, but in no particular order
136 If select rules we have select_rules, but also in no particular Ordered
137 for $s @schedule { if print_rule (print the process_obj)}
138 We also need to update the #HPC meta to include deps
139  
140 =cut
141  
142 sub process_auto_deps {
143 0 ▶ my $self = shift;
Subroutine process_auto_deps: not called CC=7 SCAR=40.3
Pod undocumented
144  
145 0 ▶ return unless $self->auto_deps;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->auto_deps 0 0 0
146  
147 0 foreach my $rule ( $self->all_select_rule_keys ) {
148  
149 0 ▶ $self->graph->{$rule} = [] if !exists $self->graph->{$rule};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->graph->{$rule} 0 0 0
150 0 my $meta = $self->process_obj->{$rule}->{meta};
151 0 ▶ $meta = [] unless $meta;
Branch: 1 branch
BranchTrueFalseTotal
unless $meta 0 0 0
152 0 my $before_meta = join( "\n", @{$meta} );
153  
154 0 ▶ if ( $before_meta =~ m/#HPC deps=/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($before_meta =~ /#HPC deps=/) 0 0 0
155 0 next;
156 }
157 0 my @deps = @{ $self->graph->{$rule} };
158 0 ▶ if (@deps) {
Branch: 1 branch
BranchTrueFalseTotal
if (@deps) 0 0 0
159 0 chomp($before_meta);
160 0 $before_meta .= "\n#HPC deps=" . join( ',', @deps ) . "\n\n";
161 }
162 0 my @text = split( "\n", $before_meta );
163 0 $self->process_obj->{$rule}->{meta} = \@text;
164 }
165 }
166  
167 1 1;
« blib/lib/BioX/Workflow/Command/run/Utils/WriteMeta.pm ↑ Summary blib/lib/BioX/Workflow/Command/run/Rules/Directives/Inspect.pm »