Blast Output not in correct dir
2
1
Entering edit mode
6.0 years ago

So, I have a directory:

Pipeline

  • database: contains the custom blast database
  • scripts
  • genomes
  • output

I want my local blast.sh script ( in the script folder) to take all the *.fna of the genomes folder and put results in the output folder.

So i specified the following:

for F in ../genomes/*.fna
do
    blastn -query  $F -db ../database/blastdb/dbGOI.fasta -outfmt 5 -out ../output/${F%.*}.xml
done

But when I run this, all of my output .xml files are in the genome folder and I do not know why since I specified that in the code.

Am I missing something?

blast • 2.2k views
ADD COMMENT
0
Entering edit mode

You are probably missing specifying correct relative path for the output. You could explicitly provide full path for -out specification.

ADD REPLY
0
Entering edit mode
-out ../output/${F%.*}.xml

but this says, go one folder above, into output and put it there?

ADD REPLY
1
Entering edit mode
6.0 years ago

So, since that seemed to be a bug, I used the following workaround:

blastn -query  $F -db ../database/blastdb/dbGOI.fasta -outfmt 5 >> ../output/results.xml

since I used cat to put all theoutput files together, I save a line of code.

ADD COMMENT
0
Entering edit mode

Glad to see you got something to work, but I can assure you it won't be a bug with the blast suite. It's an extremely well tested and widely used tool, so there will still be an error in how you're invoking it.

ADD REPLY
0
Entering edit mode
6.0 years ago
Joe 21k

Remember the relative path will be based on where your current working directory is, not where the script is. For this to work as you intend, you would have to do the following every time:

cd /dir/scripts
bash ./run_blast.sh

Else, ensure you're providing non-relative file paths the whole time.

ADD COMMENT
0
Entering edit mode

problem is, even if I am in the script dir, the blast result are put into the genomes dir and not in the output dir.

ADD REPLY
0
Entering edit mode

I just tried on our server with the following command:

blastn -task blastn -db /blastdb/nt/nt -query newseqs.fa -outfmt 5 -out output/myseqs.xml -perc_identity 99

I was inside the directory where newseqs.fa was, and the output directory is (relative): ./output/. The myseqs.xml file appeared in that folder without a problem.

Your variable may not be expanding correctly. Try changing:

../output/${F%.*}.xml

to

../output/"${F%.*}".xml
ADD REPLY
0
Entering edit mode

even with the ".." it isnt outputting it correctly.

ADD REPLY
0
Entering edit mode

Have you tried explicitly specifying the full output path to rule out any other issues?

ADD REPLY
0
Entering edit mode

Jep, I tried full path, relative path or no path at all but everytime ( also with no specific path) it gets put into the genomes dir.

ADD REPLY
1
Entering edit mode

as jrj.healey said, likely you variable is not expanded correctly. I would not be surprised to see that you are writing the output to something like : ../output/../genome/<outfile> .

Try running the same loop without doing the blast but simply echo the ../output/${F%.*}.xml part and see what that prints.

And as indicated by jrj.healey as well: take special care of the use of the "

ADD REPLY

Login before adding your answer.

Traffic: 2140 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