1
# $Id: StandAloneWUBlast.pm 15383 2009-01-16 16:45:08Z cjfields $
3
# BioPerl module for Bio::Tools::Run::StandAloneBlast
5
# Copyright Peter Schattner
7
# You may distribute this module under the same terms as perl itself
9
# POD documentation - main docs before the code
13
Bio::Tools::Run::StandAloneWUBlast - Object for the local execution
18
# Do not use directly; use Bio::Tools::Run::StandAloneBlast
22
See Bio::Tools::Run::StandAloneBlast
28
User feedback is an integral part of the evolution of this and other
29
Bioperl modules. Send your comments and suggestions preferably to one
30
of the Bioperl mailing lists. Your participation is much appreciated.
32
bioperl-l@bioperl.org - General discussion
33
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
37
Report bugs to the Bioperl bug tracking system to help us keep track
38
the bugs and their resolution. Bug reports can be submitted via
41
http://bugzilla.open-bio.org/
43
=head1 AUTHOR - Peter Schattner
45
Email schattner at alum.mit.edu
47
=head1 MAINTAINER - Torsten Seemann
49
Email torsten at infotech.monash.edu.au
53
Sendu Bala bix@sendu.me.uk (reimplementation)
57
The rest of the documentation details each of the object
58
methods. Internal methods are usually preceded with a _
62
package Bio::Tools::Run::StandAloneWUBlast;
66
use base qw(Bio::Tools::Run::StandAloneBlast);
69
our $DEFAULTREADMETHOD = 'BLAST';
71
# If local BLAST databases are not stored in the standard
72
# /data directory, the variable BLASTDATADIR will need to be
74
our $DATADIR = $Bio::Tools::Run::StandAloneBlast::DATADIR;
76
our %GENERAL_PARAMS = (i => 'input',
80
our @WUBLAST_PARAMS = qw(e s e2 s2 w t x m y z l k h v b q r
81
matrix filter wordmask filter maskextra hitdist wink ctxfactor gape
82
gaps gape2 gaps2 gapw gapx olf golf olmax golmax gapdecayrate
83
topcombon topcomboe sumstatsmethod hspsepqmax hspsepsmax gapsepqmax
84
gapsepsmax altscore hspmax gspmax qoffset nwstart nwlen qrecmin qrecmax
85
dbrecmin dbrecmax vdbdescmax dbchunks sort_by_pvalue cpus putenv
87
our @WUBLAST_SWITCH = qw(kap sump poissonp lcfilter lcmask echofilter
88
stats nogap gapall pingpong nosegs postsw span2 span1 span prune
89
consistency links ucdb gi noseqs qtype qres sort_by_pvalue
90
sort_by_count sort_by_highscore sort_by_totalscore
91
sort_by_subjectlength mmio nonnegok novalidctxok shortqueryok notes
92
warnings errors endputenv getenv endgetenv abortonerror abortonfatal);
94
our @OTHER_PARAMS = qw(_READMETHOD);
100
Usage : my $obj = Bio::Tools::Run::StandAloneBlast->new();
101
Function: Builds a newBio::Tools::Run::StandAloneBlast object
102
Returns : Bio::Tools::Run::StandAloneBlast
103
Args : -quiet => boolean # make program execution quiet
104
-_READMETHOD => 'BLAST' (default, synonym 'SearchIO') || 'blast_pull'
105
# the parsing method, case insensitive
107
Essentially all BLAST parameters can be set via StandAloneBlast.pm.
108
Some of the most commonly used parameters are listed below. All
109
parameters have defaults and are optional except for -p.
111
-p Program Name [String]
112
Input should be one of "wublastp", "wublastn", "wublastx",
113
"wutblastn", or "wutblastx".
114
-d Database [String] default = nr
115
The database specified must first be formatted with xdformat.
116
-E Expectation value (E) [Real] default = 10.0
117
-o BLAST report Output File [File Out] Optional,
118
default = ./blastreport.out ; set by StandAloneBlast.pm
123
my ($caller, @args) = @_;
124
my $self = $caller->SUPER::new(@args);
126
$self->_set_from_args(\@args, -methods => {(map { $_ => $GENERAL_PARAMS{$_} } keys %GENERAL_PARAMS),
127
(map { $_ => $_ } (@OTHER_PARAMS,
133
my ($tfh, $tempfile) = $self->io->tempfile();
134
my $outfile = $self->o || $self->outfile || $tempfile;
138
$self->_READMETHOD($DEFAULTREADMETHOD) unless $self->_READMETHOD;
143
# We let get/setter method names be case-insensitve
146
my $attr = $AUTOLOAD;
153
$self->can($attr) || $self->throw("Unallowed parameter: $orig !");
155
return $self->$attr(@_);
161
Usage : $blast_report = $factory->wublast('t/testquery.fa');
163
$input = Bio::Seq->new(-id=>"test query",
164
-seq=>"ACTACCCTTTAAATCAGTGGGGG");
165
$blast_report = $factory->wublast($input);
167
$seq_array_ref = \@seq_array; # where @seq_array is an array of Bio::Seq objects
168
$blast_report = $factory->wublast(\@seq_array);
169
Returns : Reference to a Blast object
170
Args : Name of a file or Bio::Seq object or an array of
171
Bio::Seq object containing the query sequence(s).
172
Throws an exception if argument is not either a string
173
(eg a filename) or a reference to a Bio::Seq object
174
(or to an array of Seq objects). If argument is string,
175
throws exception if file corresponding to string name can
181
my ($self, $input1) = @_;
182
$self->io->_io_cleanup();
183
my $executable = 'wublast';
185
# Create input file pointer
186
my $infilename1 = $self->_setinput($executable, $input1) || $self->throw("$input1 not Bio::Seq object or array of Bio::Seq objects or file name!");
187
$self->i($infilename1);
189
my $blast_report = $self->_generic_local_wublast($executable);
192
=head2 _generic_local_wublast
194
Title : _generic_local_wublast
195
Usage : internal function not called directly
196
Returns : Blast object
197
Args : Reference to calling object and name of BLAST executable
201
sub _generic_local_wublast {
203
my $executable = shift;
205
# Create parameter string to pass to Blast program
206
my $param_string = $self->_setparams($executable);
207
$param_string = " ".$self->database." ".$self->input." ".$param_string;
210
my $blast_report = $self->_runwublast($executable, $param_string);
216
Usage : Internal function, not to be called directly
217
Function: makes actual system call to WU-Blast program
219
Returns : Report Blast object
220
Args : Reference to calling object, name of BLAST executable,
221
and parameter string for executable
226
my ($self, $executable, $param_string) = @_;
227
my ($blast_obj, $exe);
228
if (! ($exe = $self->executable($self->p))){
229
$self->warn("cannot find path to $executable");
233
my $commandstring = $exe.$param_string;
235
$self->debug("$commandstring\n");
236
system($commandstring) && $self->throw("$executable call crashed: $? | $! | $commandstring\n");
239
my $outfile = $self->o();
240
$blast_obj = Bio::SearchIO->new(-file => $outfile, -format => 'blast');
248
Usage : Internal function, not to be called directly
249
Function: Create parameter inputs for Blast program
251
Returns : parameter string to be passed to Blast
252
Args : Reference to calling object and name of BLAST executable
257
my ($self, $executable) = @_;
258
my ($attr, $value, @execparams);
260
@execparams = @WUBLAST_PARAMS;
262
# of the general params, wublast only takes outfile at
263
# this stage (we add in program, input and database manually elsewhere)
264
push(@execparams, 'o');
266
# workaround for problems with shell metacharacters [bug 2707]
267
# simply quoting does not always work!
268
# Fixed so Windows files are not quotemeta'd
270
$self->o(quotemeta($tmp)) if ($tmp && $^O !~ /^MSWin/);
272
my $param_string = $self->SUPER::_setparams(-params => [@execparams],
273
-switches => \@WUBLAST_SWITCH,
276
$self->o($tmp) if ($tmp && $^O !~ /^MSWin/);
278
if ($self->quiet()) {
279
$param_string .= ' 2> '.File::Spec->devnull;
282
return $param_string;