Ok, so I am using the NcbiblastxCommandline wrapper to execute a BLAST search on a custom database.
cline = NcbiblastxCommandline(cmd='blastx', query=temp_path, out=blast_path, subject=path, outfmt=5, max_target_seqs=1)
os.system(str(cline))
The funny thing is that it is working just fine when I run those from the command line. However, inside my script, when I execute the exact same commands, I end up getting a blank xml results file instead of the actual results. I thought that maybe the script was not waiting for the process to complete, so I tried using subprocess and subprocess.wait(). That didn't work. I also tried using something else like time.sleep(60) which is plenty time enough for it to finish. That didn't work. So I am a bit out of ideas and am very puzzled as to why it works perfectly when executing as one-liners in the command shell after >>python but won't work from a script. Thanks for any suggestions!
Have you tried to run it like this?
What do
stdout
andstderr
say?In addition to Philipp's good question, add a
print(str(cline))
to see what the command Biopython tries to run for you is exactly.If you really want to use
os.system(...)
then you need to check for a non-zero return code (indicating an error).