File Coverage

lib/Bio/Roary/External/Fasttree.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 6 0.0
condition 0 3 0.0
subroutine 2 5 40.0
pod 0 1 0.0
total 8 41 19.5


line stmt bran cond sub pod time code
1             package Bio::Roary::External::Fasttree;
2             $Bio::Roary::External::Fasttree::VERSION = '3.11.0';
3             # ABSTRACT: Wrapper to run Fasttree
4              
5              
6 1     1   6 use Moose;
  1         2  
  1         5  
7             with 'Bio::Roary::JobRunner::Role';
8              
9             has 'input_file' => ( is => 'ro', isa => 'Str', required => 1 );
10             has 'output_file' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_file' );
11             has 'exec' => ( is => 'ro', isa => 'Str', default => 'FastTree' );
12             has 'alt_exec' => ( is => 'ro', isa => 'Str', default => 'fasttree' );
13             has '_logging' => ( is => 'ro', isa => 'Str', default => '2> /dev/null' );
14              
15             sub _build_output_file
16             {
17 0     0     my ($self) = @_;
18 0           return $self->input_file.".newick";
19             }
20              
21             sub _command_to_run {
22 0     0     my ($self) = @_;
23              
24 0           my $executable = $self->_find_exe([$self->exec, $self->alt_exec]);
25 0           my $logging_str = "";
26 0 0         $logging_str = $self->_logging if(! $self->verbose);
27              
28 0           return join(
29             ' ', ($executable, '-fastest', '-nt', $self->input_file, '>', $self->output_file, $logging_str)
30             );
31             }
32              
33             sub run {
34 0     0 0   my ($self) = @_;
35 0           my @commands_to_run;
36              
37 0 0 0       if(!defined($self->input_file) || ! ( -e $self->input_file))
38             {
39 0           $self->logger->error( "The input file is missing so not creating a tree" );
40 0           return 1;
41             }
42              
43 0 0         if(-s $self->input_file < 5)
44             {
45 0           $self->logger->info( "The input file is too small so not creating a tree" );
46 0           return 1;
47             }
48              
49 0           push(@commands_to_run, $self->_command_to_run() );
50 0           $self->logger->info( "Running command: " . $self->_command_to_run() );
51 0           my $job_runner_obj = $self->_job_runner_class->new( commands_to_run => \@commands_to_run, memory_in_mb => $self->memory_in_mb, queue => $self->_queue, cpus => $self->cpus );
52 0           $job_runner_obj->run();
53            
54 0           1;
55             }
56              
57 1     1   5922 no Moose;
  1         2  
  1         4  
58             __PACKAGE__->meta->make_immutable;
59              
60             1;
61              
62             __END__
63              
64             =pod
65              
66             =encoding UTF-8
67              
68             =head1 NAME
69              
70             Bio::Roary::External::Fasttree - Wrapper to run Fasttree
71              
72             =head1 VERSION
73              
74             version 3.11.0
75              
76             =head1 SYNOPSIS
77              
78             Wrapper to run cd-hit
79             use Bio::Roary::External::Fasttree;
80              
81             my $obj = Bio::Roary::External::Fasttree->new(
82             input_file => 'abc.fa',
83             exec => 'Fasttree',
84             output_base => 'efg',
85             );
86             $obj->run;
87              
88             =head1 AUTHOR
89              
90             Andrew J. Page <ap13@sanger.ac.uk>
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
95              
96             This is free software, licensed under:
97              
98             The GNU General Public License, Version 3, June 2007
99              
100             =cut