[BioPython] Kill blast

Andrew Dalke Andrew Dalke" <dalke@dalkescientific.com
Thu, 20 Sep 2001 11:23:10 -0600


Yair Benita <Y.Benita@pharm.uu.nl>:
> How can I kill the blast process if it takes too long (more
> than 3 min or so)?

On most unix systems, the easiest way is to define a ulimit
on the spawned off BLAST run.

See the man page for bash or whatever your /bin/sh is for details
on how to specific ulimit.

For example,

  % ulimit -t 300
  % python
  Python 2.0 (#4, Dec  8 2000, 21:23:00)
  [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
  Type "copyright", "credits" or "license" for more information.
  >>> while 1: pass
  ...
  CPU time limit exceeded
  %

sets a cpu runtime limit of 5 minutes to any new process.
Then you would run blast and let the OS kill it if it takes
too long.  'Course, you would have to have the code to check
if BLAST exists without output.  I'm not checked how the
current biopython code deals with it.

To make things more complicated, if you use an csh based
shell (like tcsh) then the command is called "limit", as in

[dalke@pw600a Blast]$ limit cputime 1

But popen3, which NCBIStandalone uses, runs /bin/sh.


What does this all mean?  Try using

  blastcmd = "limit -t 300 && blastall"

in the call to run BLAST.

                    Andrew
                    dalke@dalkescientific.com