| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package BioX::Workflow::Plugin::FileExists; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 12260 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 20 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 1 |  |  | 1 |  | 13 | use 5.008_005; | 
|  | 1 |  |  |  |  | 2 |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.13'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 469 | use Data::Dumper; | 
|  | 1 |  |  |  |  | 6062 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 9 | 1 |  |  | 1 |  | 420 | use Data::Pairs; | 
|  | 1 |  |  |  |  | 1555 |  | 
|  | 1 |  |  |  |  | 34 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 1 |  |  | 1 |  | 375 | use Moose::Role; | 
|  | 1 |  |  |  |  | 286099 |  | 
|  | 1 |  |  |  |  | 3 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | before 'write_process' => sub{ | 
| 14 |  |  |  |  |  |  | my $self = shift; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | $DB::single=2; | 
| 17 |  |  |  |  |  |  | my $process = $self->process; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | my @input =  $self->local_attr->get_values('INPUT') if $self->local_attr->exists('INPUT'); | 
| 20 |  |  |  |  |  |  | my @output =  $self->local_attr->get_values('OUTPUT') if $self->local_attr->exists('OUTPUT'); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | my($input, $output) = ($input[0], $output[0]); | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | if(!$input && !$output){ | 
| 25 |  |  |  |  |  |  | return; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | my $tprocess = ""; | 
| 29 |  |  |  |  |  |  | if($input){ | 
| 30 |  |  |  |  |  |  | $tprocess .=<<EOF; | 
| 31 |  |  |  |  |  |  | [ -f "$input"  ] || \\{ >&2 echo "INPUT: $input not found" ; exit 256; \\} && \\ | 
| 32 |  |  |  |  |  |  | [ -s "$input"  ] || \\{ >&2 echo "INPUT: $input is empty";  \\} && \\ | 
| 33 |  |  |  |  |  |  | touch $input || \\{>&2 echo "INPUT: $input could not be touched. Please check your file permissions!"; exit 1; \\} && \\ | 
| 34 |  |  |  |  |  |  | EOF | 
| 35 |  |  |  |  |  |  | if($output){ | 
| 36 |  |  |  |  |  |  | $tprocess .=<<EOF; | 
| 37 |  |  |  |  |  |  | touch $output || \\{>&2 echo "OUTPUT: $output could not be touched. Please check your file permissions!"; exit 1;\\} && \\ | 
| 38 |  |  |  |  |  |  | EOF | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  | $tprocess .= $process; | 
| 41 |  |  |  |  |  |  | $process = $tprocess; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | if($output){ | 
| 44 |  |  |  |  |  |  | chomp($process); | 
| 45 |  |  |  |  |  |  | $process = $process." && \\\n"; | 
| 46 |  |  |  |  |  |  | $tprocess =<<EOF; | 
| 47 |  |  |  |  |  |  | [ -f "$output"  ] || \\{>&2 echo "OUTPUT $output not found" ;  \\} && \\ | 
| 48 |  |  |  |  |  |  | [ -s "$output"  ] || \\{>&2 echo "OUTPUT $output is empty"; \\} | 
| 49 |  |  |  |  |  |  | EOF | 
| 50 |  |  |  |  |  |  | $process .= $tprocess; | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  | $DB::single=2; | 
| 53 |  |  |  |  |  |  | $self->process($process); | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | }; | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | 1; | 
| 58 |  |  |  |  |  |  | __END__ | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =encoding utf-8 | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =head1 NAME | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | BioX::Workflow::Plugin::FileExists - a plugin to BioX::Workflow | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | biox-workflow.pl --plugins FileExists | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | BioX::Workflow::Plugin::FileExists is a plugin of BioX::Workflow that first checks that your local INPUT exists. | 
| 73 |  |  |  |  |  |  | If it doesn't exist it will exit with 256. | 
| 74 |  |  |  |  |  |  | If INPUT is empty it will give a warning. | 
| 75 |  |  |  |  |  |  | If OUTPUT is empty or doesn't exist it will give a warning. | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =head1 AUTHOR | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | Jillian Rowe E<lt>jillian.e.rowe@gmail.comE<gt> | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | Copyright 2016- Jillian Rowe | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =head1 LICENSE | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify | 
| 89 |  |  |  |  |  |  | it under the same terms as Perl itself. | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =cut |