File Coverage

blib/lib/Bio/MUST/Drivers/Blast/Database.pm
Criterion Covered Total %
statement 15 23 65.2
branch 0 6 0.0
condition 0 6 0.0
subroutine 5 6 83.3
pod 0 1 0.0
total 20 42 47.6


line stmt bran cond sub pod time code
1             package Bio::MUST::Drivers::Blast::Database;
2             # ABSTRACT: Internal class for BLAST driver
3             $Bio::MUST::Drivers::Blast::Database::VERSION = '0.191910';
4 5     5   41 use Moose;
  5         12  
  5         45  
5 5     5   38365 use namespace::autoclean;
  5         14  
  5         63  
6              
7 5     5   525 use autodie;
  5         22  
  5         53  
8 5     5   28747 use feature qw(say);
  5         16  
  5         540  
9              
10 5     5   39 use Carp;
  5         10  
  5         1970  
11              
12             extends 'Bio::FastParsers::Base';
13              
14             # TODO: warn user that we need to build db with -parse_seqids
15              
16             has 'type' => (
17             is => 'ro',
18             isa => 'Str',
19             init_arg => undef,
20             writer => '_set_type',
21             );
22              
23             has 'remote' => (
24             is => 'ro',
25             isa => 'Bool',
26             default => 0,
27             );
28              
29             with 'Bio::MUST::Drivers::Roles::Blastable';
30              
31             # TODO: complete this with list of NCBI databases
32             # http://ncbiinsights.ncbi.nlm.nih.gov/2013/03/19/\
33             # blastdbinfo-api-access-to-a-database-of-blast-databases/
34             my %type_for = ( # cannot be made constant to allow undefined keys
35             nt => 'nucl',
36             nr => 'prot',
37             );
38              
39             sub BUILD {
40 0     0 0   my $self = shift;
41              
42 0           my $basename = $self->filename;
43              
44             # check for existence of BLAST database and set its type (nucl or prot)
45 0 0 0       if ($self->remote) {
    0 0        
    0          
46 0           $self->_set_type( $type_for{$basename} );
47             }
48             elsif (-e "$basename.psq" || -e "$basename.pal") {
49 0           $self->_set_type('prot');
50             }
51             elsif (-e "$basename.nsq" || -e "$basename.nal") {
52 0           $self->_set_type('nucl');
53             }
54             else {
55 0           croak "[BMD] Error: BLAST database not found at $basename; aborting!";
56             }
57              
58 0           return;
59             }
60              
61             __PACKAGE__->meta->make_immutable;
62             1;
63              
64             __END__
65              
66             =pod
67              
68             =head1 NAME
69              
70             Bio::MUST::Drivers::Blast::Database - Internal class for BLAST driver
71              
72             =head1 VERSION
73              
74             version 0.191910
75              
76             =head1 SYNOPSIS
77              
78             # TODO
79              
80             =head1 DESCRIPTION
81              
82             # TODO
83              
84             =head1 AUTHOR
85              
86             Denis BAURAIN <denis.baurain@uliege.be>
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN.
91              
92             This is free software; you can redistribute it and/or modify it under
93             the same terms as the Perl 5 programming language system itself.
94              
95             =cut