[BioPython] Problems with Bio.Application.generic_run()

Steffi Gebauer-Jung gebauer-jung at ice.mpg.de
Wed Aug 6 10:37:49 EDT 2003


Hello,

using the Bio.Application package, I got some trouble.

When using generic_run() to run blast, which in this case produced a 
--very-- large output and several warnings, the blast process fell asleep.
Running this blast as standalone, there were no problems.

Looking around in the Python Reference etc. I found that there is 
possibly a dead lock of parent and child processes.

For now I solved this problem using a recipe from the Python Cookbook as 
follows:

------------------------------------------------------------------------------------------- 

def generic_run(commandline):
   """Run an application with the given commandline.

   This expects a pre-built commandline that derives from
   AbstractCommandline, and returns a ApplicationResult object
   to get results from a program, along with handles of the
   standard output and standard error.

   This is a deadlock save version.
   It was derived from 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52296
   Comment: Differnet Approach: Using Tempfiles, Tobias Polzin, 2002/09/03
   """
   outfile = tempfile.mktemp()
   errfile = tempfile.mktemp()
   errorlevel = os.system("( %s ) > %s 2> %s" % 
(str(commandline),outfile,errfile)) >> 8

   r_out = open(outfile,"r").read()
   os.remove(outfile)

   e_out = open(errfile,"r").read()
   os.remove(errfile)

   return ApplicationResult(commandline), \
          File.UndoHandle(StringIO.StringIO(r_out)), \
          File.UndoHandle(StringIO.StringIO(e_out))
------------------------------------------------------------------------------------------- 


Please could you have a look at this quite central method or tell me a 
more save one to use instead?

Thanks in advance, Steffi




More information about the BioPython mailing list