Tools/Run/StandAloneBlastPlus.pm

filter: Statementstmt 8.4% 36 / 428 Branchbran 0.5% 1 / 200 Conditioncond 0.0% 0 / 68 MC/DCmcdc 0.0% 0 / 42 Subroutinesub 22.2% 10 / 45 Podpod 40.6% 13 / 32 totaltotal 7.3% 60 / 815 CC 132 SCAR 58.8
CC
132
Cov
5%
new
930.0
make_mask
600.0
_fastize
506.0
CRAP 358.3
« Tools/Run/StandAloneBlastPlus/BlastMethods.pm ↑ Summary Tools/Run/Vista.pm »
1 #
2 # BioPerl module for Bio::Tools::Run::StandAloneBlastPlus
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Mark A. Jensen <maj -at- fortinbras -dot- us>
7 #
8 # Copyright Mark A. Jensen
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Tools::Run::StandAloneBlastPlus - Compute with NCBI's blast+ suite *ALPHA*
17  
18 =head1 SYNOPSIS
19  
20 B<NOTE>: This module is related to the
21 L<Bio::Tools::Run::StandAloneBlast> system in name (and inspiration)
22 only. You must use this module directly.
23  
24 # existing blastdb:
25 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
26 -db_name => 'mydb'
27 );
28
29 # create blastdb from fasta file and attach
30 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
31 -db_name => 'mydb',
32 -db_data => 'myseqs.fas',
33 -create => 1
34 );
35
36 # create blastdb from BioPerl sequence collection objects
37 $alnio = Bio::AlignIO->new( -file => 'alignment.msf' );
38 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
39 -db_name => 'mydb',
40 -db_data => $alnio,
41 -create => 1
42 );
43  
44 @seqs = $alnio->next_aln->each_seq;
45 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
46 -db_name => 'mydb',
47 -db_data => \@seqs,
48 -create => 1
49 );
50  
51 # create database with masks
52  
53 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
54 -db_name => 'my_masked_db',
55 -db_data => 'myseqs.fas',
56 -masker => 'dustmasker',
57 -mask_data => 'maskseqs.fas',
58 -create => 1
59 );
60  
61 # create a mask datafile separately
62 $mask_file = $fac->make_mask(
63 -data => 'maskseqs.fas',
64 -masker => 'dustmasker'
65 );
66  
67 # query database for metadata
68 $info_hash = $fac->db_info;
69 $num_seq = $fac->db_num_sequences;
70 @mask_metadata = @{ $fac->db_filter_algorithms };
71  
72 # perform blast methods
73 $result = $fac->tblastn( -query => $seqio );
74 # see Bio::Tools::Run::StandAloneBlastPlus::BlastMethods
75 # for many more details
76  
77 =head1 DESCRIPTION
78  
79 B<NOTE:> This module requires BLAST+ v. 2.2.24+ and higher. Until the API
80 stabilizes for BLAST+, consider this module highly experimental.
81  
82 This module along with
83 L<Bio::Tools::Run::StandAloneBlastPlus::BlastMethods> allows the user
84 to perform BLAST functions using the external program suite C<blast+>
85 (available at
86 L<ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/>), using
87 BioPerl objects and L<Bio::SearchIO> facilities. This wrapper can
88 prepare BLAST databases as well as run BLAST searches. It can also be
89 used to run C<blast+> programs independently.
90  
91 This module encapsulates object construction and production of
92 databases and masks. Blast analysis methods (C<blastp, psiblast>,
93 etc>) are contained in
94 L<Bio::Tools::Run::StandAloneBlastPlus::BlastMethods>.
95  
96 =head1 USAGE
97  
98 The basic mantra is to (1) create a BlastPlus factory using the
99 C<new()> constructor, and (2) perform BLAST analyses by calling the
100 desired BLAST program by name off the factory object. The blast
101 database itself and any masking data are attached to the factory
102 object (step 1). Query sequences and any parameters associated with
103 particular programs are provided to the blast method call (step 2),
104 and are run against the attached database.
105  
106 =head2 Factory construction/initialization
107  
108 The factory needs to be told where the blast+ programs live. The
109 C<BLASTPLUSDIR> environment variable will be checked for the default
110 executable directory. The program directory can be set for individual
111 factory instances with the C<PROG_DIR> parameter. All the blast+
112 programs must be accessible from that directory (i.e., as executable
113 files or symlinks).
114  
115 Either the database or BLAST subject data must be specified at object
116 construction. Databases can be pre-existing formatted BLAST dbs, or
117 can be built directly from fasta sequence files or BioPerl sequence
118 object collections of several kinds. The key constructor parameters
119 are C<DB_NAME>, C<DB_DATA>, C<DB_DIR>.
120  
121 To specify a pre-existing BLAST database, use C<DB_NAME> alone:
122  
123 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
124 -DB_NAME => 'mydb'
125 );
126  
127 The directory can be specified along with the basename, or separately
128 with C<DB_DIR>:
129
130 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
131 -DB_NAME => '~/home/blast/mydb'
132 );
133  
134 #same as
135  
136 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
137 -DB_NAME => 'mydb', -DB_DIR => '~/home/blast'
138 );
139  
140 To create a BLAST database de novo, see L</Creating a BLAST database>.
141  
142 If you wish to apply pre-existing mask data (i.e., the final ASN1
143 output from one of the blast+ masker programs), to the database before
144 querying, specify it with C<MASK_FILE>:
145  
146 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
147 -DB_NAME => 'mydb', -MASK_FILE => 'mymaskdata.asn'
148 );
149  
150 =head2 Creating a BLAST database
151  
152 There are several options for creating the database de novo using
153 attached data, both before and after factory construction. If a
154 temporary database (one that can be deleted by the C<cleanup()>
155 method) is desired, leave out the C<-db_name> parameter. If
156 C<-db_name> is specified, the database will be preserved with the
157 basename specified.
158  
159 Use C<-create => 1> to create a new database (otherwise the factory
160 will look for an existing database). Use C<-overwrite => 1> to create
161 and overwrite an existing database.
162  
163 Note that the database is not created immediately on factory
164 construction. It will be created if necessary on the first use of a
165 factory BLAST method, or you can force database creation by executing
166  
167 $fac->make_db();
168  
169 =over
170  
171 =item * Specify data during construction
172  
173 With a FASTA file:
174  
175 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
176 -db_name => 'mydb',
177 -db_data => 'myseqs.fas',
178 -create => 1
179 );
180  
181 With another BioPerl object collection:
182  
183 $alnio = Bio::AlignIO->new( -file => 'alignment.msf' );
184 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
185 -db_name => 'mydb',
186 -db_data => $alnio,
187 -create => 1
188 );
189 @seqs = $alnio->next_aln->each_seq;
190 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
191 -db_name => 'mydb',
192 -db_data => \@seqs,
193 -create => 1
194 );
195  
196 Other collections (e.g., L<Bio::SeqIO>) are valid. If a certain type
197 does not work, please submit an enhancement request.
198  
199 To create temporary databases, leave out the C<-db_name>, e.g.
200  
201 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
202 -db_data => 'myseqs.fas',
203 -create => 1
204 );
205  
206 To get the tempfile basename, do:
207  
208 $dbname = $fac->db;
209  
210 =item * Specify data post-construction
211  
212 Use the explicit attribute setters:
213  
214 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
215 -create => 1
216 );
217  
218 $fac->set_db_data('myseqs.fas');
219 $fac->make_db;
220  
221 =back
222  
223 =head2 Creating and using mask data
224  
225 The blast+ mask utilities C<windowmasker>, C<segmasker>, and
226 C<dustmasker> are available. Masking can be rolled into database
227 creation, or can be executed later. If your mask data is already
228 created and in ASN1 format, set the C<-mask_file> attribute on
229 construction (see L</Factory constuction/initialization>).
230  
231 To create a mask from raw data or an existing database and apply the
232 mask upon database creation, construct the factory like so:
233  
234 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
235 -db_name => 'my_masked_db',
236 -db_data => 'myseqs.fas',
237 -masker => 'dustmasker',
238 -mask_data => 'maskseqs.fas',
239 -create => 1
240 );
241  
242 The masked database will be created during C<make_db>.
243  
244 The C<-mask_data> parameter can be a FASTA filename or any BioPerl
245 sequence object collection. If the datatype ('nucl' or 'prot') of the
246 mask data is not compatible with the selected masker, an exception
247 will be thrown with a message to that effect.
248  
249 To create a mask ASN1 file that can be used in the C<-mask_file>
250 parameter separately from the attached database, use the
251 C<make_mask()> method directly:
252  
253 $mask_file = $fac->make_mask(-data => 'maskseqs.fas',
254 -masker => 'dustmasker');
255 # segmasker can use a blastdb as input
256 $mask_file = $fac->make_mask(-mask_db => 'mydb',
257 -masker => 'segmasker')
258  
259 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
260 -db_name => 'my_masked_db',
261 -db_data => 'myseqs.fas',
262 -mask_file => $mask_file
263 -create => 1
264 );
265  
266 =head2 Getting database information
267  
268 To get a hash containing useful metadata on an existing database
269 (obtained by running C<blastdbcmd -info>, use C<db_info()>:
270
271 # get info on the attached database..
272 $info = $fac->db_info;
273 # get info on another database
274 $info = $fac->db_info('~/home/blastdbs/another');
275  
276 To get a particular info element for the attached database, just call
277 the element name off the factory:
278  
279 $num_seqs = $fac->db_num_sequences;
280 # info on all the masks applied to the db, if any:
281 @masking_info = @{ $fac->db_filter_algorithms };
282  
283 =head2 Accessing the L<Bio::Tools::Run::BlastPlus> factory
284  
285 The blast+ programs are actually executed by a
286 L<Bio::Tools::Run::BlastPlus> wrapper instance. This instance is
287 available for peeking and poking in the L<StandAloneBlastPlus>
288 C<factory()> attribute. For convenience, C<BlastPlus> methods can be
289 run from the C<StandAloneBlastPlus> object, and are delegated to the
290 C<factory()> attribute. For example, to get the blast+ program to be
291 executed, examine either
292  
293 $fac->factory->command
294  
295 or
296  
297 $fac->command
298  
299 Similarly, the current parameters for the C<BlastPlus> factory are
300  
301 @parameters = $fac->get_parameters
302  
303 =head2 Cleaning up temp files
304  
305 Temporary analysis files produced under a single factory instances can
306 be unlinked by running
307  
308 $fac->cleanup;
309  
310 Tempfiles are generally not removed unless this method is explicitly
311 called. C<cleanup()> only unlinks "registered" files and
312 databases. All temporary files are automatically registered; in
313 particular, "anonymous" databases (such as
314  
315 $fac->Bio::Tools::Run::StandAloneBlastPlus->new(
316 -db_data => 'myseqs.fas',
317 -create => 1
318 );
319  
320 without a C<-db_name> specification) are registered for cleanup. Any
321 file or database can be registered with an internal method:
322  
323 $fac->_register_temp_for_cleanup('testdb');
324  
325 =head2 Other Goodies
326  
327 =over
328  
329 =item
330  
331 You can check whether a given basename points to a properly formatted
332 BLAST database by doing
333  
334 $is_good = $fac->check_db('putative_db');
335  
336 =item
337  
338 User parameters can be passed to the underlying blast+ programs (if
339 you know what you're doing) with C<db_make_args> and C<mask_make_args>:
340  
341 $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
342 -db_name => 'customdb',
343 -db_data => 'myseqs.fas',
344 -db_make_args => [ '-taxid_map' => 'seq_to_taxa.txt' ],
345 -masker => 'windowmasker',
346 -mask_data => 'myseqs.fas',
347 -mask_make_args => [ '-dust' => 'T' ],
348 -create => 1
349 );
350  
351 =item
352  
353 You can prevent exceptions from being thrown by failed blast+ program
354 executions by setting C<no_throw_on_crash>. Examine the error with
355 C<stderr()>:
356  
357 $fac->no_throw_on_crash(1);
358 $fac->make_db;
359 if ($fac->stderr =~ /Error:/) {
360 #handle error
361 ...
362 }
363  
364 =back
365  
366 =head1 SEE ALSO
367  
368 L<Bio::Tools::Run::StandAloneBlastPlus::BlastMethods>,
369 L<Bio::Tools::Run::BlastPlus>
370  
371 =head1 FEEDBACK
372  
373 =head2 Mailing Lists
374  
375 User feedback is an integral part of the evolution of this and other
376 Bioperl modules. Send your comments and suggestions preferably to
377 the Bioperl mailing list. Your participation is much appreciated.
378  
379 bioperl-l@bioperl.org - General discussion
380 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
381  
382 =head2 Support
383  
384 Please direct usage questions or support issues to the mailing list:
385  
386 L<bioperl-l@bioperl.org>
387  
388 rather than to the module maintainer directly. Many experienced and
389 reponsive experts will be able look at the problem and quickly
390 address it. Please include a thorough description of the problem
391 with code and data examples if at all possible.
392  
393 =head2 Reporting Bugs
394  
395 Report bugs to the Bioperl bug tracking system to help us keep track
396 of the bugs and their resolution. Bug reports can be submitted via
397 the web:
398  
399 http://redmine.open-bio.org/projects/bioperl/
400  
401 =head1 AUTHOR - Mark A. Jensen
402  
403 Email maj -at- fortinbras -dot- us
404  
405 =head1 CONTRIBUTORS
406  
407 =head1 APPENDIX
408  
409 The rest of the documentation details each of the object methods.
410 Internal methods are usually preceded with a _
411  
412 =cut
413  
414 # Let the code begin...
415  
416  
417 package Bio::Tools::Run::StandAloneBlastPlus;
418 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
419 1 our $AUTOLOAD;
420  
421 # Object preamble - inherits from Bio::Root::Root
422  
423 1 ▶use lib '../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
424 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
425 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
426 1 ▶use Bio::Tools::GuessSeqFormat;
Subroutine BEGIN: called CC=1 SCAR=0.0
427 1 ▶use Bio::Tools::Run::StandAloneBlastPlus::BlastMethods;
Subroutine BEGIN: called CC=1 SCAR=0.0
428 1 ▶use File::Temp 0.22;
Subroutine BEGIN: called CC=1 SCAR=0.0
429 1 ▶use IO::String;
Subroutine BEGIN: called CC=1 SCAR=0.0
430  
431 1 ▶use base qw(Bio::Root::Root);
Subroutine BEGIN: called CC=1 SCAR=0.0
432 1 ▶unless ( eval "require Bio::Tools::Run::BlastPlus" ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require Bio::Tools::Run::BlastPlus") 0 1 1
433 0 Bio::Root::Root->throw("This module requires 'Bio::Tools::Run::BlastPlus'");
434 }
435  
436 1 my %AVAILABLE_MASKERS = (
437 'windowmasker' => 'nucl',
438 'dustmasker' => 'nucl',
439 'segmasker' => 'prot'
440 );
441  
442 # NOTE: After testing all possible output formats, only 'maskinfo_asn1_text'
443 # is currently working correctly as input for makeblastdb '-mask_data' argument,
444 # the others return an 'Unknown encoding for mask data' error
445 1 my %MASKER_ENCODING = (
446 'windowmasker' => 'maskinfo_asn1_text',
447 'dustmasker' => 'maskinfo_asn1_text',
448 'segmasker' => 'maskinfo_asn1_text'
449 );
450
451 1 my $bp_class = 'Bio::Tools::Run::BlastPlus';
452  
453 # what's the desire here?
454 #
455 # * factory object (created by new())
456 # - points to some blast db entity, so all functions run off the
457 # the factory (except bl2seq?) use the associated db
458 #
459 # * create a blast formatted database:
460 # - specify a file, or an AlignI object
461 # - store for later, or store in a tempfile to throw away
462 # - object should store its own database pointer
463 # - provide masking options based on the maskers provided
464 #
465 # * perform database actions via db-oriented blast+ commands
466 # via the object
467 #
468 # * perform blast searches against the database
469 # - blastx, blastp, blastn, tblastx, tblastn
470 # - specify Bio::Seq objects or files as queries
471 # - output the results as a file or as a Bio::Search::Result::BlastResult
472 # * perform 'special' (i.e., ones I don't know) searches
473 # - psiblast, megablast, rpsblast, rpstblastn
474 # some of these are "tasks" under particular programs
475 # check out psiblast, why special (special 'iteration' handling in
476 # ...::BlastResult)
477 # check out rpsblast, megablast
478 #
479 # * perform bl2seq
480 # - return the alignment directly as a convenience, using Bio::Search
481 # functions
482  
483 # lazy db formatting: makeblastdb only on first blast request...
484 # ParameterBaseI delegation : use AUTOLOAD
485 #
486 #
487  
488 =head2 new
489  
490 Title : new
491 Usage : my $obj = new Bio::Tools::Run::StandAloneBlastPlus();
492 Function: Builds a new Bio::Tools::Run::StandAloneBlastPlus object
493 Returns : an instance of Bio::Tools::Run::StandAloneBlastPlus
494 Args : named argument (key => value) pairs:
495 -db : blastdb name
496  
497 =cut
498  
499 0 ▶sub new {
Subroutine new: not called CC=30 SCAR=68.4
Pod documented
500 0 my ($class,@args) = @_;
501 0 my $self = $class->SUPER::new(@args);
502 0 my ($db_name, $db_data, $db_dir, $db_make_args,
503 $mask_file, $mask_data, $mask_make_args, $masker,
504 $create, $overwrite, $is_remote, $prog_dir, $program_dir)
505 = $self->_rearrange([qw(
506 DB_NAME
507 DB_DATA
508 DB_DIR
509 DB_MAKE_ARGS
510 MASK_FILE
511 MASK_DATA
512 MASK_MAKE_ARGS
513 MASKER
514 CREATE
515 OVERWRITE
516 REMOTE
517 PROG_DIR
518 PROGRAM_DIR
519 )], @args);
520  
521 # parm taint checks
522 0 ▶ if ($db_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db_name) 0 0 0
523 0 ▶ $self->throw("DB name contains invalid characters") unless $db_name =~ m{^[a-z0-9_/:.+-]+$}i;
Branch: 1 branch
BranchTrueFalseTotal
unless $db_name =~ m[^[a-z0-9_/:.+-]+$]i 0 0 0
524 }
525  
526 0 ▶ if ( $db_dir ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db_dir) { } 0 0 0
527 0 ▶ $self->throw("DB directory (DB_DIR) not found") unless (-d $db_dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -d $db_dir 0 0 0
528 0 $self->{'_db_dir'} = $db_dir;
529 }
530 else {
531 0 $self->{'_db_dir'} = '.';
532 }
533 0 ▶ $program_dir ||= $prog_dir; # alias
Condition0%0/3
$program_dir ||= $prog_dir
l!l&&r!l&&!r
000
MC/DC0%0/2
$program_dir ||= $prog_dir
$program_dir $prog_dir
Truth table0%0/3
A ||= B
A= $program_dirB= $prog_dir
ABresult
1X1
011
000
534 # now handle these systematically (bug #3003)
535 # allow db_name to include path info
536 # let db_dir act as root if present and db_name is a relative path
537 # db property contains the pathless name only
538 0 ▶ if ($db_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db_name) 0 0 0
539 0 my ($v,$d,$f) = File::Spec->splitpath($db_name);
540 0 ▶ $self->throw("No DB name at the end of path '$db_name'") unless $f;
Branch: 1 branch
BranchTrueFalseTotal
unless $f 0 0 0
541 0 $f =~ s/\..*$//; # tolerant of extensions, but ignore them
542 0 $self->{_db} = $f;
543 # now establish db_path property as the internal authority on
544 # db location...
545 0 ▶ if ( File::Spec->file_name_is_absolute($db_name) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($db_name)) { } 0 0 0
546 0 ▶ $self->throw("Path specified in DB name ('$d') does not exist") unless !$d || (-d $d);
Branch: 1 branch
BranchTrueFalseTotal
unless not $d or -d $d 0 0 0
Condition0%0/3
not $d or -d $d
l!l&&r!l&&!r
000
MC/DC0%0/2
not $d or -d $d
not $d -d $d
Truth table0%0/3
not(A) or B
A= not $dB= -d $d
ABresult
1X1
011
000
547 0 $self->{_db_path} = File::Spec->catfile($d,$f);
548 0 $self->{_db_dir} = $d;
549 # ignore $db_dir, give heads-up
550 0 ▶ $self->warn("DB name is an absolute path; setting db_dir to '".$self->db_dir."'") if $db_dir;
Branch: 1 branch
BranchTrueFalseTotal
if $db_dir 0 0 0
551 }
552 else {
553 0 $d = File::Spec->catdir($self->db_dir, $d);
554 0 ▶ $self->throw("Path specified by DB_DIR+DB_NAME ('$d') does not exist") unless !$d || (-d $d);
Branch: 1 branch
BranchTrueFalseTotal
unless not $d or -d $d 0 0 0
Condition0%0/3
not $d or -d $d
l!l&&r!l&&!r
000
MC/DC0%0/2
not $d or -d $d
not $d -d $d
Truth table0%0/3
not(A) or B
A= not $dB= -d $d
ABresult
1X1
011
000
555 0 $self->{_db_path} = File::Spec->catfile($d,$f);
556 }
557 }
558
559 0 ▶ if ($masker) {
Branch: 1 branch
BranchTrueFalseTotal
if ($masker) 0 0 0
560 0 ▶ $self->throw("Masker '$masker' not available") unless
Branch: 1 branch
BranchTrueFalseTotal
unless grep /^$masker$/, keys %AVAILABLE_MASKERS 0 0 0
561 grep /^$masker$/, keys %AVAILABLE_MASKERS;
562 0 $self->{_masker} = $masker;
563 }
564
565 0 ▶ if ($program_dir) {
Branch: 2 branches
BranchTrueFalseTotal
if ($program_dir) { } 0 0 0
elsif ($ENV{'BLASTPLUSDIR'}) { } 0 0 0
566 0 ▶ $self->throw("Can't find program directory '$program_dir'") unless
Branch: 1 branch
BranchTrueFalseTotal
unless -d $program_dir 0 0 0
567 -d $program_dir;
568 0 $self->{_program_dir} = $program_dir;
569 }
570 elsif ($ENV{BLASTPLUSDIR}) {
571 0 $self->{_program_dir} = $ENV{BLASTPLUSDIR};
572 }
573 $Bio::Tools::Run::BlastPlus::program_dir = $self->{_program_dir} ||
574 0 ▶ $Bio::Tools::Run::BlastPlus::program_dir;
Condition0%0/3
$self->{'_program_dir'} || $Bio::Tools::Run::BlastPlus::program_dir
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'_program_dir'} || $Bio::Tools::Run::BlastPlus::program_dir
$self->{'_program_dir'} $Bio::Tools::Run::BlastPlus::program_dir
Truth table0%0/3
A || B
A= $self->{'_program_dir'}B= $Bio::Tools::Run::BlastPlus::program_dir
ABresult
1X1
011
000
575
576  
577 0 ▶ $self->set_db_make_args( $db_make_args) if ( $db_make_args );
Branch: 1 branch
BranchTrueFalseTotal
if $db_make_args 0 0 0
578 0 ▶ $self->set_mask_make_args( $mask_make_args) if ($mask_make_args);
Branch: 1 branch
BranchTrueFalseTotal
if $mask_make_args 0 0 0
579 0 $self->{'_create'} = $create;
580 0 $self->{'_overwrite'} = $overwrite;
581 0 $self->{'_is_remote'} = $is_remote;
582 0 $self->{'_db_data'} = $db_data;
583
584 0 $self->{'_mask_file'} = $mask_file;
585 0 $self->{'_mask_data'} = $mask_data;
586  
587  
588 # check db
589 0 ▶ if (defined $self->check_db and $self->check_db == 0 and !$self->is_remote) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->check_db and $self->check_db == 0 and not $self->is_remote) 0 0 0
Condition0%0/6
defined $self->check_db and $self->check_db == 0 and not $self->is_remote
!ll&&!rl&&r
000
defined $self->check_db and $self->check_db == 0
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->check_db and $self->check_db == 0 and not $self->is_remote
defined $self->check_db $self->check_db == 0 not $self->is_remote
Truth table0%0/4
A and B and not(C)
A= defined $self->check_dbB= $self->check_db == 0C= not $self->is_remote
ABCresult
0XX0
10X0
1100
1111
590 0 ▶ $self->throw("DB '".$self->db."' can't be found. To create, set -create => 1.") unless ($create || $overwrite);
Branch: 1 branch
BranchTrueFalseTotal
unless $create or $overwrite 0 0 0
Condition0%0/3
$create or $overwrite
l!l&&r!l&&!r
000
MC/DC0%0/2
$create or $overwrite
$create $overwrite
Truth table0%0/3
A or B
A= $createB= $overwrite
ABresult
1X1
011
000
591 }
592 0 ▶ if (!$self->db) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->db) 0 0 0
593 # allow this to pass; catch lazily at make_db...
594 0 ▶ if (!$self->db_data) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->db_data) 0 0 0
595 0 $self->debug('No database or db data specified. '.
596 'To create a new database, provide '.
597 '-db_data => [fasta|\@seqs|$seqio_object]')
598 }
599  
600 # no db specified; create temp db
601 0 $self->{_create} = 1;
602 0 ▶ if ($self->db_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->db_dir) { } 0 0 0
603 0 my $fh = File::Temp->new(TEMPLATE => 'DBXXXXX',
604 DIR => $self->db_dir,
605 UNLINK => 1);
606 0 my ($v,$d,$f) = File::Spec->splitpath($fh->filename);
607 0 $self->{_db} = $f;
608 0 $self->{_db_path} = $fh->filename;
609 0 $self->_register_temp_for_cleanup($self->db_path);
610 0 $fh->close;
611 }
612 else {
613 0 $self->{_db_dir} = File::Temp->newdir('DBDXXXXX');
614 0 $self->{_db} = 'DBTEMP';
615 0 $self->{_db_path} = File::Spec->catfile($self->db_dir,
616 $self->db);
617 }
618 }
619  
620 0 return $self;
621 }
622  
623 =head2 db()
624  
625 Title : db
626 Usage : $obj->db($newval)
627 Function: contains the basename of the local blast database
628 Example :
629 Returns : value of db (a scalar string)
630 Args : readonly
631  
632 =cut
633  
634 0 ▶sub db { shift->{_db} }
Subroutine db: not called CC=1 SCAR=6.9
Pod documented
635 0 ▶sub db_name { shift->{_db} }
Subroutine db_name: not called CC=1 SCAR=6.9
Pod undocumented
636 0 ▶sub set_db_name { shift->{_db} = shift }
Subroutine set_db_name: not called CC=1 SCAR=6.9
Pod undocumented
637 0 ▶sub db_dir { shift->{_db_dir} }
Subroutine db_dir: not called CC=1 SCAR=6.9
Pod undocumented
638 0 ▶sub set_db_dir { shift->{_db_dir} = shift }
Subroutine set_db_dir: not called CC=1 SCAR=6.9
Pod undocumented
639 0 ▶sub db_path { shift->{_db_path} }
Subroutine db_path: not called CC=1 SCAR=6.9
Pod undocumented
640 0 ▶sub db_data { shift->{_db_data} }
Subroutine db_data: not called CC=1 SCAR=6.9
Pod undocumented
641 0 ▶sub set_db_data { shift->{_db_data} = shift }
Subroutine set_db_data: not called CC=1 SCAR=6.9
Pod undocumented
642 0 ▶sub db_type { shift->{_db_type} }
Subroutine db_type: not called CC=1 SCAR=6.9
Pod undocumented
643 0 ▶sub masker { shift->{_masker} }
Subroutine masker: not called CC=1 SCAR=6.9
Pod undocumented
644 0 ▶sub set_masker { shift->{_masker} = shift }
Subroutine set_masker: not called CC=1 SCAR=6.9
Pod undocumented
645 0 ▶sub mask_file { shift->{_mask_file} }
Subroutine mask_file: not called CC=1 SCAR=6.9
Pod undocumented
646 0 ▶sub set_mask_file { shift->{_mask_file} = shift }
Subroutine set_mask_file: not called CC=1 SCAR=6.9
Pod undocumented
647 0 ▶sub mask_data { shift->{_mask_data} }
Subroutine mask_data: not called CC=1 SCAR=6.9
Pod undocumented
648 0 ▶sub set_mask_data { shift->{_mask_data} = shift }
Subroutine set_mask_data: not called CC=1 SCAR=6.9
Pod undocumented
649  
650 =head2 factory()
651  
652 Title : factory
653 Usage : $obj->factory($newval)
654 Function: attribute containing the Bio::Tools::Run::BlastPlus
655 factory
656 Example :
657 Returns : value of factory (Bio::Tools::Run::BlastPlus object)
658 Args : readonly
659  
660 =cut
661  
662 0 ▶sub factory { shift->{_factory} }
Subroutine factory: not called CC=1 SCAR=6.9
Pod documented
663 0 ▶sub create { shift->{_create} }
Subroutine create: not called CC=1 SCAR=6.9
Pod undocumented
664 0 ▶sub overwrite { shift->{_overwrite} }
Subroutine overwrite: not called CC=1 SCAR=6.9
Pod undocumented
665 0 ▶sub is_remote { shift->{_is_remote} }
Subroutine is_remote: not called CC=1 SCAR=6.9
Pod undocumented
666  
667 =head2 program_version()
668  
669 Title : program_version
670 Usage : $version = $bedtools_fac->program_version()
671 Function: Returns the program version (if available)
672 Returns : string representing location and version of the program
673 Note : this works around the WrapperBase::version() method conflicting with
674 the -version parameter for SABlast (good argument for not having
675 getter/setters for these)
676  
677 =cut
678  
679 =head2 package_version()
680  
681 Title : package_version
682 Usage : $version = $bedtools_fac->package_version()
683 Function: Returns the BLAST+ package version (if available)
684 Returns : string representing BLAST+ package version (may differ from version())
685  
686 =cut
687  
688 0 ▶sub program_version {
Subroutine program_version: not called CC=2 SCAR=17.9
Pod documented
689 0 my $self = shift;
690 0 my $fac = $self->factory;
691 0 ▶ $fac->program_version(@_) if $fac;
Branch: 1 branch
BranchTrueFalseTotal
if $fac 0 0 0
692 }
693  
694 0 ▶sub package_version {
Subroutine package_version: not called CC=2 SCAR=17.9
Pod documented
695 0 my $self = shift;
696 0 my $fac = $self->factory;
697 0 ▶ $fac->package_version(@_) if $fac;
Branch: 1 branch
BranchTrueFalseTotal
if $fac 0 0 0
698 }
699  
700 =head1 DB methods
701  
702 =head2 make_db()
703  
704 Title : make_db
705 Usage :
706 Function: create the blast database (if necessary),
707 imposing masking if specified
708 Returns : true on success
709 Args :
710  
711 =cut
712  
713 # should also provide facility for creating subdatabases from
714 # existing databases (i.e., another format for $data: the name of an
715 # existing blastdb...)
716 0 ▶sub make_db {
Subroutine make_db: not called CC=14 SCAR=53.5
Pod documented
717 0 my $self = shift;
718 0 my @args = @_;
719 0 ▶ return 1 if ( $self->check_db && !$self->overwrite ); # already there or force make
Branch: 1 branch
BranchTrueFalseTotal
if $self->check_db and not $self->overwrite 0 0 0
Condition0%0/3
$self->check_db and not $self->overwrite
!ll&&!rl&&r
000
MC/DC0%0/2
$self->check_db and not $self->overwrite
$self->check_db not $self->overwrite
Truth table0%0/3
A and not(B)
A= $self->check_dbB= not $self->overwrite
ABresult
0X0
100
111
720  
721 0 ▶ $self->throw('No database or db data specified. '.
Branch: 1 branch
BranchTrueFalseTotal
unless $self->db_data 0 0 0
722 'To create a new database, provide '.
723 '-db_data => [fasta|\@seqs|$seqio_object]')
724 unless $self->db_data;
725 # db_data can be: fasta file, array of seqs, Bio::SeqIO object
726 0 my $data = $self->db_data;
727 0 $data = $self->_fastize($data);
728 0 my $testio = Bio::SeqIO->new(-file=>$data, -format=>'fasta');
729 0 ▶ $self->{_db_type} = ($testio->next_seq->alphabet =~ /.na/) ? 'nucl' : 'prot';
Branch: 1 branch
BranchTrueFalseTotal
$testio->next_seq->alphabet =~ /.na/ ? : 0 0 0
730 0 $testio->close;
731  
732 0 my ($v,$d,$name) = File::Spec->splitpath($data);
733 0 $name =~ s/\.fas$//;
734 0 ▶ $self->{_db} ||= $name;
Condition0%0/3
$self->{"_db"} ||= $name
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_db"} ||= $name
$self->{"_db"} $name
Truth table0%0/3
A ||= B
A= $self->{"_db"}B= $name
ABresult
1X1
011
000
735 0 $self->{_db_path} = File::Spec->catfile($self->db_dir,$self->db);
736 # <#######[
737 # deal with creating masks here,
738 # and provide correct parameters to the
739 # makeblastdb ...
740
741 # accomodate $self->db_make_args here -- allow them
742 # to override defaults, or allow only those args
743 # that are not specified here?
744 0 ▶ my $usr_db_args ||= $self->db_make_args;
Condition0%0/3
my $usr_db_args ||= $self->db_make_args
l!l&&r!l&&!r
000
MC/DC0%0/2
my $usr_db_args ||= $self->db_make_args
my $usr_db_args $self->db_make_args
Truth table0%0/3
A ||= B
A= my $usr_db_argsB= $self->db_make_args
ABresult
1X1
011
000
745 0 ▶ my %usr_args = @$usr_db_args if $usr_db_args;
Branch: 1 branch
BranchTrueFalseTotal
if $usr_db_args 0 0 0
746  
747 0 my %db_args = (
748 -in => $data,
749 -dbtype => $self->db_type,
750 -out => $self->db_path,
751 -title => $self->db,
752 -parse_seqids => 1 # necessary for masking
753 );
754 # usr arg override
755 0 ▶ if (%usr_args) {
Branch: 1 branch
BranchTrueFalseTotal
if (%usr_args) 0 0 0
756 0 $db_args{$_} = $usr_args{$_} for keys %usr_args;
757 }
758  
759 # do masking if requested
760 # if the (masker and mask_data) OR mask_file attributes of this
761 # object are set, assume that masking is desired
762 #
763 0 ▶ if ($self->mask_file) { # the actual masking data is provided
Branch: 2 branches
BranchTrueFalseTotal
if ($self->mask_file) { } 0 0 0
elsif ($self->masker and $self->mask_data) { } 0 0 0
764 0 $db_args{'-mask_data'} = $self->mask_file;
765 }
766 ▶ elsif ($self->masker && $self->mask_data) { # build the mask
Condition0%0/3
$self->masker and $self->mask_data
!ll&&!rl&&r
000
MC/DC0%0/2
$self->masker and $self->mask_data
$self->masker $self->mask_data
Truth table0%0/3
A and B
A= $self->maskerB= $self->mask_data
ABresult
0X0
100
111
767 0 $db_args{'-mask_data'} = $self->make_mask(-data => $self->mask_data);
768 $self->throw("Masker error: message is '".$self->stderr."'") unless
769 0 ▶ $db_args{'-mask_data'};
Branch: 1 branch
BranchTrueFalseTotal
unless $db_args{"-mask_data"} 0 0 0
770 0 $self->{_mask_data} = $db_args{'-mask_data'};
771 }
772  
773 0 $self->{_factory} = $bp_class->new(
774 -command => 'makeblastdb',
775 %db_args
776 );
777 0 $self->factory->no_throw_on_crash($self->no_throw_on_crash);
778 0 return $self->factory->_run;
779 }
780  
781 =head2 make_mask()
782  
783 Title : make_mask
784 Usage :
785 Function: create masking data based on specified parameters
786 Returns : mask data filename (scalar string)
787 Args :
788  
789 =cut
790  
791 # mask program usage (based on blast+ manual)
792 #
793 # program dbtype opn
794 # windowmasker nucl mask overrep data, low-complexity (optional)
795 # dustmasker nucl mask low-complexity
796 # segmasker prot
797  
798 0 ▶sub make_mask {
Subroutine make_mask: not called CC=24 SCAR=64.0
Pod documented
799 0 my $self = shift;
800 0 my @args = @_;
801 0 my ($data, $mask_db, $make_args, $masker) = $self->_rearrange([qw(
802 DATA
803 MASK_DB
804 MAKE_ARGS
805 MASKER)], @args);
806 0 my (%mask_args,%usr_args,$db_type);
807 0 my $infmt = 'fasta';
808 0 ▶ $self->throw("make_mask requires -data argument") unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
809 0 ▶ $masker ||= $self->masker;
Condition0%0/3
$masker ||= $self->masker
l!l&&r!l&&!r
000
MC/DC0%0/2
$masker ||= $self->masker
$masker $self->masker
Truth table0%0/3
A ||= B
A= $maskerB= $self->masker
ABresult
1X1
011
000
810 0 ▶ $self->throw("no masker specified and no masker default set in object")
Branch: 1 branch
BranchTrueFalseTotal
unless $masker 0 0 0
811 unless $masker;
812 0 ▶ my $usr_make_args ||= $self->mask_make_args;
Condition0%0/3
my $usr_make_args ||= $self->mask_make_args
l!l&&r!l&&!r
000
MC/DC0%0/2
my $usr_make_args ||= $self->mask_make_args
my $usr_make_args $self->mask_make_args
Truth table0%0/3
A ||= B
A= my $usr_make_argsB= $self->mask_make_args
ABresult
1X1
011
000
813 0 ▶ %usr_args = @$usr_make_args if $usr_make_args;
Branch: 1 branch
BranchTrueFalseTotal
if $usr_make_args 0 0 0
814 0 ▶ unless (grep /^$masker$/, keys %AVAILABLE_MASKERS) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /^$masker$/, keys %AVAILABLE_MASKERS) 0 0 0
815 0 $self->throw("Masker '$masker' not available");
816 }
817 0 ▶ if ($self->check_db($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->check_db($data)) { } 0 0 0
818 0 ▶ unless ($masker eq 'segmasker') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($masker eq "segmasker") 0 0 0
819 0 $self->throw("Masker '$masker' can't use a blastdb as primary input");
820 }
821 0 ▶ unless ($self->db_info($data)->{_db_type} eq
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->db_info($data)->{"_db_type"} eq $AVAILABLE_MASKERS{$masker}) 0 0 0
822 $AVAILABLE_MASKERS{$masker}) {
823 0 $self->throw("Masker '$masker' is incompatible with input db sequence type");
824 }
825 0 $infmt = 'blastdb';
826 }
827 else {
828 0 $data = $self->_fastize($data);
829 0 my $sio = Bio::SeqIO->new(-file=>$data);
830 0 my $s = $sio->next_seq;
831 0 my $type;
832 0 ▶ if ($s->alphabet =~ /.na/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s->alphabet =~ /.na/) { } 0 0 0
elsif ($s->alphabet =~ /protein/) { } 0 0 0
833 0 $type = 'nucl';
834 }
835 elsif ($s->alphabet =~ /protein/) {
836 0 $type = 'prot';
837 }
838 else {
839 0 $type = 'UNK';
840 }
841 0 ▶ unless ($type eq $AVAILABLE_MASKERS{$masker}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type eq $AVAILABLE_MASKERS{$masker}) 0 0 0
842 0 $self->throw("Masker '$masker' is incompatible with sequence type '$type'");
843 }
844 }
845
846 # check that sequence type and masker program match:
847
848 # now, need to provide reasonable default masker arg settings,
849 # and override these with $usr_make_args as necessary and appropriate
850 0 my $mh = File::Temp->new(TEMPLATE=>'MSKXXXXX',
851 UNLINK => 0,
852 DIR => $self->db_dir);
853 0 my $mask_outfile = $mh->filename;
854 0 $mh->close;
855 0 $self->_register_temp_for_cleanup(File::Spec->catfile($self->db_dir,$mask_outfile));
856  
857 # NOTE: '-outfmt' argument must not be included in the default args because
858 # it conflicts with windowmasker '-mk_counts' argument
859 0 %mask_args = (
860 -in => $data,
861 -parse_seqids => 1,
862 );
863 # usr arg override
864 0 ▶ if (%usr_args) {
Branch: 1 branch
BranchTrueFalseTotal
if (%usr_args) 0 0 0
865 0 $mask_args{$_} = $usr_args{$_} for keys %usr_args;
866 }
867 # masker-specific pipelines
868 0 my $status;
869 0 for ($masker) {
870 0 ▶ m/dustmasker/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/dustmasker/ and do { $mask_args{"-out"} = $mask_outfile; $mask_args{"-outfmt"} = $MASKER_ENCODING{$masker}; $self->{"_factory"} = $bp_class->new("-command", $masker, %mask_args); $self->factory->no_throw_on_crash($self->no_throw_on_crash); $status = $self->factory->_run; last } 0 0 0
871 0 $mask_args{'-out'} = $mask_outfile;
872 0 $mask_args{'-outfmt'} = $MASKER_ENCODING{$masker};
873 0 $self->{_factory} = $bp_class->new(-command => $masker,
874 %mask_args);
875 0 $self->factory->no_throw_on_crash($self->no_throw_on_crash);
876 0 $status = $self->factory->_run;
877 0 last;
878 };
879 0 ▶ m/windowmasker/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/windowmasker/ and do { if ($mask_db) { unless ($self->check_db($mask_db)) { $self->throw("Mask database '${mask_db}' is not present or valid"); } ; } ; my $cth = "File::Temp"->new("TEMPLATE", "MCTXXXXX", "DIR", $self->db_dir); my $ct_file = $cth->filename; $cth->close; $mask_args{"-out"} = $ct_file; $mask_args{"-mk_counts"} = "true"; $self->{"_factory"} = $bp_class->new("-command", $masker, %mask_args); $self->factory->no_throw_on_crash($self->no_throw_on_crash); $status = $self->factory->_run; last unless $status; delete $mask_args{"-mk_counts"}; $mask_args{"-ustat"} = $ct_file; $mask_args{"-out"} = $mask_outfile; $mask_args{"-outfmt"} = $MASKER_ENCODING{$masker}; if ($mask_db) { $mask_args{"-in"} = $mask_db; $mask_args{"-infmt"} = "blastdb"; } ; $self->factory->reset_parameters(%mask_args); $self->factory->no_throw_on_crash($self->no_throw_on_crash); $status = $self->factory->_run; last } 0 0 0
880 # check mask_db if present
881 0 ▶ if ($mask_db) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask_db) 0 0 0
882 0 ▶ unless ($self->check_db($mask_db)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->check_db($mask_db)) 0 0 0
883 0 $self->throw("Mask database '$mask_db' is not present or valid");
884 }
885 }
886 0 my $cth = File::Temp->new(TEMPLATE=>'MCTXXXXX',
887 DIR => $self->db_dir);
888 0 my $ct_file = $cth->filename;
889 0 $cth->close;
890 0 $mask_args{'-out'} = $ct_file;
891 0 $mask_args{'-mk_counts'} = 'true';
892 0 $self->{_factory} = $bp_class->new(-command => $masker,
893 %mask_args);
894 0 $self->factory->no_throw_on_crash($self->no_throw_on_crash);
895 0 $status = $self->factory->_run;
896 0 ▶ last unless $status;
Branch: 1 branch
BranchTrueFalseTotal
unless $status 0 0 0
897 0 delete $mask_args{'-mk_counts'};
898 0 $mask_args{'-ustat'} = $ct_file;
899 0 $mask_args{'-out'} = $mask_outfile;
900 0 $mask_args{'-outfmt'} = $MASKER_ENCODING{$masker};
901 0 ▶ if ($mask_db) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask_db) 0 0 0
902 0 $mask_args{'-in'} = $mask_db;
903 0 $mask_args{'-infmt'} = 'blastdb';
904 }
905 0 $self->factory->reset_parameters(%mask_args);
906 0 $self->factory->no_throw_on_crash($self->no_throw_on_crash);
907 0 $status = $self->factory->_run;
908 0 last;
909 };
910 0 ▶ m/segmasker/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/segmasker/ and do { $mask_args{"-infmt"} = $infmt; $mask_args{"-out"} = $mask_outfile; $mask_args{"-outfmt"} = $MASKER_ENCODING{$masker}; $self->{"_factory"} = $bp_class->new("-command", $masker, %mask_args); $self->factory->no_throw_on_crash($self->no_throw_on_crash); $status = $self->factory->_run; last } 0 0 0
911 0 $mask_args{'-infmt'} = $infmt;
912 0 $mask_args{'-out'} = $mask_outfile;
913 0 $mask_args{'-outfmt'} = $MASKER_ENCODING{$masker};
914 0 $self->{_factory} = $bp_class->new(-command => $masker,
915 %mask_args);
916 0 $self->factory->no_throw_on_crash($self->no_throw_on_crash);
917 0 $status = $self->factory->_run;
918 0 last;
919 };
920 0 do {
921 0 $self->throw("Masker program '$masker' not recognized");
922 };
923 }
924 0 ▶ return $status ? $mask_outfile : $status;
Branch: 1 branch
BranchTrueFalseTotal
$status ? : 0 0 0
925 }
926  
927 =head2 db_info()
928  
929 Title : db_info
930 Usage :
931 Function: get info for database
932 (via blastdbcmd -info); add factory attributes
933 Returns : hash of database attributes
934 Args : [optional] db name (scalar string) (default: currently attached db)
935  
936 =cut
937  
938 0 ▶sub db_info {
Subroutine db_info: not called CC=17 SCAR=57.2
Pod documented
939 0 my $self = shift;
940 0 my $db = shift;
941 0 ▶ $db ||= $self->db_path;
Condition0%0/3
$db ||= $self->db_path
l!l&&r!l&&!r
000
MC/DC0%0/2
$db ||= $self->db_path
$db $self->db_path
Truth table0%0/3
A ||= B
A= $dbB= $self->db_path
ABresult
1X1
011
000
942 0 ▶ unless ($db) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($db) 0 0 0
943 0 $self->warn("db_info: db not specified and no db attached");
944 0 return;
945 }
946 0 ▶ if ($self->is_remote) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_remote) 0 0 0
947 0 $self->warn("db_info: sorry, can't get info for remote database (complain to NCBI)");
948 0 return;
949 }
950 0 ▶ if ($db eq $self->db and $self->{_db_info}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db eq $self->db and $self->{"_db_info"}) 0 0 0
Condition0%0/3
$db eq $self->db and $self->{"_db_info"}
!ll&&!rl&&r
000
MC/DC0%0/2
$db eq $self->db and $self->{"_db_info"}
$db eq $self->db $self->{"_db_info"}
Truth table0%0/3
A and B
A= $db eq $self->dbB= $self->{"_db_info"}
ABresult
0X0
100
111
951 0 return $self->{_db_info}; # memoized
952 }
953 0 my $db_info_text;
954 0 $self->{_factory} = $bp_class->new( -command => 'blastdbcmd',
955 -info => 1,
956 -db => $db );
957 0 $self->factory->no_throw_on_crash(1);
958 0 $self->factory->_run();
959 0 $self->factory->no_throw_on_crash(0);
960 0 ▶ if ($self->factory->stderr =~ /No alias or index file found/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->factory->stderr =~ /No alias or index file found/) 0 0 0
961 0 $self->warn("db_info: Couldn't find database ".$self->db."; make with make_db()");
962 0 return;
963 }
964 0 $db_info_text = $self->factory->stdout;
965 # parse info into attributes
966 0 my $infh = IO::String->new($db_info_text);
967 0 my %attr;
968 0 ▶ while (<$infh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $infh)) 0 0 0
969 0 ▶ /Database: (.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/Database: (.*)/ and do { $attr{"db_info_name"} = $1; next } 0 0 0
970 0 $attr{db_info_name} = $1;
971 0 next;
972 };
973 0 ▶ /([0-9,]+) sequences; ([0-9,]+) total/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/([0-9,]+) sequences; ([0-9,]+) total/ and do { $attr{"db_num_sequences"} = $1; $attr{"db_total_bases"} = $2; $attr{"db_num_sequences"} =~ s/,//g; $attr{"db_total_bases"} =~ s/,//g; next } 0 0 0
974 0 $attr{db_num_sequences} = $1;
975 0 $attr{db_total_bases} = $2;
976 0 $attr{db_num_sequences} =~ s/,//g;
977 0 $attr{db_total_bases} =~ s/,//g;
978 0 next;
979 };
980 0 ▶ /Date: (.*?)\s+Longest sequence: ([0-9,]+)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/Date: (.*?)\s+Longest sequence: ([0-9,]+)/ and do { $attr{"db_date"} = $1; $attr{"db_longest_sequence"} = $2; $attr{"db_longest_sequence"} =~ s/,//g; next } 0 0 0
981 0 $attr{db_date} = $1; # convert to more usable date object
982 0 $attr{db_longest_sequence} = $2;
983 0 $attr{db_longest_sequence} =~ s/,//g;
984 0 next;
985 };
986 0 ▶ /Algorithm ID/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/Algorithm ID/ and do { my $alg = ($attr{"db_filter_algorithms"} = []); while (defined($_ = readline $infh)) { if (/\s*([0-9]+)\s+([a-z0-9_]+)\s+(.*)/i) { () = ($1, $2, $3); $alg_opts =~ s/\s+$//; push @$alg, {"algorithm_id", $alg_id, "algorithm_name", $alg_name, "algorithm_opts", $alg_opts}; } else { last; } ; } ; next } 0 0 0
987 0 my $alg = $attr{db_filter_algorithms} = [];
988 0 ▶ while (<$infh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $infh)) 0 0 0
989 0 ▶ if (/\s*([0-9]+)\s+([a-z0-9_]+)\s+(.*)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\s*([0-9]+)\s+([a-z0-9_]+)\s+(.*)/i) { } 0 0 0
990 0 my ($alg_id, $alg_name, $alg_opts) = ($1, $2, $3);
991 0 $alg_opts =~ s/\s+$//;
992 0 push @$alg, { algorithm_id => $alg_id,
993 algorithm_name => $alg_name,
994 algorithm_opts => $alg_opts };
995 }
996 else {
997 0 last;
998 }
999 }
1000 0 next;
1001 };
1002 }
1003 # get db type
1004 0 ▶ if ( -e $db.'.psq' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-e $db . '.psq') { } 0 0 0
elsif (-e $db . '.nsq') { } 0 0 0
1005 0 $attr{_db_type} = 'prot';
1006 }
1007 elsif (-e $db.'.nsq') {
1008 0 $attr{_db_type} = 'nucl';
1009 }
1010 else {
1011 0 $attr{_db_type} = 'UNK'; # bork
1012 }
1013 0 ▶ if ($db eq $self->db) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db eq $self->db) 0 0 0
1014 0 $self->{_db_type} = $attr{_db_type};
1015 0 $self->{_db_info_text} = $db_info_text;
1016 0 $self->{_db_info} = \%attr;
1017 }
1018 0 return \%attr;
1019 }
1020  
1021 =head2 set_db_make_args()
1022  
1023 Title : set_db_make_args
1024 Usage :
1025 Function: set the DB make arguments attribute
1026 with checking
1027 Returns : true on success
1028 Args : arrayref or hashref of named arguments
1029  
1030 =cut
1031  
1032 0 ▶sub set_db_make_args {
Subroutine set_db_make_args: not called CC=4 SCAR=30.0
Pod documented
1033 0 my $self = shift;
1034 0 my $args = shift;
1035 0 ▶ $self->throw("Arrayref or hashref required at DB_MAKE_ARGS") unless
Branch: 1 branch
BranchTrueFalseTotal
unless ref($args) =~ /^ARRAY|HASH$/ 0 0 0
1036 ref($args) =~ /^ARRAY|HASH$/;
1037 0 ▶ if (ref($args) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args eq "HASH") 0 0 0
1038 0 my @a = %$args;
1039 0 $args = \@a;
1040 }
1041 0 ▶ $self->throw("Named args required for DB_MAKE_ARGS") unless !(@$args % 2);
Branch: 1 branch
BranchTrueFalseTotal
if @$args % 2 0 0 0
1042 0 $self->{'_db_make_args'} = $args;
1043 0 return 1;
1044 }
1045  
1046 0 ▶sub db_make_args { shift->{_db_make_args} }
Subroutine db_make_args: not called CC=1 SCAR=6.9
Pod undocumented
1047  
1048 =head2 set_mask_make_args()
1049  
1050 Title : set_mask_make_args
1051 Usage :
1052 Function: set the masker make arguments attribute
1053 with checking
1054 Returns : true on success
1055 Args : arrayref or hasref of named arguments
1056  
1057 =cut
1058  
1059 0 ▶sub set_mask_make_args {
Subroutine set_mask_make_args: not called CC=4 SCAR=30.0
Pod documented
1060 0 my $self = shift;
1061 0 my $args = shift;
1062 0 ▶ $self->throw("Arrayref or hashref required at MASK_MAKE_ARGS") unless
Branch: 1 branch
BranchTrueFalseTotal
unless ref($args) =~ /^ARRAY|HASH$/ 0 0 0
1063 ref($args) =~ /^ARRAY|HASH$/;
1064 0 ▶ if (ref($args) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args eq "HASH") 0 0 0
1065 0 my @a = %$args;
1066 0 $args = \@a;
1067 }
1068 0 ▶ $self->throw("Named args required at MASK_MAKE_ARGS") unless !(@$args % 2);
Branch: 1 branch
BranchTrueFalseTotal
if @$args % 2 0 0 0
1069 0 $self->{'_mask_make_args'} = $args;
1070 0 return 1;
1071 }
1072  
1073 0 ▶sub mask_make_args { shift->{_mask_make_args} }
Subroutine mask_make_args: not called CC=1 SCAR=6.9
Pod undocumented
1074  
1075 =head2 check_db()
1076  
1077 Title : check_db
1078 Usage :
1079 Function: determine if database with registered name and dir
1080 exists
1081 Returns : 1 if db present, 0 if not present, undef if name/dir not
1082 set
1083 Args : [optional] db name (default is 'registered' name in $self->db)
1084 [optional] db directory (default is 'registered' dir in
1085 $self->db_dir)
1086  
1087 =cut
1088  
1089 0 ▶sub check_db {
Subroutine check_db: not called CC=5 SCAR=34.0
Pod documented
1090 0 my $self = shift;
1091 0 my ($db) = @_;
1092 0 my $db_path;
1093 0 ▶ if ($db) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db) { } 0 0 0
1094 0 my ($v,$d,$f) = File::Spec->splitpath($db);
1095 0 $f =~ s/\..*$//; # ignore extensions
1096 0 ▶ $db_path = File::Spec->catfile($d||'.',$f);
Condition0%0/2
$d || '.'
l!l
00
MC/DC0%0/1
$d || '.'
$d
Truth table0%0/2
A
A= $d
Aresult
11
00
1097 }
1098 else {
1099 0 $db_path = $self->db_path;
1100 }
1101 0 ▶ if ( $db_path ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db_path) 0 0 0
1102 0 $self->{_factory} = $bp_class->new( -command => 'blastdbcmd',
1103 -info => 1,
1104 -db => $db_path );
1105 # $DB::single=1;
1106 0 $self->factory->no_throw_on_crash(1);
1107 0 $self->factory->_run();
1108 0 $self->factory->no_throw_on_crash(0);
1109 0 ▶ return 0 if ($self->factory->stderr =~ /No alias or index file found/);
Branch: 1 branch
BranchTrueFalseTotal
if $self->factory->stderr =~ /No alias or index file found/ 0 0 0
1110 0 return 1;
1111 }
1112 0 return;
1113 }
1114  
1115 =head2 no_throw_on_crash()
1116  
1117 Title : no_throw_on_crash
1118 Usage : $fac->no_throw_on_crash($newval)
1119 Function: set to prevent an exeception throw on a failed
1120 blast program execution
1121 Example :
1122 Returns : value of no_throw_on_crash (boolean)
1123 Args : on set, new value (boolean)
1124  
1125 =cut
1126  
1127 0 ▶sub no_throw_on_crash {
Subroutine no_throw_on_crash: not called CC=2 SCAR=17.9
Pod documented
1128 0 my $self = shift;
1129
1130 0 ▶ return $self->{'no_throw_on_crash'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
1131 0 return $self->{'no_throw_on_crash'};
1132 }
1133  
1134  
1135 =head1 Internals
1136  
1137 =head2 _fastize()
1138  
1139 Title : _fastize
1140 Usage :
1141 Function: convert a sequence collection to a temporary
1142 fasta file (sans gaps)
1143 Returns : fasta filename (scalar string)
1144 Args : sequence collection
1145  
1146 =cut
1147  
1148 0 ▶sub _fastize {
Subroutine _fastize: not called CC=22 SCAR=62.3
1149 0 my $self = shift;
1150 0 my $data = shift;
1151 0 for ($data) {
1152 0 ▶ !ref && do {
Branch: 1 branch
BranchTrueFalseTotal
ref $_ or do { $self->throw("Sequence file not found") unless -e $data; my $guesser = "Bio::Tools::GuessSeqFormat"->new("-file", $data); $self->throw("Sequence file not in FASTA format") unless $guesser->guess eq "fasta"; last } 0 0 0
1153 # suppose a fasta file name
1154 0 ▶ $self->throw('Sequence file not found') unless -e $data;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $data 0 0 0
1155 0 my $guesser = Bio::Tools::GuessSeqFormat->new(-file => $data);
1156 0 ▶ $self->throw('Sequence file not in FASTA format') unless
Branch: 1 branch
BranchTrueFalseTotal
unless $guesser->guess eq "fasta" 0 0 0
1157 $guesser->guess eq 'fasta';
1158 0 last;
1159 };
1160 (ref eq 'ARRAY') && (ref $$data[0]) &&
1161 ($$data[0]->isa('Bio::Seq') || $$data[0]->isa('Bio::PrimarySeq'))
1162 0 ▶ && do {
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq "ARRAY" and ref $data->[0] and $data->[0]->isa("Bio::Seq") || $data->[0]->isa("Bio::PrimarySeq") and do { my $fh = "File::Temp"->new("TEMPLATE", "DBDXXXXX", "UNLINK", 0, "DIR", $self->db_dir, "SUFFIX", ".fas"); my $fname = $fh->filename; $fh->close; $self->_register_temp_for_cleanup($fname); my $fasio = "Bio::SeqIO"->new("-file", ">$fname", "-format", "fasta") or $self->throw("Can't create temp fasta file"); foreach $_ (@$data) { my $s = $_->seq; my $a = $_->alphabet; $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g; $_->seq($s); $_->alphabet($a); $fasio->write_seq($_); } ; $fasio->close; $data = $fname; last } 0 0 0
Condition0%0/9
ref $_ eq "ARRAY" and ref $data->[0] and $data->[0]->isa("Bio::Seq") || $data->[0]->isa("Bio::PrimarySeq")
!ll&&!rl&&r
000
ref $_ eq "ARRAY" and ref $data->[0]
!ll&&!rl&&r
000
$data->[0]->isa("Bio::Seq") or $data->[0]->isa("Bio::PrimarySeq")
l!l&&r!l&&!r
000
MC/DC0%0/4
ref $_ eq "ARRAY" and ref $data->[0] and $data->[0]->isa("Bio::Seq") || $data->[0]->isa("Bio::PrimarySeq")
ref $_ eq "ARRAY" ref $data->[0] $data->[0]->isa("Bio::Seq") $data->[0]->isa("Bio::PrimarySeq")
Truth table0%0/5
A and B and C or D
A= ref $_ eq "ARRAY"B= ref $data->[0]C= $data->[0]->isa("Bio::Seq")D= $data->[0]->isa("Bio::PrimarySeq")
ABCDresult
0XXX0
10XX0
11000
111X1
11011
1163 0 my $fh = File::Temp->new(TEMPLATE => 'DBDXXXXX',
1164 UNLINK => 0,
1165 DIR => $self->db_dir,
1166 SUFFIX => '.fas');
1167 0 my $fname = $fh->filename;
1168 0 $fh->close;
1169 0 $self->_register_temp_for_cleanup($fname);
1170 0 ▶ my $fasio = Bio::SeqIO->new(-file=>">$fname", -format=>"fasta")
Branch: 1 branch
BranchTrueFalseTotal
my $fasio = "Bio::SeqIO"->new("-file", ">$fname", "-format", "fasta") or $self->throw("Can't create temp fasta file") 0 0 0
1171 or $self->throw("Can't create temp fasta file");
1172 0 for (@$data) {
1173 0 my $s = $_->seq;
1174 0 my $a = $_->alphabet;
1175 0 $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g;
1176 0 $_->seq( $s );
1177 0 $_->alphabet($a);
1178 0 $fasio->write_seq($_);
1179 }
1180 0 $fasio->close;
1181 0 $data = $fname;
1182 0 last;
1183 };
1184 0 ▶ ref && do { # some kind of object
Branch: 1 branch
BranchTrueFalseTotal
ref $_ and do { my($fmt) = ref($data) =~ /.*::(.*)/; if ($fmt eq "fasta") { $data = $data->file; } else { my $fh = "File::Temp"->new("TEMPLATE", "DBDXXXXX", "UNLINK", 0, "DIR", $self->db_dir, "SUFFIX", ".fas"); my $fname = $fh->filename; $fh->close; $self->_register_temp_for_cleanup($fname); my $fasio = "Bio::SeqIO"->new("-file", ">$fname", "-format", "fasta") or $self->throw("Can't create temp fasta file"); require Bio::PrimarySeq; if ($data->isa("Bio::AlignIO")) { my $aln = $data->next_aln; foreach $_ ($aln->each_seq) { my $s = $_->seq; my $a = $_->alphabet; $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g; $_->seq($s); $_->alphabet($a); $fasio->write_seq($_); } ; } elsif ($data->isa("Bio::SeqIO")) { while (local $_ = $data->next_seq) { my $s = $_->seq; my $a = $_->alphabet; $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g; $_->seq($s); $_->alphabet($a); $fasio->write_seq($_); } ; } elsif ($data->isa("Bio::Align::AlignI")) { foreach $_ ($data->each_seq) { my $s = $_->seq; my $a = $_->alphabet; $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g; $_->seq($s); $_->alphabet($a); $fasio->write_seq($_); } ; } elsif ($data->isa("Bio::Seq") or $data->isa("Bio::PrimarySeq")) { my $s = $data->seq; my $a = $data->alphabet; $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g; $data->seq($s); $data->alphabet($a); $fasio->write_seq($data); } else { $self->throw(q[Can't handle sequence container object of type '] . ref($data) . q[']); } ; $fasio->close; $data = $fname; } ; last } 0 0 0
1185 0 my ($fmt) = ref($data) =~ /.*::(.*)/;
1186 0 ▶ if ($fmt eq 'fasta') {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt eq 'fasta') { } 0 0 0
1187 0 $data = $data->file; # use the fasta file directly
1188 }
1189 else {
1190 # convert
1191 0 my $fh = File::Temp->new(TEMPLATE => 'DBDXXXXX',
1192 UNLINK => 0,
1193 DIR => $self->db_dir,
1194 SUFFIX => '.fas');
1195 0 my $fname = $fh->filename;
1196 0 $fh->close;
1197 0 $self->_register_temp_for_cleanup($fname);
1198 0 ▶ my $fasio = Bio::SeqIO->new(-file=>">$fname", -format=>"fasta")
Branch: 1 branch
BranchTrueFalseTotal
my $fasio = "Bio::SeqIO"->new("-file", ">$fname", "-format", "fasta") or $self->throw("Can't create temp fasta file") 0 0 0
1199 or $self->throw("Can't create temp fasta file");
1200 0 require Bio::PrimarySeq;
1201 0 ▶ if ($data->isa('Bio::AlignIO')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($data->isa('Bio::AlignIO')) { } 0 0 0
elsif ($data->isa('Bio::SeqIO')) { } 0 0 0
elsif ($data->isa('Bio::Align::AlignI')) { } 0 0 0
elsif ($data->isa('Bio::Seq') or $data->isa('Bio::PrimarySeq')) { } 0 0 0
1202 0 my $aln = $data->next_aln;
1203 0 for ($aln->each_seq) {
1204 # must de-gap
1205 0 my $s = $_->seq;
1206 0 my $a = $_->alphabet;
1207 0 $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g;
1208 0 $_->seq( $s );
1209 0 $_->alphabet($a);
1210 0 $fasio->write_seq($_)
1211 }
1212 }
1213 elsif ($data->isa('Bio::SeqIO')) {
1214 0 ▶ while (local $_ = $data->next_seq) {
Branch: 1 branch
BranchTrueFalseTotal
if (local $_ = $data->next_seq) 0 0 0
1215 0 my $s = $_->seq;
1216 0 my $a = $_->alphabet;
1217 0 $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g;
1218 0 $_->seq( $s );
1219 0 $_->alphabet($a);
1220 0 $fasio->write_seq($_);
1221 }
1222 }
1223 elsif ($data->isa('Bio::Align::AlignI')) {
1224 0 for( $data->each_seq) {
1225 0 my $s = $_->seq;
1226 0 my $a = $_->alphabet;
1227 0 $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g;
1228 0 $_->seq( $s );
1229 0 $_->alphabet($a);
1230 0 $fasio->write_seq($_)
1231 }
1232 }
1233 ▶ elsif ($data->isa('Bio::Seq') || $data->isa('Bio::PrimarySeq')) {
Condition0%0/3
$data->isa("Bio::Seq") or $data->isa("Bio::PrimarySeq")
l!l&&r!l&&!r
000
MC/DC0%0/2
$data->isa("Bio::Seq") or $data->isa("Bio::PrimarySeq")
$data->isa("Bio::Seq") $data->isa("Bio::PrimarySeq")
Truth table0%0/3
A or B
A= $data->isa("Bio::Seq")B= $data->isa("Bio::PrimarySeq")
ABresult
1X1
011
000
1234 0 my $s = $data->seq;
1235 0 my $a = $data->alphabet;
1236 0 $s =~ s/[$Bio::PrimarySeq::GAP_SYMBOLS]//g;
1237 0 $data->seq($s);
1238 0 $data->alphabet($a);
1239 0 $fasio->write_seq($data);
1240 }
1241 else {
1242 0 $self->throw("Can't handle sequence container object ".
1243 "of type '".ref($data)."'");
1244 }
1245 0 $fasio->close;
1246 0 $data = $fname;
1247 }
1248 0 last;
1249 };
1250 }
1251 0 return $data;
1252 }
1253  
1254 =head2 _register_temp_for_cleanup()
1255  
1256 Title : _register_temp_for_cleanup
1257 Usage :
1258 Function: register a file for cleanup with
1259 cleanup() method
1260 Returns : true on success
1261 Args : a file name or a blastdb basename
1262 (scalar string)
1263  
1264 =cut
1265  
1266 0 ▶sub _register_temp_for_cleanup {
Subroutine _register_temp_for_cleanup: not called CC=3 SCAR=24.8
1267 0 my $self = shift;
1268 0 my @files = @_;
1269  
1270 0 for (@files) {
1271 0 my ($v, $d, $n) = File::Spec->splitpath($_);
1272 0 ▶ $_ = File::Spec->catfile($self->db_dir, $n) unless length($d);
Branch: 1 branch
BranchTrueFalseTotal
unless length $d 0 0 0
1273 0 push @{$self->{_cleanup_list}}, File::Spec->rel2abs($_);
1274 }
1275 0 return 1;
1276 }
1277  
1278 =head2 cleanup()
1279  
1280 Title : cleanup
1281 Usage :
1282 Function: unlink files registered for cleanup
1283 Returns : true on success
1284 Args :
1285  
1286 =cut
1287  
1288 0 ▶sub cleanup {
Subroutine cleanup: not called CC=9 SCAR=42.9
Pod documented
1289 0 my $self = shift;
1290 0 ▶ return unless $self->{_cleanup_list};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_cleanup_list"} 0 0 0
1291  
1292 0 my $self_file = '';
1293 0 ▶ if (exists $self->{_results}->{_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"_results"}{"_file"}) 0 0 0
1294 0 $self_file = $self->{_results}->{_file};
1295 }
1296 0 for (@{$self->{_cleanup_list}}) {
1297 # Close $self_file filehandle if it appears on the cleanup list,
1298 # to avoid 'permission denied' errors when unlinking
1299 0 ▶ if ($self_file ne '' and $_ =~ m/$self_file$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self_file ne "" and $_ =~ /$self_file$/) 0 0 0
Condition0%0/3
$self_file ne "" and $_ =~ /$self_file$/
!ll&&!rl&&r
000
MC/DC0%0/2
$self_file ne "" and $_ =~ /$self_file$/
$self_file ne "" $_ =~ /$self_file$/
Truth table0%0/3
A and B
A= $self_file ne ""B= $_ =~ /$self_file$/
ABresult
0X0
100
111
1300 0 close $self->{_results}->_fh;
1301 }
1302  
1303 0 ▶ m/(\.[a-z0-9_]+)+$/i && do {
Branch: 1 branch
BranchTrueFalseTotal
/(\.[a-z0-9_]+)+$/i and do { unlink $_; next } 0 0 0
1304 0 unlink $_;
1305 0 next;
1306 };
1307 0 do { # catch all index files
1308 0 ▶ if ( -e $_.".psq" ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-e $_ . '.psq') { } 0 0 0
elsif (-e $_ . '.nsq') { } 0 0 0
1309 0 ▶ unlink glob($_.".p*");
Subroutine BEGIN: called CC=1 SCAR=0.2
1310 0 unlink glob($_.".??.p*");
1311 }
1312 elsif ( -e $_.".nsq" ) {
1313 0 unlink glob($_.".n*");
1314 0 unlink glob($_.".??.n*");
1315 }
1316 else {
1317 0 unlink $_;
1318 }
1319 0 next;
1320 };
1321 }
1322 0 return 1;
1323 }
1324  
1325 =head2 AUTOLOAD
1326  
1327 In this module, C<AUTOLOAD()> delegates L<Bio::Tools::Run::WrapperBase> and
1328 L<Bio::Tools::Run::WrapperBase::CommandExts> methods (including those
1329 of L<Bio::ParamterBaseI>) to the C<factory()> attribute:
1330  
1331 $fac->stderr
1332  
1333 gives you
1334  
1335 $fac->factory->stderr
1336  
1337 If $AUTOLOAD isn't pointing to a WrapperBase method, then AUTOLOAD attempts to return a C<db_info> attribute: e.g.
1338  
1339 $fac->db_num_sequences
1340  
1341 works by looking in the $fac->db_info() hash.
1342  
1343 Finally, if $AUTOLOAD is pointing to a blast query method, AUTOLOAD
1344 runs C<run> with the C<-method> parameter appropriately set.
1345  
1346 =cut
1347  
1348 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=7 SCAR=40.3
1349 0 my $self = shift;
1350 0 my @args = @_;
1351 0 my $method = $AUTOLOAD;
1352 0 $method =~ s/.*:://;
1353 0 my @ret;
1354 0 ▶ if (grep /^$method$/, @Bio::Tools::Run::StandAloneBlastPlus::BlastMethods) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep /^$method$/, @Bio::Tools::Run::StandAloneBlastPlus::BlastMethods) 0 0 0
1355 0 ▶ push @args, ('-method_args' => ['-remote' => 1] ) if ($self->is_remote);
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_remote 0 0 0
1356 0 return $self->run( -method => $method, @args );
1357 }
1358 0 ▶ if ($self->factory and $self->factory->can($method)) { # factory method
Branch: 1 branch
BranchTrueFalseTotal
if ($self->factory and $self->factory->can($method)) 0 0 0
Condition0%0/3
$self->factory and $self->factory->can($method)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->factory and $self->factory->can($method)
$self->factory $self->factory->can($method)
Truth table0%0/3
A and B
A= $self->factoryB= $self->factory->can($method)
ABresult
0X0
100
111
1359 0 return $self->factory->$method(@args);
1360 }
1361 0 ▶ if ($self->db_info and grep /^$method$/, keys %{$self->db_info}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->db_info and grep /^$method$/, keys %{$self->db_info;}) 0 0 0
Condition0%0/3
$self->db_info and grep /^$method$/, keys %{$self->db_info;}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->db_info and grep /^$method$/, keys %{$self->db_info;}
$self->db_info grep /^$method$/, keys %{$self->db_info;}
Truth table0%0/3
A and B
A= $self->db_infoB= grep /^$method$/, keys %{$self->db_info;}
ABresult
0X0
100
111
1362 0 return $self->db_info->{$method};
1363 }
1364 # else, fail
1365 0 $self->throw("Can't locate method '$method' in class ".ref($self));
1366  
1367 }
1368  
1369  
1370 1 1;
« Tools/Run/StandAloneBlastPlus/BlastMethods.pm ↑ Summary Tools/Run/Vista.pm »