Bio-MUST-Drivers

 view release on metacpan or  search on metacpan

lib/Bio/MUST/Drivers/Blast/Database/Temporary.pm  view on Meta::CPAN

package Bio::MUST::Drivers::Blast::Database::Temporary;
# ABSTRACT: Internal class for BLAST driver
$Bio::MUST::Drivers::Blast::Database::Temporary::VERSION = '0.252830';
use Moose;
use namespace::autoclean;

use autodie;
use feature qw(say);

use Smart::Comments '###';

use Carp;
use IPC::System::Simple qw(system);
use Module::Runtime qw(use_module);
use Path::Class qw(file);

extends 'Bio::MUST::Core::Ali::Temporary';

with 'Bio::MUST::Drivers::Roles::Blastable';


## no critic (ProhibitUnusedPrivateSubroutines)

# overload Ali::Temporary default builder
# Note: an id prefix longer than 3 letters is needed to avoid casing issues
# when building BLAST databases (e.g., seq1234 is left untouched but seq12345
# becomes SEQ12345, which prevents restore_ids to work properly).
sub _build_args {
    return { clean => 1, degap => 1, id_prefix => 'temp' };
}

## use critic

# overload equivalent attribute in plain Database
sub remote {
    return 0;
}

sub BUILD {
    my $self = shift;

    # provision executable
    my $app = use_module('Bio::MUST::Provision::Blast')->new;
       $app->meet();

    my $in = $self->filename;
    my $dbtype = $self->type;

    # TODO: modify all drivers to print the native errors for easy debugging
    # create makeblastdb command
    # -parse_seqids now required for blastdbcmd to work (side effects?)
    my $pgm = file($ENV{BMD_BLAST_BINDIR}, 'makeblastdb');
    my $cmd = "$pgm -in $in -dbtype $dbtype -parse_seqids"
        . ' > /dev/null 2> /dev/null';
    #### $cmd

    # try to robustly execute makeblastdb
    my $ret_code = system( [ 0, 127 ], $cmd);
    if ($ret_code == 127) {
        # TODO: do something to abort construction
        carp "[BMD] Warning: cannot execute $pgm command; returning!";
        return;
    }

    return;



( run in 2.490 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )