| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package BioX::Workflow::SpecialVars; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1098
|
use Cwd qw(abs_path getcwd); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
121
|
|
|
4
|
2
|
|
|
2
|
|
9
|
use File::Path qw(make_path remove_tree); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
83
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use MooseX::Types::Path::Tiny qw/Path Paths AbsPath/; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
20
|
|
|
7
|
2
|
|
|
2
|
|
4197
|
use Moose::Role; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 BioX::Workflow::SpecialVars |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Variables that BioX::Workflow treats as special. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Directories - indir, outdir are looped. The indir of one rule is the outdir of the previous rule |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Files - INPUT, OUTPUT are also looped. The INPUT of one rule is the OUTPUT of the previous. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
INPUT and OUTPUT are used by the L<BioX::Workflow::Plugin::Drake> and L<BioX::Workflow::Plugin::FileEixsts> plugins. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 Variables |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head3 auto_name |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Auto_name - Create outdirectory based on rulename |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
global: |
|
26
|
|
|
|
|
|
|
- outdir: /home/user/workflow/processed |
|
27
|
|
|
|
|
|
|
rule: |
|
28
|
|
|
|
|
|
|
normalize: |
|
29
|
|
|
|
|
|
|
process: |
|
30
|
|
|
|
|
|
|
dostuff {$self->indir}/{$sample}.in >> {$self->outdir}/$sample.out |
|
31
|
|
|
|
|
|
|
analyse: |
|
32
|
|
|
|
|
|
|
process: |
|
33
|
|
|
|
|
|
|
dostuff {$self->indir}/{$sample}.in >> {$self->outdir}/$sample.out |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Would create your directory structure /home/user/workflow/processed/normalize (if it doesn't exist) |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
In addition each indir is the outdir of the previous rule |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
The indir of analyse (though not specified) is normalize. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'auto_name' => ( |
|
44
|
|
|
|
|
|
|
traits => ['Bool'], |
|
45
|
|
|
|
|
|
|
is => 'rw', |
|
46
|
|
|
|
|
|
|
isa => 'Bool', |
|
47
|
|
|
|
|
|
|
default => 1, |
|
48
|
|
|
|
|
|
|
predicate => 'has_auto_name', |
|
49
|
|
|
|
|
|
|
handles => { |
|
50
|
|
|
|
|
|
|
enforce_struct => 'set', |
|
51
|
|
|
|
|
|
|
clear_enforce_struct => 'unset', |
|
52
|
|
|
|
|
|
|
clear_auto_name => 'unset', |
|
53
|
|
|
|
|
|
|
}, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 auto_input |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This is similar to the auto_name function in the BioX::Workflow. |
|
59
|
|
|
|
|
|
|
Instead this says each INPUT should be the previous OUTPUT. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has 'auto_input' => ( |
|
64
|
|
|
|
|
|
|
is => 'rw', |
|
65
|
|
|
|
|
|
|
isa => 'Bool', |
|
66
|
|
|
|
|
|
|
default => 1, |
|
67
|
|
|
|
|
|
|
clearer => 'clear_auto_input', |
|
68
|
|
|
|
|
|
|
predicate => 'has_auto_input', |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head3 create_outdir |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has 'create_outdir' => ( |
|
76
|
|
|
|
|
|
|
is => 'rw', |
|
77
|
|
|
|
|
|
|
isa => 'Bool', |
|
78
|
|
|
|
|
|
|
predicate => 'has_create_outdir', |
|
79
|
|
|
|
|
|
|
clearer => 'clear_create_outdir', |
|
80
|
|
|
|
|
|
|
documentation => |
|
81
|
|
|
|
|
|
|
q(Create the outdir. You may want to turn this off if doing a rule that doesn't write anything, such as checking if files exist), |
|
82
|
|
|
|
|
|
|
default => 1, |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head3 indir outdir |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The initial indir is where samples are found |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
All output is written relative to the outdir |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has 'indir' => ( |
|
94
|
|
|
|
|
|
|
is => 'rw', |
|
95
|
|
|
|
|
|
|
isa => AbsPath, |
|
96
|
|
|
|
|
|
|
coerce => 1, |
|
97
|
|
|
|
|
|
|
default => sub { getcwd(); }, |
|
98
|
|
|
|
|
|
|
predicate => 'has_indir', |
|
99
|
|
|
|
|
|
|
clearer => 'clear_indir', |
|
100
|
|
|
|
|
|
|
documentation => q(Directory to look for samples), |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
has 'outdir' => ( |
|
104
|
|
|
|
|
|
|
is => 'rw', |
|
105
|
|
|
|
|
|
|
isa => AbsPath, |
|
106
|
|
|
|
|
|
|
coerce => 1, |
|
107
|
|
|
|
|
|
|
default => sub { getcwd(); }, |
|
108
|
|
|
|
|
|
|
predicate => 'has_outdir', |
|
109
|
|
|
|
|
|
|
clearer => 'clear_outdir', |
|
110
|
|
|
|
|
|
|
documentation => q(Output directories for rules and processes), |
|
111
|
|
|
|
|
|
|
); |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head3 INPUT OUTPUT |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Special variables that can have input/output |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
These variables are also used in L<BioX::Workflow::Plugin::Drake> |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
has 'OUTPUT' => ( |
|
123
|
|
|
|
|
|
|
is => 'rw', |
|
124
|
|
|
|
|
|
|
isa => 'Str|Undef', |
|
125
|
|
|
|
|
|
|
predicate => 'has_OUTPUT', |
|
126
|
|
|
|
|
|
|
clearer => 'clear_OUTPUT', |
|
127
|
|
|
|
|
|
|
documentation => |
|
128
|
|
|
|
|
|
|
q(At the end of each process the OUTPUT becomes |
|
129
|
|
|
|
|
|
|
the INPUT.) |
|
130
|
|
|
|
|
|
|
); |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
has 'INPUT' => ( |
|
133
|
|
|
|
|
|
|
is => 'rw', |
|
134
|
|
|
|
|
|
|
isa => 'Str|Undef', |
|
135
|
|
|
|
|
|
|
predicate => 'has_INPUT', |
|
136
|
|
|
|
|
|
|
clearer => 'clear_INPUT', |
|
137
|
|
|
|
|
|
|
documentation => q(See $OUTPUT) |
|
138
|
|
|
|
|
|
|
); |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 Subroutines |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head3 OUTPUT_to_INPUT |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
If we are using auto_input chain INPUT/OUTPUT |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub OUTPUT_to_INPUT { |
|
149
|
9
|
|
|
9
|
1
|
15
|
my $self = shift; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
#Change the output to input |
|
152
|
9
|
50
|
33
|
|
|
220
|
if ( $self->auto_input && $self->local_attr->exists('OUTPUT') ) { |
|
153
|
0
|
|
|
|
|
0
|
my ( $tmp, $indir, $outdir ) = ( |
|
154
|
|
|
|
|
|
|
$self->local_attr->get_values('OUTPUT'), |
|
155
|
|
|
|
|
|
|
$self->indir, $self->outdir |
|
156
|
|
|
|
|
|
|
); |
|
157
|
0
|
|
|
|
|
0
|
$tmp =~ s/{\$self->outdir}/{\$self->indir}/g; |
|
158
|
0
|
|
|
|
|
0
|
$self->INPUT($tmp); |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#This is not the best way of doing this.... |
|
161
|
0
|
|
|
|
|
0
|
$self->global_attr->set( INPUT => $self->INPUT ); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
else { |
|
164
|
9
|
|
|
|
|
390
|
$self->clear_OUTPUT(); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head3 make_outdir |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Set initial indir and outdir |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub make_outdir { |
|
175
|
93
|
|
|
93
|
1
|
110
|
my ($self) = @_; |
|
176
|
|
|
|
|
|
|
|
|
177
|
93
|
50
|
|
|
|
2188
|
return unless $self->create_outdir; |
|
178
|
|
|
|
|
|
|
|
|
179
|
93
|
50
|
|
|
|
324
|
if ( $self->{outdir} =~ m/\{\$/ ) { |
|
180
|
0
|
|
|
|
|
0
|
return; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
93
|
100
|
|
|
|
2422
|
make_path( $self->outdir ) if !-d $self->outdir; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 reset_special_vars |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
For each sample the process is interpolated |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
{$sample}.csv -> Sample_A.csv |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
We need to set it back to the original for the following rule |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub reset_special_vars { |
|
196
|
45
|
|
|
45
|
1
|
49
|
my $self = shift; |
|
197
|
|
|
|
|
|
|
|
|
198
|
45
|
50
|
|
|
|
1245
|
$self->INPUT( $self->local_attr->get_values('INPUT') ) |
|
199
|
|
|
|
|
|
|
if $self->local_attr->exists('INPUT'); |
|
200
|
45
|
50
|
|
|
|
1706
|
$self->OUTPUT( $self->local_attr->get_values('OUTPUT') ) |
|
201
|
|
|
|
|
|
|
if $self->local_attr->exists('OUTPUT'); |
|
202
|
|
|
|
|
|
|
|
|
203
|
45
|
50
|
|
|
|
1572
|
$self->indir( $self->local_attr->get_values('indir') ) |
|
204
|
|
|
|
|
|
|
if $self->local_attr->exists('indir'); |
|
205
|
45
|
50
|
|
|
|
1022
|
$self->outdir( $self->local_attr->get_values('outdir') ) |
|
206
|
|
|
|
|
|
|
if $self->local_attr->exists('outdir'); |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
1; |