« lib/BioX/Workflow/Command/Utils/Create.pm
↑ Summary
lib/BioX/Workflow/Command/run/Rules/Directives/Types/Mustache.pm »
| 1 | package BioX::Workflow::Command::run::Utils::Attributes; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use MooseX::App::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use BioSAILs::Utils::Traits qw(ArrayRefOfStrs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Storable qw(dclone); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use File::Copy; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use File::Basename; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use DateTime; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | =head1 Name | ||||||||||
| 16 | |||||||||||
| 17 | BioX::Workflow::Command::run::Utils::Attributes | ||||||||||
| 18 | |||||||||||
| 19 | =head2 Description | ||||||||||
| 20 | |||||||||||
| 21 | Attributes that are used for the duration of run | ||||||||||
| 22 | |||||||||||
| 23 | =cut | ||||||||||
| 24 | |||||||||||
| 25 | =head2 Command Line Options | ||||||||||
| 26 | |||||||||||
| 27 | =cut | ||||||||||
| 28 | |||||||||||
| 29 | option 'samples' => ( | ||||||||||
| 30 | traits => ['Array'], | ||||||||||
| 31 | is => 'rw', | ||||||||||
| 32 | required => 0, | ||||||||||
| 33 | isa => ArrayRefOfStrs, | ||||||||||
| 34 | documentation => 'Choose a subset of samples', | ||||||||||
| 35 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 36 | 1 | cmd_split => qr/,/, | |||||||||
| 37 | handles => { | ||||||||||
| 38 | all_samples => 'elements', | ||||||||||
| 39 | has_samples => 'count', | ||||||||||
| 40 | join_samples => 'join', | ||||||||||
| 41 | }, | ||||||||||
| 42 | cmd_aliases => ['s'], | ||||||||||
| 43 | ); | ||||||||||
| 44 | |||||||||||
| 45 | has 'cached_workflow' => ( | ||||||||||
| 46 | is => 'rw', | ||||||||||
| 47 | isa => 'Str', | ||||||||||
| 48 | lazy => 1, | ||||||||||
| 49 | default => '', | ||||||||||
| 50 | 0 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 51 | 0 | my $self = shift; | |||||||||
| 52 | |||||||||||
| 53 | 0 | my ( $file, $dir, $ext ) = fileparse( $self->workflow, qr/\.[^.]*/ ); | |||||||||
| 54 | 0 | my $now = DateTime->now; | |||||||||
| 55 | 0 | my $ymd = $now->ymd; | |||||||||
| 56 | 0 | my $hms = $now->hms; | |||||||||
| 57 | 0 | $hms =~ s/:/-/g; | |||||||||
| 58 | 0 | return File::Spec->catdir( $self->cache_dir, '.biox-cache', 'workflows', | |||||||||
| 59 | $file . "_$ymd" . "_$hms" . $ext ); | ||||||||||
| 60 | } | ||||||||||
| 61 | 1 | ); | |||||||||
| 62 | |||||||||||
| 63 | =head2 Attributes | ||||||||||
| 64 | |||||||||||
| 65 | =cut | ||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | =head3 local_rule1 | ||||||||||
| 69 | |||||||||||
| 70 | Rule we are currently evaluating | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | 1 | has 'local_rule' => ( | |||||||||
| 75 | is => 'rw', | ||||||||||
| 76 | isa => 'HashRef', | ||||||||||
| 77 | lazy_build => 1, | ||||||||||
| 78 | ); | ||||||||||
| 79 | |||||||||||
| 80 | =head3 global_attr | ||||||||||
| 81 | |||||||||||
| 82 | Attributes defined in the global key of the config | ||||||||||
| 83 | |||||||||||
| 84 | =cut | ||||||||||
| 85 | |||||||||||
| 86 | 1 | has 'global_attr' => ( | |||||||||
| 87 | is => 'rw', | ||||||||||
| 88 | isa => 'BioX::Workflow::Command::run::Rules::Directives', | ||||||||||
| 89 | required => 0, | ||||||||||
| 90 | ); | ||||||||||
| 91 | |||||||||||
| 92 | =head3 local_attr | ||||||||||
| 93 | |||||||||||
| 94 | Attributes in the local key of the rule | ||||||||||
| 95 | |||||||||||
| 96 | =cut | ||||||||||
| 97 | |||||||||||
| 98 | 1 | has 'local_attr' => ( | |||||||||
| 99 | is => 'rw', | ||||||||||
| 100 | isa => 'BioX::Workflow::Command::run::Rules::Directives', | ||||||||||
| 101 | required => 0, | ||||||||||
| 102 | ); | ||||||||||
| 103 | |||||||||||
| 104 | 1 | has 'p_local_attr' => ( | |||||||||
| 105 | is => 'rw', | ||||||||||
| 106 | isa => 'BioX::Workflow::Command::run::Rules::Directives', | ||||||||||
| 107 | required => 0, | ||||||||||
| 108 | ); | ||||||||||
| 109 | |||||||||||
| 110 | 1 | has 'rule_name' => ( | |||||||||
| 111 | is => 'rw', | ||||||||||
| 112 | isa => 'Str', | ||||||||||
| 113 | lazy_build => 1, | ||||||||||
| 114 | ); | ||||||||||
| 115 | |||||||||||
| 116 | has 'rule_names' => ( | ||||||||||
| 117 | traits => ['Array'], | ||||||||||
| 118 | is => 'rw', | ||||||||||
| 119 | isa => 'ArrayRef', | ||||||||||
| 120 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 121 | 1 | handles => { | |||||||||
| 122 | all_rule_names => 'elements', | ||||||||||
| 123 | has_rule_names => 'count', | ||||||||||
| 124 | join_rule_names => 'join', | ||||||||||
| 125 | first_index_rule_names => 'first_index', | ||||||||||
| 126 | grep_rule_names => 'grep', | ||||||||||
| 127 | }, | ||||||||||
| 128 | ); | ||||||||||
| 129 | |||||||||||
| 130 | has 'select_rule_keys' => ( | ||||||||||
| 131 | traits => ['Array'], | ||||||||||
| 132 | is => 'rw', | ||||||||||
| 133 | isa => 'ArrayRef', | ||||||||||
| 134 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 135 | 1 | handles => { | |||||||||
| 136 | all_select_rule_keys => 'elements', | ||||||||||
| 137 | has_select_rule_keys => 'count', | ||||||||||
| 138 | join_select_rule_keys => 'join', | ||||||||||
| 139 | first_index_select_rule_keys => 'first_index', | ||||||||||
| 140 | add_select_rule_key => 'push', | ||||||||||
| 141 | }, | ||||||||||
| 142 | ); | ||||||||||
| 143 | |||||||||||
| 144 | has 'omit_rule_keys' => ( | ||||||||||
| 145 | traits => ['Array'], | ||||||||||
| 146 | is => 'rw', | ||||||||||
| 147 | isa => 'ArrayRef', | ||||||||||
| 148 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 149 | 1 | handles => { | |||||||||
| 150 | all_omit_rule_keys => 'elements', | ||||||||||
| 151 | has_omit_rule_keys => 'count', | ||||||||||
| 152 | join_omit_rule_keys => 'join', | ||||||||||
| 153 | first_index_omit_rule_keys => 'first_index', | ||||||||||
| 154 | add_omit_rule_key => 'push', | ||||||||||
| 155 | }, | ||||||||||
| 156 | ); | ||||||||||
| 157 | |||||||||||
| 158 | 1 | has 'p_rule_name' => ( | |||||||||
| 159 | is => 'rw', | ||||||||||
| 160 | isa => 'Str', | ||||||||||
| 161 | lazy_build => 1, | ||||||||||
| 162 | ); | ||||||||||
| 163 | |||||||||||
| 164 | =head3 process_obj | ||||||||||
| 165 | |||||||||||
| 166 | Store all the text from processing the rules | ||||||||||
| 167 | |||||||||||
| 168 | At the end we will decide which rules to print | ||||||||||
| 169 | |||||||||||
| 170 | =cut | ||||||||||
| 171 | |||||||||||
| 172 | has 'process_obj' => ( | ||||||||||
| 173 | traits => ['Hash'], | ||||||||||
| 174 | is => 'rw', | ||||||||||
| 175 | isa => 'HashRef', | ||||||||||
| 176 | 0 | ▶ | default => sub { {} }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 177 | 1 | handles => { | |||||||||
| 178 | seen_process_obj_pairs => 'kv', | ||||||||||
| 179 | clear_seen_process_obj => 'clear', | ||||||||||
| 180 | }, | ||||||||||
| 181 | ); | ||||||||||
| 182 | |||||||||||
| 183 | 0 | ▶ | sub apply_local_attr { | ||||||||
|
Subroutine
apply_local_attr: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 184 | 0 | my $self = shift; | |||||||||
| 185 | |||||||||||
| 186 | 0 | ▶ | return unless exists $self->local_rule->{ $self->rule_name }->{local}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 187 | |||||||||||
| 188 | $self->local_attr->create_attr( | ||||||||||
| 189 | 0 | $self->local_rule->{ $self->rule_name }->{local} ); | |||||||||
| 190 | |||||||||||
| 191 | } | ||||||||||
| 192 | |||||||||||
| 193 | 0 | ▶ | sub apply_global_attributes { | ||||||||
|
Subroutine
apply_global_attributes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 194 | 0 | my $self = shift; | |||||||||
| 195 | |||||||||||
| 196 | 0 | my $global_attr = BioX::Workflow::Command::run::Rules::Directives->new(); | |||||||||
| 197 | |||||||||||
| 198 | 0 | $self->global_attr($global_attr); | |||||||||
| 199 | |||||||||||
| 200 | 0 | ▶ | return unless exists $self->workflow_data->{global}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 201 | |||||||||||
| 202 | 0 | $self->global_attr->create_attr( $self->workflow_data->{global} ); | |||||||||
| 203 | |||||||||||
| 204 | # if ( exists $self->global_attr->chunks->{start} ) { | ||||||||||
| 205 | # $self->global_attr->use_chunks(1); | ||||||||||
| 206 | # } | ||||||||||
| 207 | } | ||||||||||
| 208 | |||||||||||
| 209 | 1 | 1; | |||||||||