def pbdagcon(m5, t):
script_dir = os.path.dirname(os.path.realpath(__file__))
cmd = ("%s/pbdagcon -t %d -c 1 -m 1 %s" % (script_dir, t, m5)).split()
## hard coded threshold to prevent trimming too many bases
if(t > 100):
return None
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
## if in 5 sec, pbdagcon does not finish, trim 1 base and recursively run it
poll_seconds = 0.25
deadline = time.time() + 5
while time.time() < deadline and proc.poll() == None:
time.sleep(poll_seconds)
if proc.poll() == None:
proc.terminate()
sys.stderr.write("Warning: PBDAGCON timeout! Trimming %d base(s).\n" %(t+1))
stdout, stderr = proc.communicate()
if proc.returncode != 0:
stdout = pbdagcon(m5, t+1)
return stdout
评论列表
文章目录