Using BLAST+ for nucleotide alignments

It’s quite some time since I needed to run BLAST locally on anything. Here are some quick notes.

First download BLAST:

wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.2.30+-x64-linux.tar.gz
tar xvzf ncbi-blast-2.2.30+-x64-linux.tar.gz
cd ncbi-blast-2.2.30+/bin

Create a new reference database:

./makeblastdb -in ~/genomics/myreference.fasta  -dbtype nucl

In my case I needed to align fastq files. However BLAST only takes fasta. I used to the following to convert the fastqs to fastas:

awk 'BEGIN{n=0;}{if(n%4 == 0) print ">" substr($0,2); if(n%4 == 1) print $0;n++;}' input.fastq > output.fasta

And finally run the alignment:

./blastn -db ~/genomics/myreference.fasta -query ./output.fasta