lib/BioX/Workflow.pm

filter: Statementstmt 83.8% 228 / 272 Branchbran 58.5% 48 / 82 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 94.8% 37 / 39 Podpod 73.6% 14 / 19 totaltotal 77.9% 329 / 422 CC 56 SCAR 18.3
CC
56
Cov
77%
init_process_vars
14.8
clear_attr
12.0
write_pipeline
11.1
CRAP 6.2
« lib/BioX/Workflow/StructureOutput.pm ↑ Summary lib/BioX/Workflow/WriteMeta.pm »
1 package BioX::Workflow;
2  
3 2 ▶use 5.008_005;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 our $VERSION = '1.10';
5  
6 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use File::Path qw(make_path remove_tree);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Cwd qw(abs_path getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use List::Compare;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use YAML::XS 'LoadFile';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Config::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Class::Load ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Interpolation E => 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Text::Template qw(fill_in_file fill_in_string);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Data::Pairs;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use MooseX::Types::Path::Tiny qw/Path Paths AbsPath/;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 extends 'BioX::Wrapper';
25  
26 2 with 'BioX::Workflow::Samples';
27 2 with 'BioX::Workflow::Debug';
28 2 with 'BioX::Workflow::SpecialVars';
29 2 with 'BioX::Workflow::StructureOutput';
30 2 with 'BioX::Workflow::WriteMeta';
31 2 with 'BioX::Workflow::Rules';
32  
33 2 with 'MooseX::Getopt::Usage';
34 2 with 'MooseX::Getopt::Usage::Role::Man';
35 2 with 'MooseX::SimpleConfig';
36 2 with 'MooseX::Object::Pluggable';
37  
38 2 ▶use MooseX::FileAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 # For pretty man pages!
41  
42 2 $ENV{TERM} = 'xterm-256color';
43  
44 =encoding utf-7
45  
46 =head1 NAME
47  
48 BioX::Workflow - A very opinionated template based workflow writer.
49  
50 =head1 SYNOPSIS
51  
52 Most of the functionality can be accessed through the biox-workflow.pl script.
53  
54 biox-workflow.pl --workflow /path/to/workflow.yml
55  
56 This module was written with Bioinformatics workflows in mind, but should be extensible to any sort of workflow or pipeline.
57  
58 =head1 Usage
59  
60 Please check out the full Usage Docs at L<BioX::Workflow::Usage>
61  
62 Alternately, check out the github pages at L<http://jerowe.github.io/BioX-Workflow-Docs/showcase.html>. This format may be easier to read.
63  
64 =head1 In Code Documenation
65  
66 You shouldn't really need to look here unless you have some reason to do some serious hacking.
67  
68 =head2 Attributes
69  
70 Moose attributes. Technically any of these can be changed, but may break everything.
71  
72 =head3 comment_char
73  
74 This should really be in BioX::Wrapper
75  
76 =cut
77  
78 2 has '+comment_char' => (
79 predicate => 'has_comment_char',
80 clearer => 'clear_comment_char',
81 );
82  
83 =head3 workflow
84  
85 Path to workflow workflow. This must be a YAML file.
86  
87 =cut
88  
89 2 has_file 'workflow' => (
90 is => 'rw',
91 required => 1,
92 must_exist => 1,
93 documentation => q{Your configuration workflow file.},
94 );
95  
96 =head3 rule_based
97  
98 This is the default. The outer loop are the rules, not the samples
99  
100 =cut
101  
102 2 has 'rule_based' => (
103 is => 'rw',
104 isa => 'Bool',
105 default => 1,
106 );
107  
108 =head3 sample_based
109  
110 Default Value. The outer loop is samples, not rules. Must be set in your global values or on the command line --sample_based 1
111  
112 If you ever have resample: 1 in your config you should NOT set this value to true!
113  
114 =cut
115  
116 2 has 'sample_based' => (
117 is => 'rw',
118 isa => 'Bool',
119 default => 0,
120 );
121  
122 =head2 stash
123  
124 This isn't ever used in the code. Its just there incase you want to persist objects across rules
125  
126 It uses Moose::Meta::Attribute::Native::Trait::Hash and supports all the methods.
127  
128 set_stash => 'set',
129 get_stash => 'get',
130 has_no_stash => 'is_empty',
131 num_stashs => 'count',
132 delete_stash => 'delete',
133 stash_pairs => 'kv',
134  
135 =cut
136  
137 has 'stash' => (
138 is => 'rw',
139 isa => 'HashRef',
140 traits => ['Hash'],
141 6 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
142 2 handles => {
143 set_stash => 'set',
144 get_stash => 'get',
145 has_no_stash => 'is_empty',
146 num_stashs => 'count',
147 delete_stash => 'delete',
148 stash_pairs => 'kv',
149 },
150 );
151  
152 =head2 plugins
153  
154 Load plugins as an opt
155  
156 =cut
157  
158 has 'plugins' => (
159 is => 'rw',
160 isa => 'ArrayRef',
161 6 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
162 2 );
163  
164 =head3 No GetOpt Here
165  
166 =cut
167  
168 2 has 'yaml' => (
169 traits => ['NoGetopt'],
170 is => 'rw',
171 );
172  
173 =head3 attr
174  
175 attributes read in from runtime
176  
177 =cut
178  
179 2 has 'attr' => (
180 traits => ['NoGetopt'],
181 is => 'rw',
182 isa => 'Data::Pairs',
183 );
184  
185 =head3 global_attr
186  
187 Attributes defined in the global section of the yaml file
188  
189 =cut
190  
191 has 'global_attr' => (
192 traits => ['NoGetopt'],
193 is => 'rw',
194 isa => 'Data::Pairs',
195 lazy => 1,
196 6 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
197 6 my $self = shift;
198  
199 6 my $n = Data::Pairs->new(
200 [ { resample => $self->resample },
201 { wait => $self->wait },
202 { auto_input => $self->auto_input },
203 { coerce_paths => $self->coerce_paths },
204 { auto_name => $self->auto_name },
205 { indir => $self->indir },
206 { outdir => $self->outdir },
207 { min => $self->min },
208 { override_process => $self->override_process },
209 { rule_based => $self->rule_based },
210 { verbose => $self->verbose },
211 { create_outdir => $self->create_outdir },
212 ]
213 );
214 6 return $n;
215 }
216 2 );
217  
218 =head3 local_attr
219  
220 Attributes defined in the rules->rulename->local section of the yaml file
221  
222 =cut
223  
224 2 has 'local_attr' => (
225 traits => ['NoGetopt'],
226 is => 'rw',
227 isa => 'Data::Pairs',
228 );
229  
230 =head3 local_rule
231  
232 =cut
233  
234 2 has 'local_rule' => (
235 traits => ['NoGetopt'],
236 is => 'rw',
237 isa => 'HashRef'
238 );
239  
240 =head3 process
241  
242 Our bash string
243  
244 bowtie2 -p 12 -I {$sample}.fastq -O {$sample}.bam
245  
246 =cut
247  
248 2 has 'process' => (
249 traits => ['NoGetopt'],
250 is => 'rw',
251 isa => 'Str',
252 );
253  
254 =head3 key
255  
256 Name of the rule
257  
258 =cut
259  
260 2 has 'key' => (
261 traits => ['NoGetopt'],
262 is => 'rw',
263 isa => 'Str',
264 );
265  
266 =head3 pkey
267  
268 Name of the previous rule
269  
270 =cut
271  
272 2 has 'pkey' => (
273 traits => ['NoGetopt'],
274 is => 'rw',
275 isa => 'Str|Undef',
276 predicate => 'has_pkey'
277 );
278  
279 =head2 Subroutines
280  
281 Subroutines can also be overriden and/or extended in the usual Moose fashion.
282  
283 =head3 run
284  
285 Starting point.
286  
287 =cut
288  
289 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
290 0 my ($self) = shift;
291  
292 0 print "#!/bin/bash\n\n";
293  
294 0 $self->print_opts;
295  
296 0 $self->init_things;
297  
298 0 $self->write_workflow_meta('start');
299  
300 0 $self->write_pipeline;
301  
302 0 $self->write_workflow_meta('end');
303 }
304  
305 =head3 init_things
306  
307 Load the workflow, additional classes, and plugins
308  
309 Initialize the global_attr, make the global outdir, and find samples
310  
311 =cut
312  
313 6 ▶sub init_things {
Subroutine init_things: called CC=1 SCAR=0.0
Pod documented
314 6 my $self = shift;
315  
316 6 $self->key('global');
317  
318 6 $self->workflow_load;
319 6 $self->class_load;
320 6 $self->plugin_load;
321  
322 #Darn you data pairs and your shallow copies!
323 6 $self->init_global_attr;
324  
325 6 $self->make_outdir;
326 6 $self->get_samples;
327  
328 6 $self->save_env;
329 }
330  
331 =head2 workflow_load
332  
333 use Config::Any to load configuration files - yaml, json, etc
334  
335 =cut
336  
337 6 ▶sub workflow_load {
Subroutine workflow_load: called CC=2 SCAR=6.9
Pod documented
338 6 my $self = shift;
339  
340 6 my $cfg = Config::Any->load_files(
341 { files => [ $self->workflow ], use_ext => 1 } );
342  
343 6 for (@$cfg) {
344 6 my ( $filename, $config ) = %$_;
345 6 $self->yaml($config);
346 }
347 }
348  
349 =head3 plugin_load
350  
351 Load plugins defined in yaml or on command line with --plugins with MooseX::Object::Pluggable
352  
353 =cut
354  
355 6 ▶sub plugin_load {
Subroutine plugin_load: called CC=4 SCAR=16.4
Pod documented
356 6 my ($self) = shift;
357  
358 6 my $plugins = [];
359 6 ▶ if ( $self->yaml->{plugins} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->yaml->{'plugins'}) { } 0 6 6
elsif ($self->plugins) { } 6 0 6
360 0 $plugins = $self->yaml->{plugins};
361 }
362 elsif ( $self->plugins ) {
363 6 $plugins = $self->plugins;
364 }
365 else {
366 0 return;
367 }
368  
369 6 foreach my $m (@$plugins) {
370 0 $self->load_plugin($m);
371 }
372 }
373  
374 =head3 class_load
375  
376 Load classes defined in yaml with Class::Load
377  
378 =cut
379  
380 6 ▶sub class_load {
Subroutine class_load: called CC=3 SCAR=15.4
Pod documented
381 6 my ($self) = shift;
382  
383 6 ▶ return unless $self->yaml->{use};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->yaml->{"use"} 6 0 6
384  
385 0 my $modules = $self->yaml->{use};
386  
387 0 foreach my $m (@$modules) {
388 0 load_class($m);
389 }
390 }
391  
392 =head3 make_template
393  
394 Make the template for interpolating strings
395  
396 =cut
397  
398 698 ▶sub make_template {
Subroutine make_template: called CC=1 SCAR=0.0
Pod documented
399 698 my ( $self, $input ) = @_;
400  
401 698 my $template = Text::Template->new(
402 TYPE => 'STRING',
403 SOURCE => "$E{$input}",
404 );
405  
406 #SOURCE => "$input",
407 698 return $template;
408 }
409  
410 =head2 init_global_attr
411  
412 Add our global key from config file to the global_attr, and then to attr
413  
414 Deprecated: set_global_yaml
415  
416 =cut
417  
418 6 ▶sub init_global_attr {
Subroutine init_global_attr: called CC=4 SCAR=13.9
Pod documented
419 6 my $self = shift;
420  
421 6 ▶ return unless exists $self->yaml->{global};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->yaml->{"global"} 0 6 6
422  
423 6 my $aref = $self->yaml->{global};
424 6 for my $a (@$aref) {
425 24 ▶ while ( my ( $key, $value ) = each( %{$a} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$a;}) 24 24 48
426 24 $self->global_attr->set( $key => $value );
427 }
428 }
429  
430 6 $self->attr( dclone( $self->global_attr ) );
431 6 $self->create_attr;
432 }
433  
434 =head3 create_attr
435  
436 Add attributes to $self-> namespace
437  
438 =cut
439  
440 15 ▶sub create_attr {
Subroutine create_attr: called CC=7 SCAR=19.6
Pod documented
441 15 my ($self) = shift;
442  
443 15 my $meta = __PACKAGE__->meta;
444  
445 15 $meta->make_mutable;
446  
447 15 my %seen = ();
448  
449 15 for my $attr ( $meta->get_all_attributes ) {
450 758 $seen{ $attr->name } = 1;
451 }
452  
453 # Data Pairs is so much prettier
454 15 my @keys = $self->attr->get_keys();
455  
456 15 foreach my $k (@keys) {
457 220 my ($v) = $self->attr->get_values($k);
458  
459 220 ▶ if ( !exists $seen{$k} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $seen{$k}) 3 217 220
460 3 ▶ if ( $k =~ m/_dir$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /_dir$/) { } 1 2 3
461 1 ▶ if ( $self->coerce_paths ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->coerce_paths) { } 1 0 1
462 1 $meta->add_attribute(
463 $k => (
464 is => 'rw',
465 isa => AbsPath,
466 coerce => 1,
467 predicate => "has_$k",
468 clearer => "clear_$k"
469 )
470 );
471 }
472 else {
473 0 $meta->add_attribute(
474 $k => (
475 is => 'rw',
476 isa => AbsPath,
477 coerce => 0,
478 predicate => "has_$k",
479 clearer => "clear_$k"
480 )
481 );
482 }
483 }
484 else {
485 2 $meta->add_attribute(
486 $k => (
487 is => 'rw',
488 predicate => "has_$k",
489 clearer => "clear_$k"
490 )
491 );
492 }
493 }
494 220 ▶ $self->$k($v) if defined $v;
Branch: 1 branch
BranchTrueFalseTotal
if defined $v 220 0 220
495 }
496  
497 15 $meta->make_immutable;
498 }
499  
500 =head3 eval_attr
501  
502 Evaluate the keys for variables using Text::Template
503 {$sample} -> SampleA
504 {$self->indir} -> data/raw (or the indir of the rule)
505  
506 If variables are themselves hashes/array refs, leave them alone
507  
508 =cut
509  
510 54 ▶sub eval_attr {
Subroutine eval_attr: called CC=8 SCAR=21.8
Pod documented
511 54 my $self = shift;
512 54 my $sample = shift;
513  
514 54 my @keys = $self->attr->get_keys();
515  
516 54 foreach my $k (@keys) {
517 815 ▶ next unless $k;
Branch: 1 branch
BranchTrueFalseTotal
unless $k 0 815 815
518  
519 815 my ($v) = $self->attr->get_values($k);
520 815 ▶ next unless $v;
Branch: 1 branch
BranchTrueFalseTotal
unless $v 162 653 815
521  
522 #If its an array or hash reference leave it alone
523 653 ▶ if ( ref($v) eq 'ARRAY' || ref($v) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq "ARRAY" or ref $v eq "HASH") 0 653 653
Condition33%1/3
ref $v eq "ARRAY" or ref $v eq "HASH"
l!l&&r!l&&!r
00653
MC/DC0%0/2
ref $v eq "ARRAY" or ref $v eq "HASH"
ref $v eq "ARRAY" ref $v eq "HASH"
Truth table33%1/3
A or B
A= ref $v eq "ARRAY"B= ref $v eq "HASH"
ABresult
1X1
011
000
524 0 $self->$k($v);
525 0 next;
526 }
527  
528 #Otherwise its a string
529 653 my $template = $self->make_template($v);
530 653 my $text;
531 653 ▶ if ($sample) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sample) { } 545 108 653
532 545 $text = $template->fill_in(
533 HASH => { self => \$self, sample => $sample } );
534 }
535 else {
536 108 $text = $template->fill_in( HASH => { self => \$self } );
537 }
538  
539 653 $self->$k($text);
540 }
541  
542 54 ▶ $self->make_outdir if $self->create_outdir;
Branch: 1 branch
BranchTrueFalseTotal
if $self->create_outdir 54 0 54
543 }
544  
545 =head2 clear_attr
546  
547 After each rule is processe clear the $self->attr
548  
549 =cut
550  
551 0 ▶sub clear_attr {
Subroutine clear_attr: not called CC=3 SCAR=24.8
Pod documented
552 0 my $self = shift;
553  
554 0 my @keys = $self->attr->get_keys();
555  
556 0 foreach my $k (@keys) {
557 0 my ($v) = $self->attr->get_values($k);
558 0 ▶ next unless $v;
Branch: 1 branch
BranchTrueFalseTotal
unless $v 0 0 0
559  
560 0 my $clear = "clear_$k";
561 0 $self->$clear;
562 }
563 }
564  
565 3 ▶sub write_pipeline {
Subroutine write_pipeline: called CC=5 SCAR=24.1
Pod undocumented
566 3 my ($self) = shift;
567  
568 #Min and Sample_Based Mode will break with --resample
569 3 ▶ if ( $self->min ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->min) { } 0 3 3
elsif ($self->sample_based) { } 0 3 3
elsif ($self->rule_based) { } 3 0 3
570 0 $self->write_min_files;
571 0 $self->process_rules;
572 }
573 elsif ( $self->sample_based ) {
574  
575 #Store the samples
576 0 my $sample_store = $self->samples;
577 0 foreach my $sample (@$sample_store) {
578 0 $self->samples( [$sample] );
579 0 $self->process_rules;
580 }
581 }
582 elsif ( $self->rule_based ) {
583 3 $self->process_rules;
584 }
585 else {
586 0 die print "Workflow must be rule based or sample based!\n";
587 }
588 }
589  
590 3 ▶sub process_rules {
Subroutine process_rules: called CC=6 SCAR=21.3
Pod undocumented
591 3 my $self = shift;
592  
593 3 my $process;
594 3 $process = $self->yaml->{rules};
595  
596 3 ▶ die print "Where are the rules?\n" unless $process;
Branch: 1 branch
BranchTrueFalseTotal
unless $process 0 3 3
597 3 ▶ die unless ref($process) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $process eq "ARRAY" 0 3 3
598  
599 3 foreach my $p ( @{$process} ) {
600 9 ▶ next unless $p;
Branch: 1 branch
BranchTrueFalseTotal
unless $p 0 9 9
601 9 ▶ if ( $self->number_rules ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->number_rules) 0 9 9
602 0 my @keys = keys %{$p};
603 0 my $result = sprintf( "%04d", $self->counter_rules );
604 0 my $newkey = $keys[0];
605 0 $newkey = $result . '-' . $newkey;
606 0 $p->{$newkey} = dclone( $p->{ $keys[0] } );
607 0 delete $p->{ $keys[0] };
608 }
609 9 $self->local_rule($p);
610 9 $self->dothings;
611 9 $self->inc_counter_rules;
612 }
613 }
614  
615 9 ▶sub dothings {
Subroutine dothings: called CC=3 SCAR=11.1
Pod undocumented
616 9 my ($self) = shift;
617  
618 9 $self->check_keys;
619  
620 9 $self->init_process_vars;
621  
622 9 ▶ return if $self->check_rules;
Branch: 1 branch
BranchTrueFalseTotal
if $self->check_rules 0 9 9
623  
624 9 $self->process( $self->local_rule->{ $self->key }->{process} );
625  
626 9 $self->write_rule_meta('before_meta');
627  
628 9 $self->write_process();
629  
630 9 $self->write_rule_meta('after_meta');
631  
632 9 $self->clear_process_attr;
633  
634 9 ▶ $self->indir( $self->outdir . "/" . $self->pkey ) if $self->auto_name;
Branch: 1 branch
BranchTrueFalseTotal
if $self->auto_name 9 0 9
635 }
636  
637 =head2 check_keys
638  
639 There should be one key and one key only!
640  
641 =cut
642  
643 9 ▶sub check_keys {
Subroutine check_keys: called CC=4 SCAR=16.1
Pod documented
644 9 my $self = shift;
645 9 my @keys = keys %{ $self->local_rule };
646  
647 9 ▶ if ( $#keys > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($#keys > 0) { } 0 9 9
elsif (not @keys) { } 0 9 9
648 0 die print
649 "We have a problem! There should only be one key. Please see the documentation!\n";
650 }
651 elsif ( !@keys ) {
652 0 die print "There are no rules. Please see the documenation.\n";
653 }
654 else {
655 9 $self->key( $keys[0] );
656 }
657  
658 9 ▶ if ( !exists $self->local_rule->{ $self->key }->{process} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->local_rule->{$self->key}{"process"}) 0 9 9
659 0 die print "There is no process key! Dying...\n";
660 }
661 }
662  
663 =head2 clear_process_attr
664  
665 Clear the process attr
666  
667 Deprecated: clear_process_vars
668  
669 =cut
670  
671 9 ▶sub clear_process_attr {
Subroutine clear_process_attr: called CC=1 SCAR=0.0
Pod documented
672 9 my $self = shift;
673  
674 9 $self->attr->clear;
675 9 $self->local_attr->clear;
676  
677 9 $self->add_attr('global_attr');
678  
679 9 $self->eval_attr;
680 }
681  
682 =head2 init_process_vars
683  
684 Initialize the process vars
685  
686 =cut
687  
688 9 ▶sub init_process_vars {
Subroutine init_process_vars: called CC=12 SCAR=26.9
Pod documented
689 9 my $self = shift;
690  
691 9 ▶ if ( $self->auto_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->auto_name) 9 0 9
692 9 $self->outdir( $self->outdir . "/" . $self->key );
693 9 ▶ $self->make_outdir() unless $self->by_sample_outdir;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->by_sample_outdir 3 6 9
694 }
695  
696 9 ▶ if ( exists $self->local_rule->{ $self->key }->{override_process}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->local_rule->{$self->key}{'override_process'} and $self->local_rule->{$self->key}{'override_process'} == 1) { } 0 9 9
Condition33%1/3
exists $self->local_rule->{$self->key}{"override_process"} and $self->local_rule->{$self->key}{"override_process"} == 1
!ll&&!rl&&r
900
MC/DC0%0/2
exists $self->local_rule->{$self->key}{"override_process"} and $self->local_rule->{$self->key}{"override_process"} == 1
exists $self->local_rule->{$self->key}{"override_process"} $self->local_rule->{$self->key}{"override_process"} == 1
Truth table33%1/3
A and B
A= exists $self->local_rule->{$self->key}{"override_process"}B= $self->local_rule->{$self->key}{"override_process"} == 1
ABresult
0X0
100
111
697 && $self->local_rule->{ $self->key }->{override_process} == 1 )
698 {
699 0 $self->override_process(1);
700 }
701 else {
702 9 $self->override_process(0);
703 }
704  
705 9 $self->local_attr( Data::Pairs->new( [] ) );
706 9 ▶ if ( exists $self->local_rule->{ $self->key }->{local} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->local_rule->{$self->key}{"local"}) 2 7 9
707 $self->local_attr(
708 Data::Pairs->new(
709 dclone( $self->local_rule->{ $self->key }->{local} )
710 2 )
711 );
712 }
713  
714 #Make sure these aren't reset to global
715 ##YAY FOR TESTS
716 9 ▶ $self->local_attr->set( 'outdir' => $self->outdir )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->local_attr->exists("outdir") 9 0 9
717 unless $self->local_attr->exists('outdir');
718 9 ▶ $self->local_attr->set( 'indir' => $self->indir )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->local_attr->exists("indir") 9 0 9
719 unless $self->local_attr->exists('indir');
720  
721 9 $self->add_attr('local_attr');
722 9 $self->create_attr;
723 9 ▶ $self->get_samples if $self->resample;
Branch: 1 branch
BranchTrueFalseTotal
if $self->resample 0 9 9
724  
725 #Why did I have this in write rule meta?
726 9 ▶ if ( $self->auto_input ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->auto_input) 9 0 9
727 9 ▶ $self->local_attr->set( 'OUTPUT' => $self->OUTPUT )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_OUTPUT 0 9 9
728 if $self->has_OUTPUT;
729 9 ▶ $self->local_attr->set(
Branch: 1 branch
BranchTrueFalseTotal
if $self->global_attr->exists("INPUT") 0 9 9
730 'INPUT' => $self->global_attr->get_values('INPUT') )
731 if $self->global_attr->exists('INPUT');
732 }
733 }
734  
735 =head2 add_attr
736  
737 Add the local attr onto the global attr
738  
739 =cut
740  
741 18 ▶sub add_attr {
Subroutine add_attr: called CC=3 SCAR=11.0
Pod documented
742 18 my $self = shift;
743 18 my $type = shift;
744  
745 18 my @keys = $self->$type->get_keys();
746  
747 18 foreach my $key (@keys) {
748 156 ▶ next unless $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 0 156 156
749  
750 156 my ($v) = $self->$type->get_values($key);
751 156 $self->attr->set( $key => $v );
752 }
753 }
754  
755 9 ▶sub write_process {
Subroutine write_process: called CC=5 SCAR=16.6
Pod undocumented
756 9 my ($self) = @_;
757  
758 9 $self->save_env;
759  
760 9 ▶ if ( !$self->override_process ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->override_process) { } 9 0 9
761 9 foreach my $sample ( @{ $self->samples } ) {
762 45 $self->sample($sample);
763 45 ▶ $self->process_by_sample_outdir($sample)
Branch: 1 branch
BranchTrueFalseTotal
if $self->by_sample_outdir 30 15 45
764 if $self->by_sample_outdir;
765 45 $self->eval_attr($sample);
766 45 my $data = { self => \$self, sample => $sample };
767 45 $self->process_template($data);
768 45 $self->reset_special_vars;
769 }
770 }
771 else {
772 0 $self->eval_attr;
773 0 my $data = { self => \$self };
774 0 $self->process_template($data);
775 }
776  
777 9 ▶ print "\nwait\n" if $self->wait;
Branch: 1 branch
BranchTrueFalseTotal
if $self->wait 9 0 9
778  
779 9 $self->OUTPUT_to_INPUT;
780  
781 9 $self->pkey( $self->key );
782 }
783  
784 45 ▶sub process_template {
Subroutine process_template: called CC=1 SCAR=0.0
Pod undocumented
785 45 my ( $self, $data ) = @_;
786  
787 45 my $template = $self->make_template( $self->process );
788 45 $template->fill_in( HASH => $data, OUTPUT => \*STDOUT );
789  
790 45 $DB::single = 2;
791 45 $DB::single = 2;
792  
793 45 print "\n\n";
794 }
795  
796 2 __PACKAGE__->meta->make_immutable;
797  
798 2 1;
799  
800 __END__
« lib/BioX/Workflow/StructureOutput.pm ↑ Summary lib/BioX/Workflow/WriteMeta.pm »