Skip to content

Commit

Permalink
Merge pull request #256 from andrewjpage/speed_up_alignments
Browse files Browse the repository at this point in the history
Speed up alignments
  • Loading branch information
andrewjpage committed Jul 1, 2016
2 parents 83faa7f + 195462f commit 684c726
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/Bio/Roary.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sub run {
unlink($output_blast_results_filename) unless($self->dont_delete_files == 1);

my $post_analysis = Bio::Roary::External::PostAnalysis->new(
job_runner => $self->job_runner,
job_runner => 'Local',
cpus => $self->cpus,
fasta_files => $self->fasta_files,
input_files => $self->input_files,
Expand Down
2 changes: 1 addition & 1 deletion lib/Bio/Roary/CommandLine/RoaryPostAnalysis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ sub run {
}
else
{
$job_runner_to_use = 'Local';
$job_runner_to_use = 'Parallel';
}

my $output_gene_files = $self->_find_input_files;
Expand Down
12 changes: 2 additions & 10 deletions lib/Bio/Roary/External/GeneAlignmentFromNucleotides.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ has 'mafft' => ( is => 'ro', isa => 'Bool', default =>
has 'dont_delete_files' => ( is => 'rw', isa => 'Bool', default => 0 );
has 'num_input_files' => ( is => 'ro', isa => 'Int', required => 1);

# Overload Role
# Overload Role`
has 'memory_in_mb' => ( is => 'rw', isa => 'Int', lazy => 1, builder => '_build_memory_in_mb' );
has '_min_memory_in_mb' => ( is => 'ro', isa => 'Int', default => 1500 );
has '_max_memory_in_mb' => ( is => 'ro', isa => 'Int', default => 60000 );
Expand All @@ -43,15 +43,7 @@ has '_dependancy_memory_in_mb' => ( is => 'ro', isa => 'Int', default => 15000
sub _build__files_per_chunk
{
my ($self) = @_;
if($self->num_input_files > 1000)
{
return 5;
}
elsif($self->num_input_files > 500)
{
return 7;
}
return 10;
return 1;
}

sub _build_memory_in_mb {
Expand Down
12 changes: 9 additions & 3 deletions lib/Bio/Roary/JobRunner/Parallel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package Bio::Roary::JobRunner::Parallel;
use Moose;
use File::Temp qw/ tempfile /;
use Log::Log4perl qw(:easy);
use File::Slurper 'write_text';
use File::Temp qw/ tempfile /;

has 'commands_to_run' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
has 'cpus' => ( is => 'ro', isa => 'Int', default => 1 );
Expand All @@ -28,13 +30,17 @@ has 'memory_in_mb' => ( is => 'rw', isa => 'Int', default => '200' );
sub run {
my ($self) = @_;

my($fh, $temp_command_filename) = tempfile();
write_text($temp_command_filename, join("\n", @{ $self->commands_to_run }) );

for my $command_to_run(@{ $self->commands_to_run })
{
$self->logger->info($command_to_run);
}
open(my $fh,"|-","parallel --gnu -j ".$self->cpus) || die "GNU Parallel failed";
print $fh join("\n", @{ $self->commands_to_run });
close $fh;
my $parallel_command = "parallel --gnu -j ".$self->cpus." < ".$temp_command_filename ;
$self->logger->info($parallel_command );

system($parallel_command);
1;
}

Expand Down

0 comments on commit 684c726

Please sign in to comment.