DIAMOND BLAST
Create a database and search for homologues in amino acid FASTA files.
Installation
Downloading the tool
wget http://github.com/bbuchfink/diamond/releases/download/v2.1.9/diamond-linux64.tar.gz
tar xzf diamond-linux64.tar.gz
Add to PATH
export PATH=/Installation_folder:$PATH
Create a Database
Make sure both the query file (what will be searched) and the database file (where the query will be searched) contain amino acid sequences.
In case you need to convert your nucleotide sequences to amino acid sequences, run Prodigal first:
for i in *.fna ; do prodigal -i $i -o output.txt -a $i.faa ; done
To create the database, run:
diamond makedb --in aminoacids_sequences.faa --db generated_database
The input file is a FASTA file containing amino acid sequences (aminoacids_sequences.faa). It will generate a database file (generated_database.dmnd) that will be used as the search database.
Create the DB containing taxonomic info
diamond makedb --in /home/DB/DIAMOND_2022/NCBI_NR/nr.gz --db ncbi_nr_06-16-22 --taxonmap /home/Database/DIAMOND/prot.accession2taxid.FULL.gz --taxonnodes /home/Database/DIAMOND/nodes.dmp --taxonnames /home/Database/DIAMOND/names.dmp
Prepare the Query File
The output file from Prodigal (translated amino acid sequences) needs to be processed before being used in DIAMOND.
The first step is to delete all characters after the first space in the headers:
for i in *.faa; do sed -i 's/\s.*$//' $i; done
The * character should be deleted from the file:
for i in *.faa; do sed -i 's/*//g' $i; done
Then the sequences should be transformed to one-liners:
for i in *.faa ; do perl -lne 'if(/^(>.*)/){ $head=$1 } else { $fa{$head} .= $_ } END{ foreach $s (sort(keys(%fa))){ print "$s\n$fa{$s}\n" }}' $i >> $i.1L.faa ; done
A new file with the extension .1L.faa will be created in the directory. This file should be used as input in DIAMOND.
Run DIAMOND BLAST
diamond blastp --db generated_databasse.dmnd --query seqeunces2search.faa --out Results.tab --threads 3 --outfmt 6 qtitle stitle pident length qstart qend sstart send qlen slen qcovhsp scovhsp evalue bitscore --max-target-seqs 10 --evalue 0.000001 --id 30
Run recovering taxonomic information
/home/Database/DIAMOND/diamond blastp --db /home/Database/DIAMOND/ncbi_nr_06-16-22.dmnd --query seqeunces2search.faa --out Results.tab --threads 10 --outfmt 6 qtitle stitle pident length qstart qend sstart send evalue bitscore staxids sscinames sskingdoms skingdoms sphylums --max-target-seqs 3
Add the Header to Your Results
sed -i '1i\qtitle\tstitle\tpident\tlength\tqstart\tqend\tsstart\tsend\tqlen\tslen\tqcovhsp\tscovhsp\tevalue\tbitscore\tDB' Results.tab
Recover the Sequences from the Query
Get the header of the sequences in the results
for i in *.mcr ; do cut -f 1 $i > $i.txt ; done
Recover the sequences from the query
pullseq -i seqeunces2search.faa -n Header_of_interest.txt Recovered_sequences_of_interest.faa