Mercurial > repos > dereeper > roary_plots
comparison Roary/lib/Bio/Roary/External/Fasttree.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::Fasttree; | |
2 | |
3 # ABSTRACT: Wrapper to run Fasttree | |
4 | |
5 =head1 SYNOPSIS | |
6 | |
7 Wrapper to run cd-hit | |
8 use Bio::Roary::External::Fasttree; | |
9 | |
10 my $obj = Bio::Roary::External::Fasttree->new( | |
11 input_file => 'abc.fa', | |
12 exec => 'Fasttree', | |
13 output_base => 'efg', | |
14 ); | |
15 $obj->run; | |
16 | |
17 =cut | |
18 | |
19 use Moose; | |
20 with 'Bio::Roary::JobRunner::Role'; | |
21 | |
22 has 'input_file' => ( is => 'ro', isa => 'Str', required => 1 ); | |
23 has 'output_file' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_file' ); | |
24 has 'exec' => ( is => 'ro', isa => 'Str', default => 'FastTree' ); | |
25 has 'alt_exec' => ( is => 'ro', isa => 'Str', default => 'fasttree' ); | |
26 has '_logging' => ( is => 'ro', isa => 'Str', default => '2> /dev/null' ); | |
27 | |
28 sub _build_output_file | |
29 { | |
30 my ($self) = @_; | |
31 return $self->input_file.".newick"; | |
32 } | |
33 | |
34 sub _command_to_run { | |
35 my ($self) = @_; | |
36 | |
37 my $executable = $self->_find_exe([$self->exec, $self->alt_exec]); | |
38 my $logging_str = ""; | |
39 $logging_str = $self->_logging if(! $self->verbose); | |
40 | |
41 return join( | |
42 ' ', ($executable, '-fastest', '-nt', $self->input_file, '>', $self->output_file, $logging_str) | |
43 ); | |
44 } | |
45 | |
46 sub run { | |
47 my ($self) = @_; | |
48 my @commands_to_run; | |
49 | |
50 if(!defined($self->input_file) || ! ( -e $self->input_file)) | |
51 { | |
52 $self->logger->error( "The input file is missing so not creating a tree" ); | |
53 return 1; | |
54 } | |
55 | |
56 if(-s $self->input_file < 5) | |
57 { | |
58 $self->logger->info( "The input file is too small so not creating a tree" ); | |
59 return 1; | |
60 } | |
61 | |
62 push(@commands_to_run, $self->_command_to_run() ); | |
63 $self->logger->info( "Running command: " . $self->_command_to_run() ); | |
64 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 ); | |
65 $job_runner_obj->run(); | |
66 | |
67 1; | |
68 } | |
69 | |
70 no Moose; | |
71 __PACKAGE__->meta->make_immutable; | |
72 | |
73 1; |