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.
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?
2 answers
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.
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.
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.
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
even with the ".." it isnt outputting it correctly.
Have you tried explicitly specifying the full output path to rule out any other issues?
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.
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 "
Log in to answer this question.
You are probably missing specifying correct relative path for the output. You could explicitly provide full path for
-outspecification.but this says, go one folder above, into output and put it there?