BioX-Workflow-Plugin-Drake
view release on metacpan or search on metacpan
lib/BioX/Workflow/Plugin/Drake.pm view on Meta::CPAN
Run the drake things
drake --vars "SAMPLE=$sample" --workflow/workflow.drake
workflow.drake
Our regular file
=cut
has 'min' => (
is => 'rw',
isa => 'Bool',
default => 0,
);
=head2 Subroutines
Subroutines
=head3 before run
Must initialize some variables
=cut
before 'run' => sub{
my($self) = shift;
if($self->min){
$self->full(0);
}
$self->wait(0);
$self->comment_char(';');
};
=head3 after get_samples
Things to do if we decide to do a min version
=cut
after 'get_samples' => sub{
my($self) = shift;
return unless $self->min;
open(my $fh, '>', 'run-workflow.sh') or die print "Could not open file $!\n";
print $fh "#!/bin/bash\n\n";
foreach my $sample (@{$self->samples}){
print $fh <<EOF;
drake --vars "SAMPLE=$sample" --workflow workflow.drake
EOF
}
close $fh;
chmod 0777, 'run-workflow.sh';
$self->samples(["\$SAMPLE"]);
};
=head3 write_process
Fill in the template with the process
Ensure INPUT/OUTPUT exist
Prettyify the output a bit
=cut
before 'write_process' => sub{
my($self) = shift;
$DB::single=2;
if((! $self->local_attr->exists('INPUT')) && ! $self->local_attr->exists('OUTPUT') ){
print "$self->{comment_char} There is no INPUT or OUTPUT!\n";
}
#Make the formatting a big prettier
my @tmp = split("\n", $self->process);
$self->process(join("\n\t", @tmp));
my $tmp = "{\$self->OUTPUT} <- {\$self->INPUT}\n\t";
$DB::single=2;
if($self->min){
$tmp =~ s/\$SAMPLE/\$[SAMPLE]/g;
}
my $newprocess = $tmp.$self->process;
$self->process($newprocess);
};
#before 'process_template' => sub {
#my $self = shift;
#my $tmp = "{\$self->OUTPUT} <- {\$self->INPUT}\n\t";
#$DB::single=2;
#if($self->min){
#$tmp =~ s/\$SAMPLE/\$[SAMPLE]/g;
#}
#my $newprocess = $tmp.$self->process;
#$self->process($newprocess);
#};
1;
__END__
=encoding utf-8
=head1 AUTHOR
Jillian Rowe E<lt>jillian.e.rowe@gmail.comE<gt>
=head1 COPYRIGHT
Copyright 2015- Jillian Rowe
( run in 1.269 second using v1.01-cache-2.11-cpan-39bf76dae61 )