Question: Looping local blastn in bash
0
gravatar for maximilian.mayerhofer
2.8 years ago by
maximilian.mayerhofer30 wrote:

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.

bash blast • 1.7k views
ADD COMMENTlink modified 2.8 years ago by Pierre Lindenbaum131k • written 2.8 years ago by maximilian.mayerhofer30
1

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 REPLYlink modified 2.8 years ago • written 2.8 years ago by michael.ante3.6k
2
gravatar for Pierre Lindenbaum
2.8 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum131k wrote:
for F in dir/*.fasta
do
   blastn -in $F -db dbGOI.fasta -out ${F%.*}.txt
done
ADD COMMENTlink written 2.8 years ago by Pierre Lindenbaum131k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1321 users visited in the last hour