HOWTO:StandAloneBlast
Contents |
Author
Torsten Seemann <torsten.seemann-at-infotech-monash-edu-au>
Victorian Bioinformatics Consortium, Monash University, Australia.
Copyright
This document is copyright Torsten Seemann, 2006. It can be copied and distributed under the terms of the Perl Artistic License.
Revisions
- First draft - Torsten 22:16, 21 April 2006 (EDT)
Introduction
This HOWTO describes the steps you may need to take to get Bio::Tools::Run::StandAloneBlast working with NCBI BLAST on your system. There is a lot of confusion between settings that are purely do to with BLAST itself, settings for the StandAloneBlast module, and settings used by both. Hopefully this document will help clarify this.
Note that this HOWTO is for the older version of BLAST only. For the newer version of BLAST, BLAST+, see HOWTO:BlastPlus.
Checklist
Install the binaries
StandAloneBlast, despite its name, does not work standalone; it requires that the BLAST binaries/executables are installed on your system. You'll need to download and install the blast package appropriate for your platform from ftp://ftp.ncbi.nlm.nih.gov/blast/ . Let's assume you unpackaged them into /home/blast (Unix) or C:\BLAST (Windows). There should be a bin and data subdirectories.
The NCBI configuration file
This is needed to keep blastall happy.
Unix: $HOME/.ncbirc
[NCBI] Data=/home/blast/data
Windows: C:\WINDOWS\NCBI.INI or C:\WINNT\NCBI.INI
[NCBI] Data=C:\BLAST\DATA
Locating the binaries
To be able to BLAST sequences, the StandAloneBlast module needs to know where the blastall (Unix) or blastall.exe (Windows) executable is. This can be done in two ways - using PATH or BLASTDIR. Here we combine both methods.
Unix: $HOME/.bashrc
export PATH=${PATH}:/home/blast/bin
export BLASTDIR=/home/blast
Windows: C:\AUTOEXEC.BAT
PATH=%PATH%;C:\BLAST\BIN BLASTDIR=C:\BLAST
After you get this part working, typing blastall - should print all the command line options.
Default location of BLAST indices
This is the directory where blastall will look for sequence index files if you don't specify a full path on the -d option (database to search).
Unix: $HOME/.bashrc
export BLASTDB=/home/blast/data
Windows: C:\AUTOEXEC.BAT
BLASTDB=C:\BLAST\DATA
This is not needed if you supply a fully specified path (ie. starts with "/" or "\").
Example session
The example code below assumes that you used the formatdb program to index the database sequence file "db.fa".
First, include the necessary modules with use:
use Bio::Tools::Run::StandAloneBlast; use Bio::Seq;
Stipulate the parameters used by the blastall program by populating an array, @params:
@params = (program => 'blastn', database => 'db.fa');
Now, create a Bio::Seq object to provide the query:
$seq_obj = Bio::Seq->new(-id =>"test query", -seq =>"TTTAAATATATTTTGAAGTATAGATTATATGTT");
Finally create the StandAloneBlast object (a.k.a "factory"), and execute blastall by calling the blastall method with the parameter array. The parsed BLAST output is returned in $report_obj.
$blast_obj = Bio::Tools::Run::StandAloneBlast->new(@params); $report_obj = $blast_obj->blastall($seq_obj); $result_obj = $report_obj->next_result; print $result_obj->num_hits;
$report_obj is a Bio::SearchIO object. Here's an example of how one would use SearchIO to extract data from a BLAST report. This code prints out details about the match when the HSP or aligned pair are greater than 75% identical.
use Bio::SearchIO; $report_obj = new Bio::SearchIO(-format => 'blast', -file => 'report.bls'); while( $result = $report_obj->next_result ) { while( $hit = $result->next_hit ) { while( $hsp = $hit->next_hsp ) { if ( $hsp->percent_identity > 75 ) { print "Hit\t", $hit->name, "\n", "Length\t", $hsp->length('total'), "\n", "Percent_id\t", $hsp->percent_identity, "\n"; } } } }
Much more info on SearchIO is available at HOWTO:SearchIO.
Note: You may see errors when you try to use Bio::Tools::Run::StandAloneBlast that have nothing to do with Bioperl. Make sure that BLAST is set up properly and running before you attempt to script it using Bio::Tools::Run::StandAloneBlast. There are some notes on setting up BLAST in the INSTALL file.
Using WU-BLAST
TODO.