blib/lib/BioX/Workflow/Command/run/Rules/Directives/Types/List.pm

filter: Statementstmt 39.1% 18 / 46 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 30.0% 3 / 10 Podpod 66.6% 2 / 3 totaltotal 33.8% 23 / 68 CC 4 SCAR 19.9
CC
4
Cov
34%
__ANON__
20.0
__ANON__
2.0
__ANON__
2.0
CRAP 7.3
« blib/lib/BioX/Workflow/Command/run/Rules/Directives/Types/Config.pm ↑ Summary blib/lib/BioX/Workflow/Command/run/Utils/Files/TrackChanges.pm »
1 package BioX::Workflow::Command::run::Rules::Directives::Types::List;
2  
3 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 0 ▶ default => sub { {} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 1 );
25  
26 1 has 'chunk' => ( is => 'rw' );
27  
28 1 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 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
45 0 ▶ if ( !exists $self->chunks->{start} || !exists $self->chunks->{end} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->chunks->{"start"} and exists $self->chunks->{"end"}) 0 0 0
Condition0%0/3
exists $self->chunks->{"start"} and exists $self->chunks->{"end"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->chunks->{"start"} and exists $self->chunks->{"end"}
exists $self->chunks->{"start"} exists $self->chunks->{"end"}
Truth table0%0/3
A and B
A= exists $self->chunks->{"start"}B= exists $self->chunks->{"end"}
ABresult
0X0
100
111
46 0 return [];
47 }
48 0 my @array = ();
49 0 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($x <= $self->chunks->{"end"}) 0 0 0
50 my $x = $self->chunks->{start} ;
51 $x <= $self->chunks->{end} ;
52 $x = $x + $self->chunks->{step}
53 )
54 {
55 0 push( @array, $x );
56 }
57 0 return \@array;
58 },
59 1 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 0 ▶ return [ 1 .. 22, 'X', 'Y', 'MT' ];
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 },
79 1 handles => {
80 'all_chrom_lists' => 'elements',
81 },
82 );
83  
84 1 has 'chrom' => ( is => 'rw' );
85  
86 1 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 ▶ my $self = shift;
Subroutine create_ITERABLE_attr: not called CC=1 SCAR=6.9
Pod documented
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 ▶ my $self = shift;
Subroutine create_BOOL_attr: not called CC=1 SCAR=6.9
Pod undocumented
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 ▶ my $self = shift;
Subroutine create_blank_attr: not called CC=1 SCAR=6.9
Pod documented
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 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
176  
177 0 $self->set_register_types( 'list',
178 { builder => 'create_ITERABLE_attr', lookup => ['.*_list$'] } );
179 1 };
180  
181 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
182  
183 1 1;
« blib/lib/BioX/Workflow/Command/run/Rules/Directives/Types/Config.pm ↑ Summary blib/lib/BioX/Workflow/Command/run/Utils/Files/TrackChanges.pm »