NAME
Bio::Tools::Run::StandAloneBlast - Object for the local execution of the NCBI Blast program suite (blastall, blastpgp, bl2seq)
SYNOPSIS
Local-blast "factory object" creation and blast-parameter initialization:
@params = ('database' => 'swissprot','outfile' => 'blast1.out',
'_READMETHOD' => 'Blast');
$factory = Bio::Tools::Run::StandAloneBlast->new(@params);
Blast a sequence against a database:
$str = Bio::SeqIO->new(-file=>'t/amino.fa' , '-format' => 'Fasta' );
$input = $str->next_seq();
$input2 = $str->next_seq();
$blast_report = $factory->blastall($input);
Run an iterated Blast (psiblast) of a sequence against a database:
$factory->j(3); # 'j' is blast parameter for # of iterations
$factory->outfile('psiblast1.out');
$factory = Bio::Tools::Run::StandAloneBlast->new(@params);
$blast_report = $factory->blastpgp($input);
Use blast to align 2 sequences against each other:
$factory = Bio::Tools::Run::StandAloneBlast->new('outfile' => 'bl2seq.out');
$factory->bl2seq($input, $input2);
Various additional options and input formats are available. See the DESCRIPTION section for details.
DESCRIPTION
This DESCRIPTION only documents Bio::Tools::Run::StandAloneBlast.pm: - a Bioperl object for running the NCBI standAlone BLAST package. Blast, itself, is a large & complex program - for more information regarding BLAST, please see the BLAST documentation which accompanies the BLAST distribution. BLAST is available from: ftp://ftp.ncbi.nlm.nih.gov/blast/server/current_release/.
(A source of confusion in documenting a BLAST interface is that the term "program" is used in - at least - three different ways in the BLAST documentation. In this DESCRIPTION, "program" will refer to the BLAST routine set by BLAST's -p
parameter that can be set to blastn, blastp, tblastx etc. We will use the term Blast "executable" to refer to the various different executable files that may be called - ie blastall, blastpgp or bl2seq. In addition, there are several BLAST capabilities (which are also referred to as "programs") and are implemented by using specific combinations of BLAST executables, programs and parameters. They will be referred by their specific names - eg PSIBLAST and PHIBLAST. )
StandAloneBlast.pm has been tested so far only under Linux. I expect that it should also work under other Unix systems. However, since the module is implemented using (unix) system calls, modification may be necessary before StandAloneBlast.pm would work under non-Unix operating systems (eg Windows, MacOS). Before running StandAloneBlast.pm it is necessary: to install BLAST on your system, to edit set the environmental variable $BLASTDIR or your $PATH variable to point to the BLAST directory, and to ensure that users have execute privileges for the BLAST program. If the databases which will be searched by BLAST are located in the data subdirectory of the blast program directory (the default installation location), StandAloneBlast.pm will find them; however, if the database files are located in any other location, environmental variable $BLASTDATADIR will need to be set to point to that directory.
The use of the StandAloneBlast.pm module is as follows: Initially, a local blast "factory object" is created. The constructor may be passed an optional array of (non-default) parameters to be used by the factory, eg:
@params = ('program' => 'blastn', 'database' => 'ecoli.nt');
$factory = Bio::Tools::Run::StandAloneBlast->new(@params);
Any parameters not explicitly set will remain as the defaults of the BLAST executable. Note each BLAST executable has somewhat different parameters and options. See the BLAST Documentation for a description or run the BLAST executable from the command line followed solely with a "-" to see a list of options and default values for that executable; eg >blastall -.
BLAST parameters can be changed and/or examined at any time after the factory has been created. The program checks that any parameter/switch being set/read is valid. Except where specifically noted, StandAloneBlast uses the same single-letter, case-sensitive parameter names as the actual blast program. Currently no checks are included to verify that parameters are of the proper type (eg string or numeric) or that their values are within the proper range.
As an example, to change the value of the Blast parameter 'e' ('e' is the parameter for expectation-value cutoff)
$expectvalue = 0.01;
$factory->e($expectvalue);
Note that for improved script readibility one can modify the name of the BLAST parameters as desired as long as the initial letter (and case) of the parameter are preserved, eg $factory->expectvalue($expectvalue); Unfortunately, some of the BLAST parameters are not the single letter one might expect (eg "iteration round" in blastpgp is 'j'). Again one can check by using (eg)
> blastpgp - .
Once the factory has been created and the appropriate parameters set, one can call one of the supported blast executables. The input sequence(s) to these executables may be fasta file(s) as described in the BLAST documentation.
$inputfilename = 't/testquery.fa';
$blast_report = $factory->blastall($inputfilename);
In addition, sequence input may be in the form of either a Bio::Seq object or or an array of Bio::Seq objects, eg
$input = Bio::Seq->new(-id=>"test query",-seq=>"ACTACCCTTTAAATCAGTGGGGG");
$blast_report = $factory->blastall($input);
For blastall and non-psiblast blastpgp runs, report object is either a BPlite.pm or Blast.pm object, selected by the user with the parameter _READMETHOD. (The leading underscore is needed to distinguish this option from options which are passed to the BLAST executable.) The default parser is BPlite. For (multiple iteration) psiblast and bl2seq runs the report is automatically parsed by the BPpsilite.pm and BPbl2seq.pm parsers respectively, since neither Blast.pm nor BPlite can parse these reports. In any case, the "raw" blast report is also available. The filename is set by the in the 'outfile' parameter and has the default value of "blastreport.out".
When using the Blast.pm parser, only a default configuration is currently supported:
-signif => $self->e() || 1e-5, # where $self->e(), if set, is the BLAST cutoff value
-parse => 1,
-stats => 1,
-check_all_hits => 1,
If it is desired to parse the resulting report with Blast.pm with other values, the user can save the report in the file given by $factory->outfile('outputfilelocation') and then reading that file with Blast.pm using any parameters desired.
For psiblast execution in BLAST's "jumpstart" mode, the program must be passed (in addition to the query sequence itself) an alignment containing the query sequence (in the form of a SimpleAlign object) as well as a "mask" specifying at what residues position-specific scoring matrices (PSSMs) are to used and at what residues default scoring matrices (eg BLOSUM) are to be used. See psiblast documentation for more details. The mask itself is a string of 0's and 1's which is the same length as each sequence in the alignment and has a "1" at locations where (PSSMs) are to be used and a "0" at all other locations. So for example:
$str = Bio::AlignIO->new(-file=> "cysprot.msf", '-format' => 'msf' );
$aln = $str->next_aln();
$len = $aln->length_aln();
$mask = '1' x $len; # simple case where PSSM's to be used at all residues
$report = $factory->blastpgp("cysprot1.fa", $aln, $mask);
For bl2seq execution, StandAloneBlast.pm can be combined with AlignIO.pm to directly produce a SimpleAlign object from the alignment of the two sequences produced by bl2seq as in:
#Get 2 sequences
$str = Bio::SeqIO->new(-file=>'t/amino.fa' , '-format' => 'Fasta', );
my $seq3 = $str->next_seq();
my $seq4 = $str->next_seq();
# Run bl2seq on them
$factory = Bio::Tools::Run::StandAloneBlast->new('outfile' => 'bl2seq.out');
my $bl2seq_report = $factory->bl2seq($seq3, $seq4);
# Use AlignIO.pm to create a SimpleAlign object from the bl2seq report
$str = Bio::AlignIO->new(-file=> 'bl2seq.out','-format' => 'bl2seq');
$aln = $str->next_aln();
For more examples of syntax and use of Blast.pm, the user is encouraged to run the scripts standaloneblast.pl in the bioperl /examples directory and StandAloneBlast.t in the bioperl /t directory.
Note: There is a similar (but older) perl object interface offered by nhgri. The nhgri module only supports blastall and does not support blastpgp, psiblast, phiblast, bl2seq etc. This module can be found at http://genome.nhgri.nih.gov/blastall/.
DEVELOPERS NOTES
STILL TO BE WRITTEN
Note: This module is still under development. If you would like that a specific BLAST feature be added to this perl interface, let me know.
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bio.perl.org/MailList.html - About the mailing lists
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via email or the web:
bioperl-bugs@bio.perl.org
http://bio.perl.org/bioperl-bugs/
AUTHOR - Peter Schattner
Email schattner@alum.mit.edu
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
BLAST parameters
Essentially all BLAST parameter can be set via StandAloneBlast.pm. Some of the most commonly used parameters are listed below. All parameters have defaults and are optional (I think.) For a complete listing of settable parameters, run the relevant executable BLAST program with the option "-" as in blastall -
Blastall
-p Program Name [String]
Input should be one of "blastp", "blastn", "blastx",
"tblastn", or "tblastx".
-d Database [String] default = nr
The database specified must first be formatted with formatdb.
Multiple database names (bracketed by quotations) will be accepted.
An example would be -d "nr est"
-i Query File [File In] Set by StandAloneBlast.pm from script.
default = stdin. The query should be in FASTA format. If multiple FASTA entries are in the input
file, all queries will be searched.
-e Expectation value (E) [Real] default = 10.0
-o BLAST report Output File [File Out] Optional,
default = ./blastreport.out ; set by StandAloneBlast.pm
-S Query strands to search against database (for blast[nx], and tblastx). 3 is both, 1 is top, 2 is bottom [Integer]
default = 3
Blastpgp (including Psiblast)
-j is the maximum number of rounds (default 1; i.e., regular BLAST)
-h is the e-value threshold for including sequences in the
score matrix model (default 0.001)
-c is the "constant" used in the pseudocount formula specified in the paper (default 10)
-B Multiple alignment file for PSI-BLAST "jump start mode" Optional
-Q Output File for PSI-BLAST Matrix in ASCII [File Out] Optional
Bl2seq
-i First sequence [File In]
-j Second sequence [File In]
-p Program name: blastp, blastn, blastx. For blastx 1st argument should be nucleotide [String]
default = blastp
-o alignment output file [File Out] default = stdout
-e Expectation value (E) [Real] default = 10.0
-S Query strands to search against database (blastn only). 3 is both, 1 is top, 2 is bottom [Integer]
default = 3
Methods
exists_blast
Title : exists_blast
Usage : $blastfound = Bio::Tools::Run::StandAloneBlast->exists_blast()
Function: Determine whether Blast program can be found on current host.
Cf. the DESCRIPTION section of this POD for how to make sure
for your BLAST installation to be found. This method checks for
existence of the blastall executable either in BLASTDIR or in
the path.
Side effects: if BLASTDATADIR is not set, checks whether data is a
subdirectory of the directory where blastall is found, and if so,
sets DATADIR accordingly.
Returns : 1 if Blast program found at expected location, 0 otherwise.
Args : none
blastall
Title : blastall
Usage : $blast_report = $factory->blastall('t/testquery.fa');
or
$input = Bio::Seq->new(-id=>"test query",
-seq=>"ACTACCCTTTAAATCAGTGGGGG");
$blast_report = $factory->blastall($input);
or
$seq_array_ref = \@seq_array; # where @seq_array is an array of Bio::Seq objects
$blast_report = $factory->blastall(\@seq_array);
Returns : Reference to a Blast object or BPlite object
containing the blast report.
Args : Name of a file or Bio::Seq object or an array of
Bio::Seq object containing the query sequence(s).
Throws an exception if argument is not either a string
(eg a filename) or a reference to a Bio::Seq object
(or to an array of Seq objects). If argument is string,
throws exception if file corresponding to string name can
not be found.
blastpgp
Title : blastpgp
Usage : $blast_report = $factory-> blastpgp('t/testquery.fa');
or
$input = Bio::Seq->new(-id=>"test query",
-seq=>"ACTADDEEQQPPTCADEEQQQVVGG");
$blast_report = $factory->blastpgp ($input);
or
$seq_array_ref = \@seq_array; # where @seq_array is an array of Bio::Seq objects
$blast_report = $factory-> blastpgp(\@seq_array);
Returns : Reference to a Blast object or BPlite object containing
the blast report.
Args : Name of a file or Bio::Seq object. In psiblast jumpstart
mode two additional arguments are required: a SimpleAlign
object one of whose elements is the query and a "mask" to
determine how BLAST should select scoring matrices see
DESCRIPTION above for more details.
Throws an exception if argument is not either a string
(eg a filename) or a reference to a Bio::Seq object
(or to an array of Seq objects). If argument is string,
throws exception if file corresponding to string name can
not be found.
Returns : Reference to either a BPlite.pm, Blast.pm or BPpsilite.pm
object containing the blast report.
bl2seq
Title : bl2seq
Usage : $factory-> blastpgp('t/seq1.fa', 't/seq2.fa');
or
$input1 = Bio::Seq->new(-id=>"test query1",
-seq=>"ACTADDEEQQPPTCADEEQQQVVGG");
$input2 = Bio::Seq->new(-id=>"test query2",
-seq=>"ACTADDEMMMMMMMDEEQQQVVGG");
$blast_report = $factory->bl2seq ($input1, $input2);
Returns : Reference to a BPbl2seq object containing the blast report.
Args : Names of 2 files or 2 Bio::Seq objects containing the
sequences to be aligned by bl2seq.
Throws an exception if argument is not either a pair of
strings (eg filenames) or references to Bio::Seq objects.
If arguments are strings, throws exception if files
corresponding to string names can not be found.
_generic_local_blast
Title : _generic_local_blast
Usage : internal function not called directly
Returns : Blast or BPlite object
Args : Reference to calling object and name of BLAST executable
_runblast
Title : _runblast
Usage : Internal function, not to be called directly
Function: makes actual system call to Blast program
Example :
Returns : Report object in the appropriate format (BPlite,
BPpsilite, Blast, or BPbl2seq)
Args : Reference to calling object, name of BLAST executable,
and parameter string for executable
_setinput
Title : _setinput
Usage : Internal function, not to be called directly
Function: Create input file(s) for Blast executable
Example :
Returns : name of file containing Blast data input
Args : Seq object reference or input file name
_setparams
Title : _setparams
Usage : Internal function, not to be called directly
Function: Create parameter inputs for Blast program
Example :
Returns : parameter string to be passed to Blast
Args : Reference to calling object and name of BLAST executable