File Coverage

lib/Bio/Roary/External/Makeblastdb.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Bio::Roary::External::Makeblastdb;
2             $Bio::Roary::External::Makeblastdb::VERSION = '3.10.2';
3             # ABSTRACT: Wrapper around NCBIs makeblastdb command
4              
5              
6 5     5   388411 use Moose;
  5         1267024  
  5         38  
7 5     5   35575 use File::Temp;
  5         27619  
  5         356  
8 5     5   30 use Cwd;
  5         9  
  5         1453  
9             with 'Bio::Roary::JobRunner::Role';
10              
11             has 'fasta_file' => ( is => 'ro', isa => 'Str', required => 1 );
12             has 'exec' => ( is => 'ro', isa => 'Str', default => 'makeblastdb' );
13             has '_working_directory' => ( is => 'ro', isa => 'File::Temp::Dir', default => sub { File::Temp->newdir( DIR => getcwd, CLEANUP => 1 ); } );
14             has '_dbtype' => ( is => 'ro', isa => 'Str', default => 'prot' );
15             has '_logfile' => ( is => 'ro', isa => 'Str', default => '/dev/null' );
16             has 'output_database' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_database' );
17              
18             # Overload Role
19             has 'memory_in_mb' => ( is => 'ro', isa => 'Int', default => 4000);
20              
21             sub _build_output_database {
22 4     4   12 my ($self) = @_;
23 4         116 return join( '/', ( $self->_working_directory->dirname(), 'output_contigs' ) );
24             }
25              
26             sub _command_to_run {
27 9     9   28 my ($self) = @_;
28 9         265 return join(
29             " ",
30             (
31             $self->exec,
32             '-in', $self->fasta_file,
33             '-dbtype', $self->_dbtype,
34             '-out', $self->output_database,
35             '-logfile', $self->_logfile
36             )
37             );
38             }
39              
40             sub run {
41 4     4 0 785 my ($self) = @_;
42 4         8 my @commands_to_run;
43 4         14 push(@commands_to_run, $self->_command_to_run );
44 4         123 $self->logger->info( "Running command: " . $self->_command_to_run() );
45 4         141 my $job_runner_obj = $self->_job_runner_class->new( commands_to_run => \@commands_to_run, memory_in_mb => $self->memory_in_mb, queue => $self->_queue, cpus => $self->cpus );
46 4         23 $job_runner_obj->run();
47            
48 4         595 1;
49             }
50              
51 5     5   39 no Moose;
  5         9  
  5         33  
52             __PACKAGE__->meta->make_immutable;
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Bio::Roary::External::Makeblastdb - Wrapper around NCBIs makeblastdb command
64              
65             =head1 VERSION
66              
67             version 3.10.2
68              
69             =head1 SYNOPSIS
70              
71             Take in a fasta file and create a temporary blast database.
72              
73             use Bio::Roary::External::Makeblastdb;
74            
75             my $blast_database= Bio::Roary::External::Makeblastdb->new(
76             fasta_file => 'contigs.fa',
77             exec => 'makeblastdb'
78             );
79            
80             $blast_database->run();
81              
82             =head1 METHODS
83              
84             =head2 output_database
85              
86             Returns the path to the temporary blast database files
87              
88             =head1 AUTHOR
89              
90             Andrew J. Page <ap13@sanger.ac.uk>
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
95              
96             This is free software, licensed under:
97              
98             The GNU General Public License, Version 3, June 2007
99              
100             =cut