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