This isnt my usual way if doing things but because im using Plone it has to be done this way.
The function below takes a variable "x" which is the query sequence. Its is then formatted to a blast-able format and then blasted against the database. When results are retuned the file is empty. Any idea why? I had this working but now its not...
def print_query(x):
f = open('/home/rv/ncbi-blast-2.2.23+/db/test.txt', 'w')
f.write(x)
from subprocess import Popen
Popen(["formatdb", "-p", "T", "-i", "/home/rv/ncbi-blast-2.2.23+/db/test.txt"])
Popen(["blastall", "-d", "/home/rv/ncbi-blast-2.2.23+/db/vdatabase.fasta", "-i", "/home/rv/ncbi-blast-2.2.23+/db/test.txt", "-p", "blastp", "-m", "8", "-e", "0.01", "-o", "/home/rv/ncbi-blast-2.2.23+/db/output.blast"])
return open('/home/rv/ncbi-blast-2.2.23+/db/output.blast', 'r').read()
P.S. I know im using the outdated BLAST I'm planning on switching when i have this working
There is no need to call
sleep
explicitly. Thesubprocess.call()
will wait for the process to finish. So would thewait()
method on thepopen
object.The simplest might be just to add
.wait()
to the end of the 2 lines that start with "Popen"Would
time.sleep()
work?