| 1 | package Bio::Roary::External::Mcl; | ||||||||||
| 2 | 2 | $Bio::Roary::External::Mcl::VERSION = '3.13.0'; | |||||||||
| 3 | # ABSTRACT: Wrapper around MCL which takes in blast results and outputs clustered results | ||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use File::Which; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | with 'Bio::Roary::JobRunner::Role'; | |||||||||
| 9 | |||||||||||
| 10 | 2 | has 'blast_results' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 11 | 2 | has 'mcxdeblast_exec' => ( is => 'ro', isa => 'Str', default => 'mcxdeblast' ); | |||||||||
| 12 | 2 | has '_full_mcxdeblast_exec' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__full_mcxdeblast_exec'); | |||||||||
| 13 | 2 | has 'mcl_exec' => ( is => 'ro', isa => 'Str', default => 'mcl' ); | |||||||||
| 14 | 2 | has 'output_file' => ( is => 'ro', isa => 'Str', default => 'output_groups' ); | |||||||||
| 15 | |||||||||||
| 16 | 2 | has '_score' => ( is => 'ro', isa => 'Str', default => 'r' ); | |||||||||
| 17 | |||||||||||
| 18 | 2 | has 'inflation_value' => ( is => 'ro', isa => 'Num', default => 1.5 ); | |||||||||
| 19 | 2 | has '_logging' => ( is => 'ro', isa => 'Str', default => '> /dev/null 2>&1' ); | |||||||||
| 20 | |||||||||||
| 21 | 2 | has 'memory_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' ); | |||||||||
| 22 | |||||||||||
| 23 | sub _build_memory_in_mb | ||||||||||
| 24 | 1 | ▶ | { | ||||||||
|
Subroutine
_build_memory_in_mb: called CC=2 SCAR=8.7
| |||||||||||
| 25 | 1 | my ($self) = @_; | |||||||||
| 26 | # Todo: implement this equation for memory estimation if this hardcoded value proves too unstable. | ||||||||||
| 27 | # http://micans.org/mcl/man/mcl.html#opt-how-much-ram | ||||||||||
| 28 | |||||||||||
| 29 | 1 | my $filename = $self->blast_results; | |||||||||
| 30 | 1 | my $memory_required = 2000; | |||||||||
| 31 | 1 | ▶ | if(-e $filename) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | { | ||||||||||
| 33 | 0 | $memory_required = -s $filename; | |||||||||
| 34 | # Convert to mb | ||||||||||
| 35 | 0 | $memory_required = int($memory_required/1000000); | |||||||||
| 36 | # increase memory for worst case senario | ||||||||||
| 37 | 0 | $memory_required *= 3; | |||||||||
| 38 | 0 | $memory_required += 2000; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | return $memory_required; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | sub _build__full_mcxdeblast_exec | ||||||||||
| 46 | 2 | ▶ | { | ||||||||
|
Subroutine
_build__full_mcxdeblast_exec: called CC=3 SCAR=11.1
| |||||||||||
| 47 | 2 | my ($self) = @_; | |||||||||
| 48 | |||||||||||
| 49 | 2 | ▶ | if(-e $self->mcxdeblast_exec) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | { | ||||||||||
| 51 | 1 | return $self->mcxdeblast_exec; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 1 | my $full_exec = which($self->mcxdeblast_exec); | |||||||||
| 55 | 1 | ▶ | if(! defined($full_exec)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | { | ||||||||||
| 57 | 1 | $self->logger->error("Cannot find the mcxdeblast executable, please ensure its in your PATH") ; | |||||||||
| 58 | 1 | exit(); | |||||||||
| 59 | } | ||||||||||
| 60 | 0 | return "perl $full_exec"; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 4 | ▶ | sub _command_to_run { | ||||||||
|
Subroutine
_command_to_run: called CC=1 SCAR=0.0
| |||||||||||
| 64 | 4 | my ($self) = @_; | |||||||||
| 65 | 4 | return join( | |||||||||
| 66 | " ", | ||||||||||
| 67 | ( | ||||||||||
| 68 | $self->_full_mcxdeblast_exec, '-m9', '--score='.$self->_score, | ||||||||||
| 69 | '--line-mode=abc', $self->blast_results, '2> /dev/null', | ||||||||||
| 70 | '|', $self->mcl_exec, '-', '--abc', | ||||||||||
| 71 | '-I', $self->inflation_value, '-o', $self->output_file, | ||||||||||
| 72 | $self->_logging | ||||||||||
| 73 | ) | ||||||||||
| 74 | ); | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 2 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 78 | 2 | my ($self) = @_; | |||||||||
| 79 | 2 | my @commands_to_run; | |||||||||
| 80 | 2 | push(@commands_to_run, $self->_command_to_run ); | |||||||||
| 81 | 1 | $self->logger->info( "Running command: " . $self->_command_to_run() ); | |||||||||
| 82 | 1 | 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 ); | |||||||||
| 83 | 1 | $job_runner_obj->run(); | |||||||||
| 84 | |||||||||||
| 85 | 1 | 1; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 2 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 89 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 90 | 2 | 1; | |||||||||
| 91 | |||||||||||
| 92 | __END__ | ||||||||||