File Coverage

blib/lib/BioX/Workflow/WriteMeta.pm
Criterion Covered Total %
statement 42 42 100.0
branch 13 18 72.2
condition n/a
subroutine 3 3 100.0
pod 1 2 50.0
total 59 65 90.7


line stmt bran cond sub pod time code
1             package BioX::Workflow::WriteMeta;
2              
3 2     2   854 use Moose::Role;
  2         3  
  2         12  
4              
5             =head1 BioX::Workflow::WriteMeta
6              
7             Debug information containing metadata per rule.
8              
9             Useful for tracking the evolution of an analysis
10              
11             =head2 Variables
12              
13             =head3 verbose
14              
15             Output some more things
16              
17             =cut
18              
19             has 'verbose' => (
20             is => 'rw',
21             isa => 'Bool',
22             default => 1,
23             clearer => 'clear_verbose',
24             predicate => 'has_verbose',
25             );
26              
27             =head3 wait
28              
29             Print "wait" at the end of each rule
30              
31             This is useful for running with the HPC::Runner libraries.
32              
33             =cut
34              
35             has 'wait' => (
36             is => 'rw',
37             isa => 'Bool',
38             default => 1,
39             documentation =>
40             q(Print 'wait' at the end of each rule. If you are running as a plain bash script you probably don't need this.),
41             clearer => 'clear_wait',
42             predicate => 'has_wait',
43             );
44              
45             =head2 Subroutines
46              
47             =cut
48              
49             sub write_workflow_meta {
50 6     6 0 46 my $self = shift;
51 6         14 my $type = shift;
52              
53 6 50       149 return unless $self->verbose;
54              
55 6 100       39 if ( $type eq "start" ) {
    50          
56 3         27 print "$self->{comment_char}\n";
57 3         20 print "$self->{comment_char} Starting Workflow\n";
58 3         16 print "$self->{comment_char}\n";
59 3         18 print "$self->{comment_char}\n";
60 3         18 print "$self->{comment_char} Global Variables:\n";
61              
62 3         79 my @keys = $self->global_attr->get_keys();
63              
64 3         118 foreach my $k (@keys) {
65 45 50       75 next unless $k;
66 45         1045 my ($v) = $self->global_attr->get_values($k);
67 45         2326 print "$self->{comment_char}\t$k: " . $v . "\n";
68             }
69 3         23 print "$self->{comment_char}\n";
70             }
71             elsif ( $type eq "end" ) {
72 3         115 print "$self->{comment_char}\n";
73 3         19 print "$self->{comment_char} Ending Workflow\n";
74 3         38 print "$self->{comment_char}\n";
75             }
76             }
77              
78             =head2 write_rule_meta
79              
80             =cut
81              
82             sub write_rule_meta {
83 18     18 1 33 my ( $self, $meta ) = @_;
84              
85 18         452 print "\n$self->{comment_char}\n";
86              
87 18 100       59 if ( $meta eq "after_meta" ) {
88 9         59 print "$self->{comment_char} Ending $self->{key}\n";
89             }
90              
91 18         104 print "$self->{comment_char}\n\n";
92              
93 18 100       74 return unless $meta eq "before_meta";
94 9         57 print "$self->{comment_char} Starting $self->{key}\n";
95 9         47 print "$self->{comment_char}\n\n";
96              
97 9 50       260 return unless $self->verbose;
98              
99 9         75 print "\n\n$self->{comment_char}\n";
100 9         51 print "$self->{comment_char} Variables \n";
101 9         270 print "$self->{comment_char} Indir: " . $self->indir . "\n";
102 9         323 print "$self->{comment_char} Outdir: " . $self->outdir . "\n";
103              
104 9 100       273 if ( exists $self->local_rule->{ $self->key }->{local} ) {
105              
106 2         17 print "$self->{comment_char} Local Variables:\n";
107              
108 2         51 my @keys = $self->local_attr->get_keys();
109              
110 2         45 foreach my $k (@keys) {
111 7         172 my ($v) = $self->local_attr->get_values($k);
112 7         160 print "$self->{comment_char}\t$k: " . $v . "\n";
113             }
114             }
115              
116 9 50       221 $self->write_sample_meta if $self->resample;
117              
118 9         79 print "$self->{comment_char}\n\n";
119             }
120              
121             1;