[Biopython-dev] [Bug 2480] Local BLAST fails: Spaces in Windows file-path values
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Tue Sep 30 15:34:37 UTC 2008
http://bugzilla.open-bio.org/show_bug.cgi?id=2480
------- Comment #26 from biopython-bugzilla at maubp.freeserve.co.uk 2008-09-30 11:34 EST -------
(In reply to comment #25)
> Using subprocess I am now able to get Biopython to run local
> BLAST successfully in Windows when spaces are present in
> file-path values.
Good - but have you been able to try your code on Linux or the Mac?
> With a conditional statement like the one below, following
> type of modification will still let Biopython remain
> compatible with old versions of Python that cannot use
> subprocess:
If we can take advantage of the subprocess module in a cross platform way, then
yes, a try/except fall back for python 2.3 would be nice. As of
Blast/NCBIStandalone.py CVS revision 1.79, there is now only one place in this
module where such a change can be applied (rather than three places).
> # replace lines 1680-1682 of CVS 1.78 of Bio/Blast/NCBIStandalone.py with
> these
>
> try:
> import subprocess
> my_process = subprocess.Popen(" ".join([blastcmd] + params),
> stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
> shell=False)
Using shell=False works while shell=True fails on Windows (I tested on Windows
XP with Python 2.5 from IDLE). However, the opposite is true on Mac OS X with
python 2.5 from IDLE. This is a pain.
Also you don't need the stdin=... argument as we don't want to give BLAST any
piped input.
> r, e = my_process.communicate('through stdin to stdout')
> return r, e
First of all, there is no reason to pipe in the text "through stdin to stdout"
into BLAST's standard input. I guess you blindly cut and paste this from a
google search. Instead just:
r, e = my_process.communicate()
You should NOT be using the communicate method, as it will read in an buffer
all the output and wait for BLAST to finish. As BLAST output (especially XML
output) can be larger (gigabytes) we must not load this into memory. Instead:
r = my_process.stdout
e = my_process.stderr
> except:
> w, r, e = os.popen3(" ".join([blastcmd] + params))
> w.close()
> return File.UndoHandle(r), File.UndoHandle(e)
>
> The test.py file I tested:
>
> # Note the unusual ways to specify the database, input file, and BLAST
> locations
> my_blast_db = r'"\"C:\Documents and Settings\patnaik\My
> Documents\blast\bin\hairpin.db\""'
> my_blast_file = r'"C:\Documents and Settings\patnaik\My
> Documents\blast\bin\30a.seq"'
> my_blast_exe = r"C:\Documents and Settings\patnaik\My
> Documents\blast\bin\blastall.exe"
I've been having trouble with specifying BLAST databases with spaces in the
path. Have you been able to demonstrate this with more than one database?
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list