comparison Roary/lib/Bio/Roary/External/Prank.pm @ 0:c47a5f61bc9f draft

Uploaded
author dereeper
date Fri, 14 May 2021 20:27:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c47a5f61bc9f
1 package Bio::Roary::External::Prank;
2
3 # ABSTRACT: Wrapper to run prank
4
5 =head1 SYNOPSIS
6
7 Wrapper to run cd-hit
8 use Bio::Roary::External::Prank;
9
10 my $prank_obj = Bio::Roary::External::Prank->new(
11 input_filename => $fasta_file,
12 output_filename => $fasta_file.'.aln',
13 job_runner => 'Local'
14 );
15 $prank_obj->run();
16 =cut
17
18 use Moose;
19 use File::Spec;
20 with 'Bio::Roary::JobRunner::Role';
21
22 has 'input_filename' => ( is => 'ro', isa => 'Str', required => 1 );
23 has 'output_filename' => ( is => 'ro', isa => 'Str', default => 'output' );
24 has 'exec' => ( is => 'ro', isa => 'Str', default => 'prank' );
25
26 # Overload Role
27 has 'memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' );
28
29 sub _build_memory_in_mb {
30 my ($self) = @_;
31 my $memory_required = 2000;
32 return $memory_required;
33 }
34
35 sub _command_to_run {
36 my ($self) = @_;
37
38 if(! -e $self->input_filename)
39 {
40 $self->logger->error( "Input file to PRANK missing: " . $self->input_filename );
41 }
42
43 return join(
44 ' ',
45 (
46 $self->exec,
47 "-d=" . $self->input_filename,
48 "-o=" . $self->output_filename,
49 '-codon', '-F', '-quiet', '-once', '> /dev/null 2>&1',
50 '&&', 'mv', $self->output_filename . '*.fas',
51 $self->output_filename
52 )
53 );
54 }
55
56 sub run {
57 my ($self) = @_;
58 my @commands_to_run;
59
60 push( @commands_to_run, $self->_command_to_run() );
61 $self->logger->info( "Running command: " . $self->_command_to_run() );
62
63 my $job_runner_obj = $self->_job_runner_class->new(
64 commands_to_run => \@commands_to_run,
65 memory_in_mb => $self->memory_in_mb,
66 queue => $self->_queue,
67 cpus => $self->cpus
68 );
69 $job_runner_obj->run();
70
71 1;
72 }
73
74 no Moose;
75 __PACKAGE__->meta->make_immutable;
76
77 1;