File Coverage

lib/Bio/Roary/External/Blastp.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 16 17 94.1


line stmt bran cond sub pod time code
1             package Bio::Roary::External::Blastp;
2             $Bio::Roary::External::Blastp::VERSION = '3.11.0';
3             # ABSTRACT: Wrapper around NCBIs blastp command
4              
5              
6 4     4   70540 use Moose;
  4         6  
  4         33  
7             with 'Bio::Roary::JobRunner::Role';
8              
9             has 'fasta_file' => ( is => 'ro', isa => 'Str', required => 1 );
10             has 'blast_database' => ( is => 'ro', isa => 'Str', required => 1 );
11             has 'exec' => ( is => 'ro', isa => 'Str', default => 'blastp' );
12             has '_evalue' => ( is => 'ro', isa => 'Num', default => 1E-6 );
13             has '_num_threads' => ( is => 'ro', isa => 'Int', default => 1 );
14             has '_max_target_seqs' => ( is => 'ro', isa => 'Int', default => 2000 );
15             has '_logging' => ( is => 'ro', isa => 'Str', default => '2> /dev/null' );
16             has 'output_file' => ( is => 'ro', isa => 'Str', default => 'results.out' );
17             has 'perc_identity' => ( is => 'ro', isa => 'Num', default => 98 );
18              
19             sub _command_to_run {
20 9     9   22 my ($self) = @_;
21 9         232 return join(
22             " ",
23             (
24             $self->exec,
25             '-query', $self->fasta_file,
26             '-db', $self->blast_database,
27             '-evalue', $self->_evalue,
28             '-num_threads', $self->_num_threads,
29             '-outfmt 6',
30             '-max_target_seqs', $self->_max_target_seqs,
31             ' | awk \'{ if ($3 > '.$self->perc_identity.') print $0;}\'',
32             $self->_logging, '1> ', $self->output_file,
33             )
34            
35            
36             );
37             }
38              
39             sub run {
40 1     1 0 2 my ($self) = @_;
41 1         25 $self->logger->info( "Running command: " . $self->_command_to_run() );
42 1         9 system( $self->_command_to_run );
43 1         67 1;
44             }
45              
46 4     4   24003 no Moose;
  4         9  
  4         36  
47             __PACKAGE__->meta->make_immutable;
48             1;
49              
50             __END__
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             Bio::Roary::External::Blastp - Wrapper around NCBIs blastp command
59              
60             =head1 VERSION
61              
62             version 3.11.0
63              
64             =head1 SYNOPSIS
65              
66             Wrapper around NCBIs blastp command
67              
68             use Bio::Roary::External::Blastp;
69            
70             my $blast_database= Bio::Roary::External::Blastp->new(
71             fasta_file => 'contigs.fa',
72             blast_database => 'db',
73             exec => 'blastp',
74             output_file => 'results.out'
75             );
76            
77             $blast_database->run();
78              
79             =head1 METHODS
80              
81             =head2 result_file
82              
83             Returns the path to the results file
84              
85             =head1 AUTHOR
86              
87             Andrew J. Page <ap13@sanger.ac.uk>
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
92              
93             This is free software, licensed under:
94              
95             The GNU General Public License, Version 3, June 2007
96              
97             =cut