line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::Workflow::Command::run::Rules::Directives::Types::List; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
552
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
4511
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head2 Iterables |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Lists to iterate by |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Chunks and chroms are included by default |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 chunks |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Special iterable. Iterate through a list of numbers |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'chunks' => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'HashRef', |
23
|
|
|
|
|
|
|
default => sub { {} } |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'chunk' => ( is => 'rw' ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'use_chunks' => ( |
29
|
|
|
|
|
|
|
is => 'rw', |
30
|
|
|
|
|
|
|
traits => ['Bool'], |
31
|
|
|
|
|
|
|
isa => 'Bool', |
32
|
|
|
|
|
|
|
default => 0, |
33
|
|
|
|
|
|
|
handles => { |
34
|
|
|
|
|
|
|
'no_chunks' => 'not', |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has 'chunk_list' => ( |
39
|
|
|
|
|
|
|
traits => ['Array'], |
40
|
|
|
|
|
|
|
is => 'rw', |
41
|
|
|
|
|
|
|
isa => 'ArrayRef', |
42
|
|
|
|
|
|
|
lazy => 1, |
43
|
|
|
|
|
|
|
default => sub { |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
if ( !exists $self->chunks->{start} || !exists $self->chunks->{end} ) { |
46
|
|
|
|
|
|
|
return []; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
my @array = (); |
49
|
|
|
|
|
|
|
for ( |
50
|
|
|
|
|
|
|
my $x = $self->chunks->{start} ; |
51
|
|
|
|
|
|
|
$x <= $self->chunks->{end} ; |
52
|
|
|
|
|
|
|
$x = $x + $self->chunks->{step} |
53
|
|
|
|
|
|
|
) |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
push( @array, $x ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
return \@array; |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
handles => { |
60
|
|
|
|
|
|
|
'all_chunk_lists' => 'elements', |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 chroms_list |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Iterate by chroms. Default is human chromosomes. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
To change create a first rule with the template |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has 'chroms_list' => ( |
73
|
|
|
|
|
|
|
traits => ['Array'], |
74
|
|
|
|
|
|
|
is => 'rw', |
75
|
|
|
|
|
|
|
isa => 'ArrayRef', |
76
|
|
|
|
|
|
|
default => sub { |
77
|
|
|
|
|
|
|
return [ 1 .. 22, 'X', 'Y', 'MT' ]; |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
handles => { |
80
|
|
|
|
|
|
|
'all_chrom_lists' => 'elements', |
81
|
|
|
|
|
|
|
}, |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
has 'chrom' => ( is => 'rw' ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
has 'use_chroms' => ( |
87
|
|
|
|
|
|
|
is => 'rw', |
88
|
|
|
|
|
|
|
traits => ['Bool'], |
89
|
|
|
|
|
|
|
isa => 'Bool', |
90
|
|
|
|
|
|
|
default => 0, |
91
|
|
|
|
|
|
|
handles => { |
92
|
|
|
|
|
|
|
'no_chroms' => 'not', |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head3 create_ITERABLE_attr |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
For every argument that ends in _list, create an array, a single val, and a boolean |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
If iterable is |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
some_list |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
We get an array 'some_list', boolean value 'use_somes', and blank/placeholder of 'some' |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The boolean value is set to 0 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
You can only use one iterable per flow |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub create_ITERABLE_attr { |
113
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
114
|
0
|
|
|
|
|
|
my $meta = shift; |
115
|
0
|
|
|
|
|
|
my $k = shift; |
116
|
0
|
|
|
|
|
|
my $v = shift; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $t = $k; |
119
|
0
|
|
|
|
|
|
$t =~ s/_list//; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$self->create_ARRAY_attr( $meta, $k ); |
122
|
0
|
|
|
|
|
|
$self->create_blank_attr( $meta, $t ); |
123
|
0
|
|
|
|
|
|
$self->create_BOOL_attr( $meta, $t ); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub create_BOOL_attr { |
127
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
my $meta = shift; |
129
|
0
|
|
|
|
|
|
my $k = shift; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$meta->add_attribute( |
132
|
|
|
|
|
|
|
'use_' |
133
|
|
|
|
|
|
|
. $k |
134
|
|
|
|
|
|
|
. 's' => ( |
135
|
|
|
|
|
|
|
traits => ['Bool'], |
136
|
|
|
|
|
|
|
is => 'rw', |
137
|
|
|
|
|
|
|
isa => 'Bool', |
138
|
|
|
|
|
|
|
default => 0, |
139
|
|
|
|
|
|
|
handles => { |
140
|
|
|
|
|
|
|
'no_' . $k . 's' => 'not', |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
) |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head3 create_blank_attr |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
placeholder for ITERABLE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub create_blank_attr { |
153
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
154
|
0
|
|
|
|
|
|
my $meta = shift; |
155
|
0
|
|
|
|
|
|
my $k = shift; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
$meta->add_attribute( |
158
|
|
|
|
|
|
|
$k => ( |
159
|
|
|
|
|
|
|
is => 'rw', |
160
|
|
|
|
|
|
|
default => '', |
161
|
|
|
|
|
|
|
) |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 Set Register Types |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
When we are iterating over the local variables, we can create types based on regular expressions |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
INPUT, OUTPUT, *_dir, indir, outdir all create paths - but only the leaves of the data structure |
170
|
|
|
|
|
|
|
*_list transforms the whole data structure |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
after 'BUILD' => sub { |
175
|
|
|
|
|
|
|
my $self = shift; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$self->set_register_types( 'list', |
178
|
|
|
|
|
|
|
{ builder => 'create_ITERABLE_attr', lookup => ['.*_list$'] } ); |
179
|
|
|
|
|
|
|
}; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
1; |