Question: Blast Output not in correct dir
0
gravatar for maximilian.mayerhofer
13 months ago by
maximilian.mayerhofer20 wrote:

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 • 494 views
ADD COMMENTlink modified 13 months ago • written 13 months ago by maximilian.mayerhofer20

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

ADD REPLYlink modified 13 months ago • written 13 months ago by genomax67k
-out ../output/${F%.*}.xml

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

ADD REPLYlink written 13 months ago by maximilian.mayerhofer20
1
gravatar for maximilian.mayerhofer
13 months ago by
maximilian.mayerhofer20 wrote:

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 COMMENTlink modified 13 months ago • written 13 months ago by maximilian.mayerhofer20

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 REPLYlink written 13 months ago by jrj.healey12k
0
gravatar for jrj.healey
13 months ago by
jrj.healey12k
United Kingdom
jrj.healey12k wrote:

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 COMMENTlink modified 13 months ago • written 13 months ago by jrj.healey12k

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 REPLYlink written 13 months ago by maximilian.mayerhofer20

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 REPLYlink written 13 months ago by jrj.healey12k

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

ADD REPLYlink written 13 months ago by maximilian.mayerhofer20

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

ADD REPLYlink written 13 months ago by jrj.healey12k

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 REPLYlink written 13 months ago by maximilian.mayerhofer20
1

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 REPLYlink modified 13 months ago • written 13 months ago by lieven.sterck4.8k
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: 2215 users visited in the last hour