File Coverage

lib/Bio/Roary/External/Mafft.pm
Criterion Covered Total %
statement 22 23 95.6
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 29 32 90.6


line stmt bran cond sub pod time code
1             package Bio::Roary::External::Mafft;
2             $Bio::Roary::External::Mafft::VERSION = '3.11.0';
3             # ABSTRACT: Wrapper to run mafft
4              
5              
6 2     2   680 use Moose;
  2         3  
  2         15  
7 2     2   11367 use File::Spec;
  2         4  
  2         473  
8             with 'Bio::Roary::JobRunner::Role';
9              
10             has 'input_filename' => ( is => 'ro', isa => 'Str', required => 1 );
11             has 'output_filename' => ( is => 'ro', isa => 'Str', default => 'output' );
12             has 'exec' => ( is => 'ro', isa => 'Str', default => 'mafft' );
13              
14             # Overload Role
15             has 'memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' );
16              
17             sub _build_memory_in_mb {
18 1     1   3 my ($self) = @_;
19 1         3 my $memory_required = 2000;
20 1         20 return $memory_required;
21             }
22              
23             sub _command_to_run {
24 3     3   6 my ($self) = @_;
25              
26 3 50       69 if(! -e $self->input_filename)
27             {
28 0         0 $self->logger->error( "Input file to MAFFT missing: " . $self->input_filename );
29             }
30 3         59 return join(
31             ' ',
32             (
33             $self->exec,
34             '--auto',
35             '--quiet',
36             $self->input_filename,
37             '>',
38             $self->output_filename
39             )
40             );
41             }
42              
43             sub run {
44 1     1 0 2 my ($self) = @_;
45 1         2 my @commands_to_run;
46              
47 1         3 push( @commands_to_run, $self->_command_to_run() );
48 1         20 $self->logger->info( "Running command: " . $self->_command_to_run() );
49              
50 1         27 my $job_runner_obj = $self->_job_runner_class->new(
51             commands_to_run => \@commands_to_run,
52             memory_in_mb => $self->memory_in_mb,
53             queue => $self->_queue,
54             cpus => $self->cpus
55             );
56 1         5 $job_runner_obj->run();
57              
58 1         108 1;
59             }
60              
61 2     2   13 no Moose;
  2         3  
  2         9  
62             __PACKAGE__->meta->make_immutable;
63              
64             1;
65              
66             __END__
67              
68             =pod
69              
70             =encoding UTF-8
71              
72             =head1 NAME
73              
74             Bio::Roary::External::Mafft - Wrapper to run mafft
75              
76             =head1 VERSION
77              
78             version 3.11.0
79              
80             =head1 SYNOPSIS
81              
82             Wrapper to run mafft
83             use Bio::Roary::External::Mafft;
84              
85             my $mafft_obj = Bio::Roary::External::Mafft->new(
86             input_filename => $fasta_file,
87             output_filename => $fasta_file.'.aln',
88             job_runner => 'Local'
89             );
90             $mafft_obj->run();
91              
92             =head1 AUTHOR
93              
94             Andrew J. Page <ap13@sanger.ac.uk>
95              
96             =head1 COPYRIGHT AND LICENSE
97              
98             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
99              
100             This is free software, licensed under:
101              
102             The GNU General Public License, Version 3, June 2007
103              
104             =cut