File Coverage

lib/Bio/Roary/CommandLine/ParallelAllAgainstAllBlastp.pm
Criterion Covered Total %
statement 49 60 81.6
branch 20 26 76.9
condition n/a
subroutine 9 9 100.0
pod 0 3 0.0
total 78 98 79.5


line stmt bran cond sub pod time code
1             undef $VERSION;
2             package Bio::Roary::CommandLine::ParallelAllAgainstAllBlastp;
3             $Bio::Roary::CommandLine::ParallelAllAgainstAllBlastp::VERSION = '3.10.2';
4             # ABSTRACT: Take in a FASTA file of proteins and blast against itself
5              
6              
7 1     1   437378 use Moose;
  1         2  
  1         8  
8 1     1   6192 use Getopt::Long qw(GetOptionsFromArray);
  1         7663  
  1         6  
9 1     1   447 use Bio::Roary::ParallelAllAgainstAllBlast;
  1         4  
  1         38  
10 1     1   361 use Bio::Roary::CombinedProteome;
  1         3  
  1         30  
11 1     1   348 use Bio::Roary::PrepareInputFiles;
  1         3  
  1         525  
12             extends 'Bio::Roary::CommandLine::Common';
13              
14             has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
15             has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 );
16             has 'help' => ( is => 'rw', isa => 'Bool', default => 0 );
17              
18             has 'fasta_files' => ( is => 'rw', isa => 'ArrayRef' );
19             has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'blast_results' );
20             has 'job_runner' => ( is => 'rw', isa => 'Str', default => 'Local' );
21             has 'cpus' => ( is => 'rw', isa => 'Int', default => 1 );
22             has 'makeblastdb_exec' => ( is => 'rw', isa => 'Str', default => 'makeblastdb' );
23             has 'blastp_exec' => ( is => 'rw', isa => 'Str', default => 'blastp' );
24             has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
25              
26             has '_error_message' => ( is => 'rw', isa => 'Str' );
27              
28             sub BUILD {
29 3     3 0 11 my ($self) = @_;
30              
31 3         14 my ( $fasta_files, $output_filename, $job_runner, $makeblastdb_exec, $blastp_exec, $help, $cpus, $verbose, );
32              
33 3         147 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 100       2962 if ( @{ $self->args } == 0 ) {
  3         97  
45 1         31 $self->_error_message("Error: You need to provide a FASTA file");
46             }
47              
48 3 50       13 if ( defined($verbose) ) {
49 0         0 $self->verbose($verbose);
50 0         0 $self->logger->level(10000);
51             }
52 3 100       35 $self->help($help) if(defined($help));
53 3 100       41 $self->output_filename($output_filename) if ( defined($output_filename) );
54 3 100       85 $self->makeblastdb_exec($makeblastdb_exec) if ( defined($makeblastdb_exec) );
55 3 100       60 $self->blastp_exec($blastp_exec) if ( defined($blastp_exec) );
56 3 100       61 $self->job_runner($job_runner) if ( defined($job_runner) );
57 3 50       9 $self->cpus($cpus) if ( defined($cpus) );
58 3 50       103 if ( $self->cpus > 1 ) {
59 0         0 $self->job_runner('Parallel');
60             }
61              
62 3         6 for my $filename ( @{ $self->args } ) {
  3         80  
63 2 50       36 if ( !-e $filename ) {
64 0         0 $self->_error_message("Error: Cant access file $filename");
65 0         0 last;
66             }
67             }
68 3         90 $self->fasta_files( $self->args );
69              
70             }
71              
72             sub run {
73 3     3 0 15 my ($self) = @_;
74              
75 3 100       106 ( !$self->help ) or die $self->usage_text;
76 2 50       59 if ( defined( $self->_error_message ) ) {
77 0         0 print $self->_error_message . "\n";
78 0         0 die $self->usage_text;
79             }
80            
81 2         48 my $prepare_input_files = Bio::Roary::PrepareInputFiles->new(
82             input_files => $self->fasta_files,
83             );
84            
85 2         4 my $output_combined_filename;
86 2 50       4 if(@{$self->fasta_files} > 1)
  2         55  
87             {
88 0         0 $output_combined_filename = 'combined_files.fa';
89 0         0 $self->logger->info("Combining protein files");
90 0         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         0 $combine_fasta_files->create_combined_proteome_file;
97             }
98             else
99             {
100 2         48 $output_combined_filename = $self->fasta_files->[0];
101             }
102              
103 2         53 $self->logger->info("Beginning all against all blast");
104 2         95 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         34 $blast_obj->run();
114             }
115              
116             sub usage_text {
117 1     1 0 3 my ($self) = @_;
118              
119 1         16 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             __PACKAGE__->meta->make_immutable;
135 1     1   12 no Moose;
  1         3  
  1         10  
136             1;
137              
138             __END__
139              
140             =pod
141              
142             =encoding UTF-8
143              
144             =head1 NAME
145              
146             Bio::Roary::CommandLine::ParallelAllAgainstAllBlastp - Take in a FASTA file of proteins and blast against itself
147              
148             =head1 VERSION
149              
150             version 3.10.2
151              
152             =head1 SYNOPSIS
153              
154             Take in a FASTA file of proteins and blast against itself
155              
156             =head1 AUTHOR
157              
158             Andrew J. Page <ap13@sanger.ac.uk>
159              
160             =head1 COPYRIGHT AND LICENSE
161              
162             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
163              
164             This is free software, licensed under:
165              
166             The GNU General Public License, Version 3, June 2007
167              
168             =cut