lib/BioX/Workflow/StructureOutput.pm

filter: Statementstmt 65.7% 23 / 35 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 50.0% 1 / 2 totaltotal 63.0% 29 / 46 CC 5 SCAR 18.8
CC
5
Cov
63%
write_min_files
12.0
process_by_sample_outdir
3.0
BEGIN
1.0
CRAP 6.6
« lib/BioX/Workflow/Rules.pm ↑ Summary lib/BioX/Workflow.pm »
1 package BioX::Workflow::StructureOutput;
2  
3 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 BioX::Workflow::StructureOutput
6  
7 BioX::Workflow does the best it can to create an easy to parse directory structure.
8  
9 Options are either files or directories, and for the most part can output looks like:
10  
11 #Global indir - our raw data
12 data/raw
13 #Global outdir - our processed/analyzed data
14 data/processed
15 rule1
16 rule2
17  
18 Or if by_sample_outdir
19 data/processed
20 Sample1/rule1
21 Sample1/rule2
22  
23 =head2 Variables
24  
25 =head3 coerce_paths
26  
27 Coerce relative path directories in variables: indir, outdir, and other variables ending in _dir to full path names
28  
29 =cut
30  
31 2 has 'coerce_paths' => (
32 is => 'rw',
33 isa => 'Bool',
34 default => 1,
35 predicate => 'has_coerce_paths',
36 );
37  
38 =head3 min
39  
40 Print the workflow as 2 files.
41  
42 #run-workflow.sh
43 export SAMPLE=sampleN && ./run_things
44  
45 Instead of each sample having its own command, have sample exported as an environmental variable.
46  
47 This option is probably less ideal when working on an HPC cluster.
48  
49 =cut
50  
51 2 has 'min' => (
52 is => 'rw',
53 isa => 'Bool',
54 default => 0,
55 );
56  
57 =head2 Subroutines
58  
59 =cut
60  
61 0 ▶sub write_min_files {
Subroutine write_min_files: not called CC=3 SCAR=24.8
Pod undocumented
62 0 my ($self) = shift;
63  
64 0 ▶ open( my $fh, '>', 'run-workflow.sh' )
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", "run-workflow.sh" or die print("Could not open file $!\n") 0 0 0
65 or die print "Could not open file $!\n";
66  
67 0 print $fh "#!/bin/bash\n\n";
68  
69 0 my $cwd = getcwd();
70 0 foreach my $sample ( @{ $self->samples } ) {
71 0 print $fh <<EOF;
72 export SAMPLE=$sample && ./workflow.sh
73 EOF
74 }
75  
76 0 close $fh;
77  
78 0 chmod 0777, 'run-workflow.sh';
79  
80 0 $self->samples( ["\${SAMPLE}"] );
81 }
82  
83 =head3 process_by_sample_outdir
84  
85 Make sure indir/outdirs are named appropriated for samples when using by
86  
87 =cut
88  
89 30 ▶sub process_by_sample_outdir {
Subroutine process_by_sample_outdir: called CC=3 SCAR=11.1
Pod documented
90 30 my $self = shift;
91 30 my $sample = shift;
92  
93 30 my ( $tt, $key );
94 30 $tt = $self->outdir;
95 30 $key = $self->key;
96 30 $tt =~ s/$key/$sample\/$key/;
97 30 $self->outdir($tt);
98 30 $self->make_outdir;
99 30 $self->attr->set( 'outdir' => $self->outdir );
100  
101 30 $tt = $self->indir;
102 30 ▶ if ( $tt =~ m/\{\$self/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tt =~ /\{\$self/) { } 0 30 30
elsif ($self->has_pkey) { } 20 10 30
103 0 $tt = "$tt/{\$sample}";
104 0 $self->indir($tt);
105 }
106 elsif ( $self->has_pkey ) {
107 20 $key = $self->pkey;
108 20 $tt =~ s/$key/$sample\/$key/;
109 20 $self->indir($tt);
110 }
111 else {
112 10 $tt = "$tt/$sample";
113 10 $self->indir($tt);
114 }
115 30 $self->attr->set( 'indir' => $self->indir );
116 }
117  
118 2 1;
« lib/BioX/Workflow/Rules.pm ↑ Summary lib/BioX/Workflow.pm »