File Coverage

blib/lib/BioX/Workflow/Command/run/Rules/Directives/Sample.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package BioX::Workflow::Command::run::Rules::Directives::Sample;
2              
3 1     1   523 use MooseX::App::Role;
  1         2  
  1         9  
4 1     1   6670 use namespace::autoclean;
  1         2  
  1         7  
5              
6 1     1   67 use BioSAILs::Utils::Traits qw(ArrayRefOfStrs);
  1         2  
  1         13  
7 1     1   935 use MooseX::Types::Path::Tiny qw/Path Paths AbsPath AbsPaths AbsFile/;
  1         4  
  1         12  
8              
9             =head3 sample_rule
10              
11             Rule to find files/samples
12              
13             =cut
14              
15             has 'sample_rule' => (
16             is => 'rw',
17             isa => 'Str',
18             default => sub { return "(.*)"; },
19             clearer => 'clear_sample_rule',
20             predicate => 'has_sample_rule',
21             );
22              
23             =head3 maxdepth
24              
25             Like find -max_depth
26              
27             =cut
28              
29             has 'maxdepth' => (
30             is => 'rw',
31             default => 1
32             );
33              
34             =head3 sample_glob
35              
36             Alternately, instead of sample_rule use sample_glob to find files. Glob does not
37             differentiate between files and directories.
38              
39             =cut
40              
41             has 'sample_glob' => (
42             is => 'rw',
43             isa => 'Str',
44             clearer => 'clear_sample_glob',
45             predicate => 'has_sample_glob',
46             );
47              
48             =head2 find_sample_bydir
49              
50             #Previous find_by_dir
51              
52             Use this option when you sample names are by directory
53             The default is to find samples by filename
54              
55             /SAMPLE1
56             SAMPLE1_r1.fastq.gz
57             SAMPLE1_r2.fastq.gz
58             /SAMPLE2
59             SAMPLE2_r1.fastq.gz
60             SAMPLE2_r2.fastq.gz
61              
62             =cut
63              
64             has 'find_sample_bydir' => (
65             is => 'rw',
66             isa => 'Bool',
67             default => 0,
68             documentation => q{Use this option when you sample names are directories},
69             predicate => 'has_find_sample_bydir',
70             );
71              
72             #Same thing - here for backwards compatibility
73              
74             has 'find_by_dir' => (
75             is => 'rw',
76             isa => 'Bool',
77             default => 0,
78             documentation => q{Use this option when you sample names are directories},
79             predicate => 'has_find_by_dir',
80             trigger => sub {
81             my $self = shift;
82             $self->find_sample_bydir( $self->find_by_dir );
83             }
84             );
85              
86             =head3 by_sample_outdir
87              
88             No change - previously by sample outdir
89              
90             Preface outdir with sample
91              
92             Instead of
93              
94             outdir/
95             rule1
96             rule2
97              
98             outdir/
99             Sample_01/
100             rule1
101             rule2
102              
103             =cut
104              
105             has 'by_sample_outdir' => (
106             traits => ['Bool'],
107             is => 'rw',
108             isa => 'Bool',
109             default => 0,
110             documentation => q{Use this option when you sample names are directories},
111             predicate => 'has_by_sample_outdir',
112             handles => {
113             clear_by_sample_outdir => 'unset',
114             },
115             );
116              
117             =head3 samples
118              
119             This is our actual list of samples
120              
121             =cut
122              
123             option 'samples' => (
124             traits => ['Array'],
125             is => 'rw',
126             isa => 'ArrayRef',
127             default => sub { [] },
128             required => 0,
129             cmd_split => qr/,/,
130             handles => {
131             all_samples => 'elements',
132             has_samples => 'count',
133             has_no_samples => 'is_empty',
134             sorted_samples => 'sort',
135             },
136             documentation =>
137             q{Supply samples on the command line as --samples sample1 --samples sample2, or find through sample_rule.}
138             );
139              
140             option 'exclude_samples' => (
141             traits => ['Array'],
142             is => 'rw',
143             isa => 'ArrayRef',
144             default => sub { [] },
145             required => 0,
146             cmd_split => qr/,/,
147             handles => {
148             all_exclude_samples => 'elements',
149             has_exclude_samples => 'count',
150             has_no_exclude_samples => 'is_empty',
151             sorted_exclude_samples => 'sort',
152             },
153             documentation =>
154             q{Exclude samples from analysis --exclude_samples sample1 --exclude_samples sample2}
155             );
156              
157             has 'sample' => (
158             is => 'rw',
159             isa => 'Str',
160             predicate => 'has_sample',
161             clearer => 'clear_sample',
162             required => 0,
163             );
164              
165             =head3 resample
166              
167             Boolean value get new samples based on indir/sample_rule or no
168              
169             Samples are found at the beginning of the workflow, based on the global indir
170             variable and the file_find.
171              
172             Chances are you don't want to set resample to true. These files probably won't
173             exist outside of the indirectory until the pipeline is run.
174              
175             One example of doing so, shown in the gemini.yml in the examples directory, is
176             looking for uncompressed files, .vcf extension, compressing them, and then
177             resampling based on the .vcf.gz extension.
178              
179             =cut
180              
181             has 'resample' => (
182             isa => 'Bool',
183             is => 'rw',
184             default => 0,
185             predicate => 'has_resample',
186             clearer => 'clear_resample',
187             );
188              
189             =head3 sample_files
190              
191             Infiles to be processed
192              
193             =cut
194              
195             has 'sample_files' => (
196             is => 'rw',
197             isa => Paths,
198             coerce => 1,
199             );
200              
201             1;