[BioPython] BLAST subprocess problem with a GUI

Stefanie Lück lueck at ipk-gatersleben.de
Mon Feb 2 02:37:35 EST 2009


Hi Peter and the rest of the mailing list!

I'm using Biopython 1.49b and Python 2.5.

I tried your suggestion and changed \Blast\NCBIStandalone.py as you said:

        import subprocess, sys
        #We don't need to supply any piped input, but we setup the
        #pipe anyway as a work around for a python bug if this is
        #called from a Windows GUI program.  For details, see:
        #http://bugs.python.org/issue1124861
        blast_process = subprocess.Popen(cmd_string,
                                         stdin=subprocess.PIPE,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE,
                                         shell=(sys.platform!="win32"))
        blast_process.stdin.close()
        return blast_process.stdout, blast_process.stderr

And after comipilation with py2exe it's seem to work! In addition I changed
\Application\__init__.py in function generic_run
\ClustalW\__init__.py in function do_alignment

in the same way because I got the same error message when I used Primer3 and 
ClustalW.
I tried up to now only on view Windows XP PC's but it's looks like the 
problem is solved!

Finally I can release the tool for testing! Thanks to all for their help!

Thanks a lot Peter and sorry for the late reply!

Kind regards
Stefanie

----- Original Message ----- 
From: "Peter" <biopython at maubp.freeserve.co.uk>
To: "Stefanie Lück" <lueck at ipk-gatersleben.de>
Cc: <biopython at lists.open-bio.org>
Sent: Wednesday, January 28, 2009 6:45 PM
Subject: [BioPython] BLAST subprocess problem with a GUI


On Tue, Jan 13, 2009 at 10:41 AM, Peter <biopython at maubp.freeserve.co.uk> 
wrote:
> On Tue, Jan 13, 2009 at 7:38 AM, Stefanie Lück <lueck at ipk-gatersleben.de> 
> wrote:
>> I was a little bit to optimistic...
>>
>> After compilation with py2exe, blast hangs. In the log file of py2exe
>> I get the following error message:
>>
>>  Traceback (most recent call last):
>>  File "prim_search.pyc", line 464, in make_xml
>>
>>  File "Bio\Blast\NCBIStandalone.pyc", line 1668, in blastall
>>  File "Bio\Blast\NCBIStandalone.pyc", line 1992, in _invoke_blast
>>  File "subprocess.pyc", line 586, in __init__
>>  File "subprocess.pyc", line 681, in _get_handles
>>  File "subprocess.pyc", line 722, in _make_inheritable
>>  TypeError: an integer is required
>>
>> Any ideas?
>> Stefanie
>
> Are you using Biopython 1.49?
>
> What version of Python are you using here?  (Python 2.3 is handled a
> little differently, as it does not have the subprocess module).
>
> Can you confirm the exact same code works fine run from Python
> directly (via IDLE or the commandline?), but fails via py2exe?
>
> Are you running the py2exe compiled version from the Windows command
> line?  Can you try that, even thought you said it was a GUI program.
> This might be related to the following python bug on Windows to do
> with pipe redirection, http://bugs.python.org/issue1124861
> If so, I think there is a suggested work around we can try (this will
> require a change to the Biopython code).
>
> Peter

Hi Stefanie,

Did you make any progress with this problem?  If as I suspect the
problem is the python subprocess bug
http://bugs.python.org/issue1124861 then you can try the suggested
work around in Biopython, by modifying the _invoke_blast function in
Bio\Blast\NCBIStandalone.py file as follows:

        import subprocess, sys
        #We don't need to supply any piped input, but we setup the
        #pipe anyway as a work around for a python bug if this is
        #called from a Windows GUI program.  For details, see:
        #http://bugs.python.org/issue1124861
        blast_process = subprocess.Popen(cmd_string,
                                         stdin=subprocess.PIPE,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE,
                                         shell=(sys.platform!="win32"))
        blast_process.stdin.close()
        return blast_process.stdout, blast_process.stderr

I've checked this change doesn't seem to break anything - but does it
help for your GUI program?

Peter



More information about the BioPython mailing list