-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from andrewjpage/master
run post analysis as a job
- Loading branch information
Showing
8 changed files
with
345 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env perl | ||
|
||
package Bio::PanGenome::Main::PanGenomePostAnalysis; | ||
|
||
# ABSTRACT: Perform the post analysis on the pan genome | ||
# PODNAME: pan_genome_post_analysis | ||
|
||
=head1 SYNOPSIS | ||
Perform the post analysis on the pan genome | ||
=cut | ||
|
||
BEGIN { unshift( @INC, '../lib' ) } | ||
BEGIN { unshift( @INC, './lib' ) } | ||
BEGIN { unshift( @INC, '/software/pathogen/internal/prod/lib/' ) } | ||
use Bio::PanGenome::CommandLine::PanGenomePostAnalysis; | ||
|
||
Bio::PanGenome::CommandLine::PanGenomePostAnalysis->new(args => \@ARGV, script_name => $0)->run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package Bio::PanGenome::CommandLine::PanGenomePostAnalysis; | ||
|
||
# ABSTRACT: Perform the post analysis on the pan genome | ||
|
||
=head1 SYNOPSIS | ||
Perform the post analysis on the pan genome | ||
=cut | ||
|
||
use Moose; | ||
use Getopt::Long qw(GetOptionsFromArray); | ||
use Bio::PanGenome::PostAnalysis; | ||
|
||
|
||
has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | ||
has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
has 'help' => ( is => 'rw', isa => 'Bool', default => 0 ); | ||
has '_error_message' => ( is => 'rw', isa => 'Str' ); | ||
|
||
has 'fasta_files' => ( is => 'rw', isa => 'ArrayRef' ); | ||
has 'input_files' => ( is => 'rw', isa => 'ArrayRef'); | ||
has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'clustered_proteins' ); | ||
has 'output_pan_geneome_filename' => ( is => 'rw', isa => 'Str', default => 'pan_genome.fa' ); | ||
has 'output_statistics_filename' => ( is => 'rw', isa => 'Str', default => 'group_statisics.csv' ); | ||
has 'output_multifasta_files' => ( is => 'rw', isa => 'Bool', default => 0 ); | ||
has 'clusters_filename' => ( is => 'rw', isa => 'Str' ); | ||
has 'job_runner' => ( is => 'rw', isa => 'Str', default => 'LSF' ); | ||
|
||
sub BUILD { | ||
my ($self) = @_; | ||
|
||
my ( $output_filename, $output_pan_geneome_filename, $job_runner, $output_statistics_filename, $output_multifasta_files, $clusters_filename, $fasta_files, $input_files, $help ); | ||
|
||
GetOptionsFromArray( | ||
$self->args, | ||
'o|output=s' => \$output_filename, | ||
'j|job_runner=s' => \$job_runner, | ||
'output_multifasta_files' => \$output_multifasta_files, | ||
'p=s' => \$output_pan_geneome_filename, | ||
's=s' => \$output_statistics_filename, | ||
'c=s' => \$clusters_filename, | ||
'f=s@' => \$fasta_files, | ||
'i=s@' => \$input_files, | ||
'h|help' => \$help, | ||
); | ||
|
||
$self->job_runner($job_runner) if ( defined($job_runner) ); | ||
$self->fasta_files($fasta_files) if (defined($fasta_files)); | ||
$self->input_files($input_files) if (defined($input_files)); | ||
$self->output_filename($output_filename) if (defined($output_filename)); | ||
$self->output_pan_geneome_filename($output_pan_geneome_filename) if (defined($output_pan_geneome_filename)); | ||
$self->output_statistics_filename($output_statistics_filename) if (defined($output_statistics_filename)); | ||
$self->output_multifasta_files($output_multifasta_files) if (defined($output_multifasta_files)); | ||
$self->clusters_filename($clusters_filename) if (defined($clusters_filename)); | ||
|
||
} | ||
|
||
sub run { | ||
my ($self) = @_; | ||
|
||
( !$self->help ) or die $self->usage_text; | ||
if ( defined( $self->_error_message ) ) { | ||
print $self->_error_message . "\n"; | ||
die $self->usage_text; | ||
} | ||
|
||
my $obj = Bio::PanGenome::PostAnalysis->new( | ||
fasta_files => $self->fasta_files , | ||
input_files => $self->input_files , | ||
output_filename => $self->output_filename , | ||
output_pan_geneome_filename => $self->output_pan_geneome_filename, | ||
output_statistics_filename => $self->output_statistics_filename , | ||
output_multifasta_files => $self->output_multifasta_files , | ||
clusters_filename => $self->clusters_filename , | ||
); | ||
$obj->run(); | ||
} | ||
|
||
sub usage_text { | ||
my ($self) = @_; | ||
|
||
return <<USAGE; | ||
Usage: pan_genome_post_analysis [options] | ||
Perform the post analysis on the pan genome. This script is usally only called by another script. | ||
#Normal usage | ||
pan_genome_post_analysis | ||
-o output_groups_filename / | ||
-p output_pan_genome_filename / | ||
-s output_stats_filename / | ||
-c output_clusters_filename / | ||
-f proteins1.faa / | ||
-f proteins2.faa / | ||
-f proteins3.faa / | ||
-i annotation1.gff / | ||
-i annotation2.gff / | ||
# This help message | ||
pan_genome_post_analysis -h | ||
USAGE | ||
} | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
no Moose; | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package Bio::PanGenome::External::PostAnalysis; | ||
|
||
# ABSTRACT: Perform the post analysis | ||
|
||
=head1 SYNOPSIS | ||
Perform the post analysis | ||
use Bio::PanGenome::External::PostAnalysis; | ||
my $seg= Bio::PanGenome::External::PostAnalysis->new( | ||
fasta_file => 'contigs.fa', | ||
); | ||
$seg->run(); | ||
=cut | ||
|
||
use Moose; | ||
with 'Bio::PanGenome::JobRunner::Role'; | ||
|
||
has 'input_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | ||
has 'exec' => ( is => 'ro', isa => 'Str', default => 'pan_genome_post_analysis' ); | ||
has 'fasta_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | ||
has 'output_filename' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
has 'output_pan_geneome_filename' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
has 'output_statistics_filename' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
has 'clusters_filename' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
|
||
# Overload Role | ||
has '_memory_required_in_mb' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build__memory_required_in_mb' ); | ||
has '_minimum_memory_mb' => ( is => 'ro', isa => 'Int', default => 1000 ); | ||
has '_memory_per_sample_mb' => ( is => 'ro', isa => 'Int', default => 100 ); | ||
|
||
sub _build__memory_required_in_mb { | ||
my ($self) = @_; | ||
my $num_samples = @{ $self->input_files }; | ||
|
||
my $memory_required = $num_samples * $self->_memory_per_sample_mb; | ||
if ( $memory_required < $self->_minimum_memory_mb ) { | ||
$memory_required = $self->_minimum_memory_mb; | ||
} | ||
|
||
return $memory_required; | ||
} | ||
|
||
sub _command_to_run { | ||
my ($self) = @_; | ||
|
||
my $fasta_files_param = join(' -f ',@{$self->fasta_files}); | ||
$fasta_files_param = ' -f '.$fasta_files_param; | ||
|
||
my $input_files_param = join(' -i ',@{$self->input_files}); | ||
$input_files_param = ' -i '.$input_files_param; | ||
|
||
return join( | ||
" ", | ||
( | ||
$self->exec, | ||
'-o', $self->output_filename, | ||
'-p', $self->output_pan_geneome_filename, | ||
'-s', $self->output_statistics_filename, | ||
'-c', $self->clusters_filename, | ||
'--output_multifasta_files', | ||
$fasta_files_param, | ||
$input_files_param | ||
) | ||
); | ||
} | ||
|
||
sub run { | ||
my ($self) = @_; | ||
my @commands_to_run; | ||
push( @commands_to_run, $self->_command_to_run ); | ||
|
||
my $job_runner_obj = $self->_job_runner_class->new( | ||
commands_to_run => \@commands_to_run, | ||
memory_in_mb => $self->_memory_required_in_mb, | ||
queue => $self->_queue, | ||
dont_wait => $self->dont_wait, | ||
); | ||
$job_runner_obj->run(); | ||
|
||
1; | ||
} | ||
|
||
no Moose; | ||
__PACKAGE__->meta->make_immutable; | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.