首页 > 代码库 > Run a local BLAST

Run a local BLAST

In this context, ‘local’ means you are running BLAST on your own server, not at NCBI or anyone else’s server. This gives you the flexibility of comparing your query either against precomputed databases (like NR, Swissprot, trEMBL, etc.) or against a customized database, containing a specific set of sequences.

 

Query Sequence Set: contigs.supercontigs.filtered_012808.fasta

Reference Database: all_gene-CDS-111313.txt 

(Hint: choose among: BLASTP, BLASTN, BLASTX, TBLASTN, TBLASTX)

BLAST Reference: http://www.ncbi.nlm.nih.gov/BLAST/blast_program.shtml

 

Generate a customized search database

$ makeblastdb -dbtype nucl -in contigs.supercontigs.filtered_012808.fasta

 

BLAST the all_gene-CDS-111313.txt 

$ blastn -query all_gene-CDS-111313.txt -db contigs.supercontigs.filtered_012808.fasta-outfmt 6 -out gene.blastn

 

Wait until it finishes then take a look at the output:

$ less gene.blastn

 

BLAST tabular format (as specified in -outfmt 6) has multiple columns, and is the easiest output format to work with. http://www.pangloss.com/wiki/Blast

 

Cout the column (-f 2):

$ cut -f 2 gene.blastn | sort -u > hits.ids

 

How many unique hits did we get? This equals to the number of lines in the file:

$ wc -l hits.ids

 

It appears we are getting lots of hits. We may need to go back to the BLAST command to add an E-value cutoff to be more stringent. How to add E-value cutoff? Let’s look at the help for tblastn

$ blastn -help

 

Now run BLAST with more stringent settings (E-value cutoff: 1e-20):

$ blastn -query all_gene-CDS-111313.txt -db contigs.supercontigs.filtered_012808.fasta -outfmt 6 -out gene.blastn -evalue 1e-20

$ cut -f 2 gene.blastn| sort -u > hits.ids

 

Extract sequences from contigs.supercontigs.filtered_012808.fasta

The command faSomeRecords can be used to extract multiple sequences, now let’s get all the BLAST hits to retrieve a gene family.

$ faSomeRecords contigs.supercontigs.filtered_012808.fasta hits.ids hits.fasta

Run a local BLAST