Looping local blastn in bash
1
0
Entering edit mode
4.4 years ago

Hello,

I have a Folder containing multiple genomes as .fasta files.

strainA.fasta
strainB.fasta
strainC.fasta
....

I have set up a local blast db called "dbGOI.fasta"

I want to blast all the genomes against my local db.

for file in dir
do
   blastn -in *.fasta -db dbGOI.fasta -out blast[strainname].txt
done

But as you might guess, it does not work as intended.

blast bash • 2.7k views
ADD COMMENT
1
Entering edit mode

It should be something like:

for file in *fasta
do
   blastn -in $file -db dbGOI.fasta -out blast$(basename $file .fasta).txt
done

For explanation: the variable yyou use to loop is called file. You call this variable in with $file . to get the name of the fasta without the file-ending you call basename with the variable and the ending you want to remove. with $() you use the output of basename as a string.

I just don't know if it is -in or -query in the blastn function

ADD REPLY
2
Entering edit mode
4.4 years ago
for F in dir/*.fasta
do
   blastn -in $F -db dbGOI.fasta -out ${F%.*}.txt
done
ADD COMMENT

Login before adding your answer.

Traffic: 920 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6