Question

So I'm writing a script to run a blast query, which I hardcoded variables for at this point (just to make sure they weren't getting messed up). Which is:

blastCLine = NcbiblastnCommandline(query="temp.fasta", db="refseq_rna", outfmt=5, out="test.txt", evalue=0.05)
stdt, stdr = blastCLine()
print stdt
print stdr

And I get nothing, output file is blank, and no error or anything. If I use the blast command from blastCLine on the command line, it works. If i use the above code in the python environment, it works. Just not working in my script.

I've been googling and looking at tons of examples. From what I can tell it should work. I've tried changing it to blastx, and using cmd="blastn" to no avail, also. Any suggestions?

Was it helpful?

Solution

In this line, you are generating the BLAST command with arguments. If you print blastCLine, you will see the BLAST command:

>>> blastCLine = NcbiblastnCommandline(query="temp.fasta", db="refseq_rna", outfmt=5, out="test.txt", evalue=0.05)
>>> print blastCLine
blastn -out test.txt -outfmt 5 -query /home/mamun/temp.fasta -db refseq_rna -evalue 0.05

Now, with stdt, stdr = blastCLine(), you are executing the command from python. What happens here, you get a new output that overwrites the existing stuffs in test.txt file. You can check this by deleting the existing test.txt file and run the above two commands again from python shell. As the command runs successfully and it doesn't generate any output or error, both stdout and stderr get empty string after the command runs successfully. Hope, the explanation helps to understand what's happening here. If it doesn't even work, try to execute it with os.system:

>>> import os
>>> os.system(str(blastCLine))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top