Protocol // BLAST
BLASTn
Create a database and search for homologues in nt fasta files and recover sequences from NCBI.
BLAST
scheduleMarch 31, 2026
Make the Database
info
For output format options, see: https://www.biostars.org/p/161457/
makeblastdb -dbtype nucl -in Sequences.fna -input_type fasta
Run BLASTn
Run locally against a custom database:
blastn -db Sequences.fna -query 16S_sequences.fna -max_target_seqs 10 -out Blast_16S_Sequences.tab -outfmt "6 qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore" -word_size 5 -perc_identity 90 -num_threads 10
Run via SLURM against the nt database:
#!/bin/bash
#SBATCH --job-name=Blastn
#SBATCH --time=
#SBATCH --cpus-per-task=
#SBATCH --mem=
#SBATCH -w
#SBATCH --partition=
#SBATCH --output=%x_%j_stdout.txt
#SBATCH --error=%x_%j_stderr.txt
#SBATCH --mail-type=ALL
#SBATCH --mail-user=
export PATH="/home/blast:$PATH"
blastn -db nt -query Sequences.faa -max_target_seqs 10 -out BLAST_Results.tab -outfmt "6 qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore staxids" -word_size 5 -evalue 0.00001 -num_threads 15
Include the header in the first line of the BLAST results:
sed -i '1i qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore staxids' Blast_Results.tab
info
Make sure to check if your table has the last column (Taxonomy information).
Recover Sequences from NCBI
Install Entrez:
#Create an environment in which you can add Entrez Direct
conda create --name entrez
#Activate this new environment
conda activate entrez
#Install Entrez
conda install -c bioconda entrez-direct
Create a list with the accession numbers of the sequences to recover:
nano list.txt
ABO08866.1
AFA39020.1
AFA39042.1
AFI78392.1
AOQ24367.1
APC08827.1
ATY72478.1
Change the file from a column to a CSV:
cat list.txt | tr "\n" "," | sed 's/,$//' > list.csv
Make an executable script:
sed 's/^/efetch -db protein -format fasta -id /' list.csv > list.sh
chmod +x list.sh
It should look like this:
efetch -db protein -format fasta -id ABO08866.1,AFA39020.1,AFA39042.1,AFI78392.1,AOQ24367.1,APC08827.1,ATY72478.1
Run the script:
bash list.sh > list.faa