blib/lib/BioX/Workflow/Plugin/FileExists.pm

filter: Statementstmt 51.5% 17 / 33 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 46.8% 22 / 47 CC 5 SCAR 27.4
CC
5
Cov
41%
__ANON__
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 15.5
↑ Summary Build »
1 package BioX::Workflow::Plugin::FileExists;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use 5.008_005;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 our $VERSION = '0.11';
7  
8 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Data::Pairs;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 before 'write_process' => sub{
14 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=5 SCAR=34.0
15  
16 0 my $process = $self->process;
17 0 chomp($process);
18 0 $process = $process." && \\\n";
19 0 ▶ my @input = $self->local_attr->get_values('INPUT') if $self->local_attr->exists('INPUT');
Branch: 1 branch
BranchTrueFalseTotal
if $self->local_attr->exists("INPUT") 0 0 0
20 0 ▶ my @output = $self->local_attr->get_values('OUTPUT') if $self->local_attr->exists('OUTPUT');
Branch: 1 branch
BranchTrueFalseTotal
if $self->local_attr->exists("OUTPUT") 0 0 0
21  
22 0 my($input, $output) = ($input[0], $output[0]);
23  
24 0 my $tprocess = "";
25 0 ▶ if($input){
Branch: 1 branch
BranchTrueFalseTotal
if ($input) 0 0 0
26 0 $tprocess .=<<EOF;
27 [ -f "$input" ] || \\{>&2 echo "INPUT: $input not found" ; exit 256; \\} && \\
28 [ -s "$input" ] || \\{>&2 echo "INPUT: $input is empty"; \\} && \\
29 touch $input || {>&2 echo "INPUT: $input could not be touched. Please check your file permissions!"; exit 1;\\} && \\
30 touch $output || {>&2 echo "OUTPUT: $output could not be touched. Please check your file permissions!"; exit 1;\\} && \\
31 EOF
32 0 $tprocess .= $process;
33 0 $process = $tprocess;
34 }
35 0 ▶ if($output){
Branch: 1 branch
BranchTrueFalseTotal
if ($output) 0 0 0
36 0 $tprocess =<<EOF;
37 [ -f "$output" ] || \\{>&2 echo "OUTPUT $output not found" ; \\} && \\
38 [ -s "$output" ] || \\{>&2 echo "OUTPUT $output is empty"; \\}
39 EOF
40 0 $process .= $tprocess;
41 }
42 0 $self->process($process);
43  
44 1 };
45  
46 1 1;
47 __END__
48  
49 =encoding utf-8
50  
51 =head1 NAME
52  
53 BioX::Workflow::Plugin::FileExists - a plugin to BioX::Workflow
54  
55 =head1 SYNOPSIS
56  
57 biox-workflow.pl --plugins FileExists
58  
59 =head1 DESCRIPTION
60  
61 BioX::Workflow::Plugin::FileExists is a plugin of BioX::Workflow that first checks that your local INPUT exists.
62 If it doesn't exist it will exit with 256.
63 If INPUT is empty it will give a warning.
64 If OUTPUT is empty or doesn't exist it will give a warning.
65  
66  
67 =head1 AUTHOR
68  
69 Jillian Rowe E<lt>jillian.e.rowe@gmail.comE<gt>
70  
71 =head1 COPYRIGHT
72  
73 Copyright 2016- Jillian Rowe
74  
75 =head1 LICENSE
76  
77 This library is free software; you can redistribute it and/or modify
78 it under the same terms as Perl itself.
79  
80 =head1 SEE ALSO
81  
82 =cut
↑ Summary Build »