File Coverage

lib/Bio/MLST/Blast/Database.pm
Criterion Covered Total %
statement 15 20 75.0
branch n/a
condition n/a
subroutine 5 6 83.3
pod n/a
total 20 26 76.9


line stmt bran cond sub pod time code
1             package Bio::MLST::Blast::Database;
2             # ABSTRACT: Wrapper around NCBIs makeblastdb command
3             $Bio::MLST::Blast::Database::VERSION = '2.1.1706216';
4              
5              
6             package Bio::MLST::Blast::Database;
7 13     13   237835 use Moose;
  13         588186  
  13         91  
8 13     13   61854 use File::Temp;
  13         13  
  13         840  
9 13     13   1457 use Bio::MLST::Types;
  13         16  
  13         306  
10 13     13   50 use Cwd;
  13         15  
  13         2286  
11              
12             # input variables
13             has 'fasta_file' => ( is => 'ro', isa => 'Str', required => 1 );
14             has 'exec' => ( is => 'ro', isa => 'Bio::MLST::Executable', default => 'makeblastdb' );
15              
16             # Generated
17             has '_working_directory' => ( is => 'ro', isa => 'File::Temp::Dir', default => sub { File::Temp->newdir(DIR => getcwd, CLEANUP => 1); });
18             has 'location' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_location' );
19              
20             sub _build_location
21             {
22 0     0     my($self) = @_;
23              
24 0           my $output_database = join('/',($self->_working_directory->dirname(),'output_contigs'));
25 0           my $makeblastdb_cmd = join(" ",($self->exec, '-in', $self->fasta_file, '-dbtype nucl', '-parse_seqids', '-out', $output_database));
26             # FIXME: run this command in a more sensible fashion
27 0           `$makeblastdb_cmd`;
28 0           return $output_database;
29             }
30              
31 13     13   57 no Moose;
  13         13  
  13         59  
32             __PACKAGE__->meta->make_immutable;
33             1;
34              
35             __END__
36              
37             =pod
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             Bio::MLST::Blast::Database - Wrapper around NCBIs makeblastdb command
44              
45             =head1 VERSION
46              
47             version 2.1.1706216
48              
49             =head1 SYNOPSIS
50              
51             Take in a fasta file and create a temporary blast database.
52              
53             use Bio::MLST::Blast::Database;
54            
55             my $blast_database= Bio::MLST::Blast::Database->new(
56             fasta_file => 'contigs.fa',
57             exec => 'makeblastdb'
58             );
59            
60             $blast_database->location();
61              
62             =head1 METHODS
63              
64             =head2 location
65              
66             Returns the path to the temporary blast database files
67              
68             =head1 SEE ALSO
69              
70             =over 4
71              
72             =item *
73              
74             L<Bio::MLST::Blast::BlastN>
75              
76             =back
77              
78             =head1 AUTHOR
79              
80             Andrew J. Page <ap13@sanger.ac.uk>
81              
82             =head1 COPYRIGHT AND LICENSE
83              
84             This software is Copyright (c) 2012 by Wellcome Trust Sanger Institute.
85              
86             This is free software, licensed under:
87              
88             The GNU General Public License, Version 3, June 2007
89              
90             =cut