| 1 | 1 | undef $VERSION; | |||||||||
| 2 | package Bio::Roary::CommandLine::ParallelAllAgainstAllBlastp; | ||||||||||
| 3 | 1 | $Bio::Roary::CommandLine::ParallelAllAgainstAllBlastp::VERSION = '3.13.0'; | |||||||||
| 4 | # ABSTRACT: Take in a FASTA file of proteins and blast against itself | ||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Bio::Roary::ParallelAllAgainstAllBlast; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Bio::Roary::CombinedProteome; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Bio::Roary::PrepareInputFiles; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | extends 'Bio::Roary::CommandLine::Common'; | |||||||||
| 13 | |||||||||||
| 14 | 1 | has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | |||||||||
| 15 | 1 | has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 16 | 1 | has 'help' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||
| 17 | |||||||||||
| 18 | 1 | has 'fasta_files' => ( is => 'rw', isa => 'ArrayRef' ); | |||||||||
| 19 | 1 | has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'blast_results' ); | |||||||||
| 20 | 1 | has 'job_runner' => ( is => 'rw', isa => 'Str', default => 'Local' ); | |||||||||
| 21 | 1 | has 'cpus' => ( is => 'rw', isa => 'Int', default => 1 ); | |||||||||
| 22 | 1 | has 'makeblastdb_exec' => ( is => 'rw', isa => 'Str', default => 'makeblastdb' ); | |||||||||
| 23 | 1 | has 'blastp_exec' => ( is => 'rw', isa => 'Str', default => 'blastp' ); | |||||||||
| 24 | 1 | has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||
| 25 | |||||||||||
| 26 | 1 | has '_error_message' => ( is => 'rw', isa => 'Str' ); | |||||||||
| 27 | |||||||||||
| 28 | 3 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=12 SCAR=25.9
Pod
undocumented
| |||||||||||
| 29 | 3 | my ($self) = @_; | |||||||||
| 30 | |||||||||||
| 31 | 3 | my ( $fasta_files, $output_filename, $job_runner, $makeblastdb_exec, $blastp_exec, $help, $cpus, $verbose, ); | |||||||||
| 32 | |||||||||||
| 33 | 3 | GetOptionsFromArray( | |||||||||
| 34 | $self->args, | ||||||||||
| 35 | 'o|output=s' => \$output_filename, | ||||||||||
| 36 | 'j|job_runner=s' => \$job_runner, | ||||||||||
| 37 | 'm|makeblastdb_exec=s' => \$makeblastdb_exec, | ||||||||||
| 38 | 'b|blastp_exec=s' => \$blastp_exec, | ||||||||||
| 39 | 'p|processors=i' => \$cpus, | ||||||||||
| 40 | 'v|verbose' => \$verbose, | ||||||||||
| 41 | 'h|help' => \$help, | ||||||||||
| 42 | ); | ||||||||||
| 43 | |||||||||||
| 44 | 3 | ▶ | if ( @{ $self->args } == 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 1 | $self->_error_message("Error: You need to provide a FASTA file"); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 3 | ▶ | if ( defined($verbose) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | $self->verbose($verbose); | |||||||||
| 50 | 0 | $self->logger->level(10000); | |||||||||
| 51 | } | ||||||||||
| 52 | 3 | ▶ | $self->help($help) if(defined($help)); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 3 | ▶ | $self->output_filename($output_filename) if ( defined($output_filename) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 3 | ▶ | $self->makeblastdb_exec($makeblastdb_exec) if ( defined($makeblastdb_exec) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 3 | ▶ | $self->blastp_exec($blastp_exec) if ( defined($blastp_exec) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 3 | ▶ | $self->job_runner($job_runner) if ( defined($job_runner) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 3 | ▶ | $self->cpus($cpus) if ( defined($cpus) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 3 | ▶ | if ( $self->cpus > 1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | $self->job_runner('Parallel'); | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 3 | for my $filename ( @{ $self->args } ) { | |||||||||
| 63 | 2 | ▶ | if ( !-e $filename ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | $self->_error_message("Error: Cant access file $filename"); | |||||||||
| 65 | 0 | last; | |||||||||
| 66 | } | ||||||||||
| 67 | } | ||||||||||
| 68 | 3 | $self->fasta_files( $self->args ); | |||||||||
| 69 | |||||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 3 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=4 SCAR=15.4
Pod
undocumented
| |||||||||||
| 73 | 3 | my ($self) = @_; | |||||||||
| 74 | |||||||||||
| 75 | 3 | ▶ | ( !$self->help ) or die $self->usage_text; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 2 | ▶ | if ( defined( $self->_error_message ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | 0 | print $self->_error_message . "\n"; | |||||||||
| 78 | 0 | die $self->usage_text; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 2 | my $prepare_input_files = Bio::Roary::PrepareInputFiles->new( | |||||||||
| 82 | input_files => $self->fasta_files, | ||||||||||
| 83 | ); | ||||||||||
| 84 | |||||||||||
| 85 | 2 | my $output_combined_filename; | |||||||||
| 86 | 2 | ▶ | if(@{$self->fasta_files} > 1) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | { | ||||||||||
| 88 | 0 | $output_combined_filename = 'combined_files.fa'; | |||||||||
| 89 | 0 | $self->logger->info("Combining protein files"); | |||||||||
| 90 | 0 | my $combine_fasta_files = Bio::Roary::CombinedProteome->new( | |||||||||
| 91 | proteome_files => $prepare_input_files->fasta_files, | ||||||||||
| 92 | output_filename => $output_combined_filename, | ||||||||||
| 93 | maximum_percentage_of_unknowns => 5.0, | ||||||||||
| 94 | apply_unknowns_filter => 0 | ||||||||||
| 95 | ); | ||||||||||
| 96 | 0 | $combine_fasta_files->create_combined_proteome_file; | |||||||||
| 97 | } | ||||||||||
| 98 | else | ||||||||||
| 99 | { | ||||||||||
| 100 | 2 | $output_combined_filename = $self->fasta_files->[0]; | |||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | 2 | $self->logger->info("Beginning all against all blast"); | |||||||||
| 104 | 2 | my $blast_obj = Bio::Roary::ParallelAllAgainstAllBlast->new( | |||||||||
| 105 | fasta_file => $output_combined_filename, | ||||||||||
| 106 | blast_results_file_name => $self->output_filename, | ||||||||||
| 107 | job_runner => $self->job_runner, | ||||||||||
| 108 | cpus => $self->cpus, | ||||||||||
| 109 | makeblastdb_exec => $self->makeblastdb_exec, | ||||||||||
| 110 | blastp_exec => $self->blastp_exec, | ||||||||||
| 111 | logger => $self->logger | ||||||||||
| 112 | ); | ||||||||||
| 113 | 2 | $blast_obj->run(); | |||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | 1 | ▶ | sub usage_text { | ||||||||
|
Subroutine
usage_text: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 117 | 1 | my ($self) = @_; | |||||||||
| 118 | |||||||||||
| 119 | 1 | return <<USAGE; | |||||||||
| 120 | Usage: parallel_all_against_all_blastp [options] file.faa | ||||||||||
| 121 | Take in a FASTA file of proteins and blast against itself | ||||||||||
| 122 | |||||||||||
| 123 | Options: -p INT number of threads [1] | ||||||||||
| 124 | -o STR output filename for blast results [blast_results] | ||||||||||
| 125 | -m STR makeblastdb executable [makeblastdb] | ||||||||||
| 126 | -b STR blastp executable [blastp] | ||||||||||
| 127 | -v verbose output to STDOUT | ||||||||||
| 128 | -h this help message | ||||||||||
| 129 | |||||||||||
| 130 | For further info see: http://sanger-pathogens.github.io/Roary/ | ||||||||||
| 131 | USAGE | ||||||||||
| 132 | } | ||||||||||
| 133 | |||||||||||
| 134 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 135 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 136 | 1 | 1; | |||||||||
| 137 | |||||||||||
| 138 | __END__ | ||||||||||