How do I BLAST a sequences ?

Introduction: Basic Local Alignment Search Tool, or BLAST, is an algorithm for comparing biological sequences, such as the amino-acid sequences of different proteins or the DNA sequences. Given a library or database of sequences, a BLAST search enables a researcher to look for sequences that resemble a given sequence of interest. The query is the needle that is found in the haystack which is a database. The STRAP-toolbox supports several different BLAST implementations. The computation yields the search result as XML text.

Local blast installation vs. Web services: The usage of a web-service is most convenient for the user because no installation is required. Unfortunately, computation takes long time. A local blast installation is useful when the user wants to perform Blast searches using a locally stored Blast database,

Cache: To avoid repetitive computation of identical BLAST queries a HD cache is maintained CacheResult . To avoid that the result is taken from the cache the cache can be switched off with CacheResult#setEnabled(boolean) .

Installation: The STRAP-toolbox which is derived from the alignment program STRAP, provides several BLAST methods which can be used along with Biojava. To use this toolbox it is necessary to add strap.jar to the class path. With STRAP-toolbox comes 3 implementations of SequenceBlaster . They invoke the Web service at EBI or a local WU-BLAST or NCBI-BLAST installation.

Web-Proxy: If STRAP fails to communicate with the remote Blast server a possible reason is that a web proxy needs to be specified. This is discussed in Scripting.html.

License: STRAP-toolbox is distributed under the GNU-license. You should read the terms of use for the individual BLAST implementations.

Code example:
import charite.christo.strap.*;
import charite.christo.interfaces.*;
import charite.christo.strap.extensions.Blaster_ebi_ac_uk;
import charite.christo.blast.*;
import charite.christo.*;
import java.util.*;
import javax.swing.*;
import java.io.*;
import static java.lang.System.*;
/**
   java DemoSequenceBlaster

   This demo shows how Blast is used to find sequences that are similar
   to a given Sequence.  For performing large numbers of Blast runs
   please use the locally installed Blast rather than a web service.

   If you are behind a firewall the variable http_proxy must be set.
*/
public class DemoSequenceBlaster {
    public static void main(String[] argv){
        /* Web proxy in environment variable http_proxy */
        Web.setProxyFromShellVariable();

        /* Initialize a SequenceBlaster one of the following:
           Blaster_ebi_ac_uk, Blaster_local_Wu, Blaster_local_NCBI */
        final SequenceBlaster blaster=new Blaster_ebi_ac_uk();
        blaster.setAAQuerySequence("KVFFKAGLLGLLEEMRDDKLAEIITATQARCRGFLM");

        out.print("The following databases are available: "+Arrays.asList(blaster.getAvailableDatabases()));

        /* Show A control panel to watch log messages */
        if (blaster instanceof HasControlPanel) {
            final JFrame f=new JFrame();
            f.setSize(300,300);
            f.getContentPane().add(((HasControlPanel)blaster).getControlPanel());
            f.show();
        }
        blaster.setDatabase(Blaster_ebi_ac_uk.DATABASES_AA[0]);

        /* computation takes a lot of time */
        blaster.compute();
        final ByteArray xml=blaster.getResultXml();

        /* BlastResult is an object oriented model of the Blast Result  */
        final BlastResult result=new BlastResult(xml);
        final File f=new File("output.txt");
        try { 
            final int charactersPerLine=60;
            result.writeFile(f, charactersPerLine);
        } catch(IOException ioex) { out.println("Writing blast result: "+ioex); }
        out.println("The result is found in the file "+f);
        exit(0);
    }
}