line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::Workflow::Command::run::Rules::Directives::Types::Path; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
418
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
4154
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
61
|
use MooseX::Types::Path::Tiny qw/Path Paths AbsPath AbsFile/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
7
|
1
|
|
|
1
|
|
2851
|
use Path::Tiny; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
8
|
1
|
|
|
1
|
|
6
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
9
|
1
|
|
|
1
|
|
7
|
use Data::Walk; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
447
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head2 File Options |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head3 indir outdir |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
The initial indir is where samples are found |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
All output is written relative to the outdir |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'indir' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => Path, |
24
|
|
|
|
|
|
|
coerce => 1, |
25
|
|
|
|
|
|
|
required => 0, |
26
|
|
|
|
|
|
|
default => sub { cwd(); }, |
27
|
|
|
|
|
|
|
predicate => 'has_indir', |
28
|
|
|
|
|
|
|
clearer => 'clear_indir', |
29
|
|
|
|
|
|
|
documentation => q(Directory to look for samples), |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'outdir' => ( |
33
|
|
|
|
|
|
|
is => 'rw', |
34
|
|
|
|
|
|
|
isa => Path, |
35
|
|
|
|
|
|
|
coerce => 1, |
36
|
|
|
|
|
|
|
required => 0, |
37
|
|
|
|
|
|
|
default => sub { cwd(); }, |
38
|
|
|
|
|
|
|
predicate => 'has_outdir', |
39
|
|
|
|
|
|
|
clearer => 'clear_outdir', |
40
|
|
|
|
|
|
|
documentation => q(Output directories for rules and processes), |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'cwd' => ( |
44
|
|
|
|
|
|
|
is => 'rw', |
45
|
|
|
|
|
|
|
isa => Path, |
46
|
|
|
|
|
|
|
coerce => 1, |
47
|
|
|
|
|
|
|
required => 0, |
48
|
|
|
|
|
|
|
default => sub { cwd(); }, |
49
|
|
|
|
|
|
|
predicate => 'has_cwd', |
50
|
|
|
|
|
|
|
clearer => 'clear_cwd', |
51
|
|
|
|
|
|
|
documentation => q(Placeholder for the cwd.), |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head3 INPUT OUTPUT |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Special variables that can have input/output |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has 'OUTPUT' => ( |
61
|
|
|
|
|
|
|
is => 'rw', |
62
|
|
|
|
|
|
|
required => 0, |
63
|
|
|
|
|
|
|
predicate => 'has_OUTPUT', |
64
|
|
|
|
|
|
|
documentation => q(At the end of each process the OUTPUT becomes |
65
|
|
|
|
|
|
|
the INPUT.) |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has 'INPUT' => ( |
69
|
|
|
|
|
|
|
is => 'rw', |
70
|
|
|
|
|
|
|
required => 0, |
71
|
|
|
|
|
|
|
predicate => 'has_INPUT', |
72
|
|
|
|
|
|
|
documentation => q(See OUTPUT) |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head3 coerce_abs_dir |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Coerce dirs to absolute paths (True) |
78
|
|
|
|
|
|
|
Keep paths as relative directories (False) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has 'coerce_abs_dir' => ( |
83
|
|
|
|
|
|
|
is => 'rw', |
84
|
|
|
|
|
|
|
isa => 'Bool', |
85
|
|
|
|
|
|
|
default => 1, |
86
|
|
|
|
|
|
|
documentation => q{Coerce '*_dir' to absolute directories}, |
87
|
|
|
|
|
|
|
predicate => 'has_coerce_abs_dir', |
88
|
|
|
|
|
|
|
clearer => 'clear_coerce_abs_dir', |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head3 create_outdir |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
has 'create_outdir' => ( |
96
|
|
|
|
|
|
|
is => 'rw', |
97
|
|
|
|
|
|
|
isa => 'Bool', |
98
|
|
|
|
|
|
|
predicate => 'has_create_outdir', |
99
|
|
|
|
|
|
|
clearer => 'clear_create_outdir', |
100
|
|
|
|
|
|
|
documentation => |
101
|
|
|
|
|
|
|
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), |
102
|
|
|
|
|
|
|
default => 1, |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
after 'BUILD' => sub { |
106
|
|
|
|
|
|
|
my $self = shift; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$self->set_register_process_directives( |
109
|
|
|
|
|
|
|
'path', |
110
|
|
|
|
|
|
|
{ |
111
|
|
|
|
|
|
|
builder => 'process_directive_path', |
112
|
|
|
|
|
|
|
lookup => |
113
|
|
|
|
|
|
|
[ '^indir$', '^outdir$', '^INPUT$', '^OUTPUT$', '.*_dir$' ] |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 Type Specific Process Directives |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Sometimes you want a type specific way of processing directives. This will generally require two different methods |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
process_directive* |
123
|
|
|
|
|
|
|
walk_directives* |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
process_directive gives some official parameters |
126
|
|
|
|
|
|
|
walk_directives walks the data structure |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Take a look at the methods in 'BioX::Workflow::Command::run::Rules::Directives::Walk' |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Your functions will probably be very similar |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub process_directive_path { |
135
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
136
|
0
|
|
|
|
|
|
my $k = shift; |
137
|
0
|
|
|
|
|
|
my $v = shift; |
138
|
|
|
|
|
|
|
|
139
|
0
|
0
|
|
|
|
|
if ( ref($v) ) { |
140
|
|
|
|
|
|
|
walk { |
141
|
0
|
|
|
0
|
|
|
wanted => sub { $self->walk_directives_path( @_ ) } |
142
|
|
|
|
|
|
|
}, |
143
|
0
|
|
|
|
|
|
$self->$k; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
else { |
146
|
0
|
|
|
|
|
|
my $text = ''; |
147
|
0
|
0
|
|
|
|
|
$text = $self->interpol_directive($v) if $v; |
148
|
0
|
0
|
|
|
|
|
if ( $text ne '' ) { |
149
|
0
|
|
|
|
|
|
$text = $self->return_path($text); |
150
|
|
|
|
|
|
|
} |
151
|
0
|
|
|
|
|
|
$self->$k($text); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head3 walk_directives_paths |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Invoke with |
158
|
|
|
|
|
|
|
walk { wanted => sub { $self->directives(@_) } }, $self->other_thing; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Acts funny with $self->some_other_thing is not a reference |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub walk_directives_path { |
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
166
|
0
|
|
|
|
|
|
my $ref = shift; |
167
|
|
|
|
|
|
|
|
168
|
0
|
0
|
|
|
|
|
return if ref($ref); |
169
|
0
|
0
|
|
|
|
|
return unless $ref; |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
my $text = ''; |
172
|
0
|
0
|
|
|
|
|
$text = $self->interpol_directive($ref) if $ref; |
173
|
0
|
|
|
|
|
|
$text = $self->return_path($text); |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
$self->update_directive($text); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub return_path { |
179
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
180
|
0
|
|
|
|
|
|
my $text = shift; |
181
|
|
|
|
|
|
|
|
182
|
0
|
0
|
|
|
|
|
if ( $self->coerce_abs_dir ) { |
183
|
0
|
|
|
|
|
|
$text = path($text)->absolute; |
184
|
0
|
|
|
|
|
|
$text = path($text); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
else { |
187
|
0
|
|
|
|
|
|
$text = path($text); |
188
|
|
|
|
|
|
|
} |
189
|
0
|
|
|
|
|
|
return $text; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |