| 1 | package Bio::MUST::Drivers::Blast::Database::Temporary; | ||||||||||
| 2 | # ABSTRACT: Internal class for BLAST driver | ||||||||||
| 3 | 5 | $Bio::MUST::Drivers::Blast::Database::Temporary::VERSION = '0.252830'; | |||||||||
| 4 | 5 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 5 | ▶ | use autodie; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 5 | ▶ | use feature qw(say); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 5 | ▶ | use Smart::Comments '###'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 5 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 5 | ▶ | use IPC::System::Simple qw(system); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 5 | ▶ | use Module::Runtime qw(use_module); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 5 | ▶ | use Path::Class qw(file); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 5 | extends 'Bio::MUST::Core::Ali::Temporary'; | |||||||||
| 18 | |||||||||||
| 19 | 5 | with 'Bio::MUST::Drivers::Roles::Blastable'; | |||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||
| 23 | |||||||||||
| 24 | # overload Ali::Temporary default builder | ||||||||||
| 25 | # Note: an id prefix longer than 3 letters is needed to avoid casing issues | ||||||||||
| 26 | # when building BLAST databases (e.g., seq1234 is left untouched but seq12345 | ||||||||||
| 27 | # becomes SEQ12345, which prevents restore_ids to work properly). | ||||||||||
| 28 | 0 | ▶ | sub _build_args { | ||||||||
|
Subroutine
_build_args: not called CC=1 SCAR=6.9
| |||||||||||
| 29 | 0 | return { clean => 1, degap => 1, id_prefix => 'temp' }; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | ## use critic | ||||||||||
| 33 | |||||||||||
| 34 | # overload equivalent attribute in plain Database | ||||||||||
| 35 | 0 | ▶ | sub remote { | ||||||||
|
Subroutine
remote: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 36 | 0 | return 0; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 40 | 0 | my $self = shift; | |||||||||
| 41 | |||||||||||
| 42 | # provision executable | ||||||||||
| 43 | 0 | my $app = use_module('Bio::MUST::Provision::Blast')->new; | |||||||||
| 44 | 0 | $app->meet(); | |||||||||
| 45 | |||||||||||
| 46 | 0 | my $in = $self->filename; | |||||||||
| 47 | 0 | my $dbtype = $self->type; | |||||||||
| 48 | |||||||||||
| 49 | # TODO: modify all drivers to print the native errors for easy debugging | ||||||||||
| 50 | # create makeblastdb command | ||||||||||
| 51 | # -parse_seqids now required for blastdbcmd to work (side effects?) | ||||||||||
| 52 | 0 | my $pgm = file($ENV{BMD_BLAST_BINDIR}, 'makeblastdb'); | |||||||||
| 53 | 0 | my $cmd = "$pgm -in $in -dbtype $dbtype -parse_seqids" | |||||||||
| 54 | . ' > /dev/null 2> /dev/null'; | ||||||||||
| 55 | #### $cmd | ||||||||||
| 56 | |||||||||||
| 57 | # try to robustly execute makeblastdb | ||||||||||
| 58 | 0 | my $ret_code = system( [ 0, 127 ], $cmd); | |||||||||
| 59 | 0 | ▶ | if ($ret_code == 127) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | # TODO: do something to abort construction | ||||||||||
| 61 | 0 | carp "[BMD] Warning: cannot execute $pgm command; returning!"; | |||||||||
| 62 | 0 | return; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 0 | return; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub DEMOLISH { | ||||||||
|
Subroutine
DEMOLISH: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 69 | 0 | my $self = shift; | |||||||||
| 70 | |||||||||||
| 71 | # updated with ChatGPT in Sept 2024 | ||||||||||
| 72 | # The following is valid for BLAST 2.16.0: | ||||||||||
| 73 | # Core Nucleotide Database Files: | ||||||||||
| 74 | # - .ndb – Nucleotide database file: Contains the actual nucleotide sequences. | ||||||||||
| 75 | # - .nhr – Nucleotide header file: Stores sequence descriptions and identifiers (like the protein .phr file). | ||||||||||
| 76 | # - .nin – Nucleotide index file: Contains indexing information for fast lookup (analogous to the .pin file for proteins). | ||||||||||
| 77 | # - .nsq – Nucleotide sequence file: Holds the nucleotide sequences in a compact format for efficient searching (similar to the .psq file for proteins). | ||||||||||
| 78 | # Partitioning and Multi-threading Support Files (Nucleotide Version): | ||||||||||
| 79 | # - .nog – Group partition index file: Manages partitioned groups of nucleotide sequences. | ||||||||||
| 80 | # - .not – Partition offset table: Contains offsets for different partitions within the nucleotide database. | ||||||||||
| 81 | # - .ntf – Partition table file: The reference table for nucleotide database partitions. | ||||||||||
| 82 | # - .nto – Partition offset file: Holds the positions of nucleotide partitions. | ||||||||||
| 83 | # Metadata and Optimization Files: | ||||||||||
| 84 | # - .njs – Nucleotide JSON schema file: Similar to the .pjs file in protein databases, it contains metadata in JSON format about the nucleotide database. | ||||||||||
| 85 | # - .nos – Nucleotide offset file: Similar to .pos, it stores sequence offsets for optimized retrieval. | ||||||||||
| 86 | |||||||||||
| 87 | # unlink temp files | ||||||||||
| 88 | 0 | ▶ | my @suffices = map { ( $self->type eq 'prot' ? 'p' : 'n' ) . $_ } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | qw(db hr in sq og ot tf to js os); | ||||||||||
| 90 | 0 | my $basename = $self->filename; | |||||||||
| 91 | #### $basename | ||||||||||
| 92 | 0 | file($_)->remove for map { "$basename.$_" } @suffices; | |||||||||
| 93 | |||||||||||
| 94 | 0 | return; | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||
| 98 | 5 | 1; | |||||||||
| 99 | |||||||||||
| 100 | __END__ | ||||||||||