blib/lib/BioX/Workflow/Command/run/Utils/Attributes.pm

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