Commit 532d7279 by John Chodera (MSKCC)

Added Exception handling back.

parent 509dcb40
...@@ -4,6 +4,7 @@ import simtk.openmm ...@@ -4,6 +4,7 @@ import simtk.openmm
import Bio.PDB import Bio.PDB
import os import os
import os.path
import sys import sys
import numpy import numpy
...@@ -26,13 +27,6 @@ class Watchdog: ...@@ -26,13 +27,6 @@ class Watchdog:
def defaultHandler(self): def defaultHandler(self):
raise self raise self
def simulate(pdbcode, pdb_filename): def simulate(pdbcode, pdb_filename):
from simtk.openmm import app from simtk.openmm import app
import simtk.openmm as mm import simtk.openmm as mm
...@@ -103,8 +97,14 @@ def test_build_and_simulate(): ...@@ -103,8 +97,14 @@ def test_build_and_simulate():
print pdbcode print pdbcode
try: try:
# Remove file if it exists already.
input_pdb_filename = 'pdb' + pdbcode + '.ent'
if os.path.exists(input_pdb_filename):
os.remove(input_pdb_filename)
print "Attempting to retrieve PDB code '%s' from %s..." % (pdbcode, PDBList.alternative_download_url) print "Attempting to retrieve PDB code '%s' from %s..." % (pdbcode, PDBList.alternative_download_url)
input_pdb_filename = pdblist.retrieve_pdb_file(pdbcode, pdir='.') input_pdb_filename = pdblist.retrieve_pdb_file(pdbcode, pdir='.')
except Exception as e: except Exception as e:
print str(e) print str(e)
print "Could not download PDB code '%s'" % pdbcode print "Could not download PDB code '%s'" % pdbcode
...@@ -123,9 +123,10 @@ def test_build_and_simulate(): ...@@ -123,9 +123,10 @@ def test_build_and_simulate():
infile = open(input_pdb_filename) infile = open(input_pdb_filename)
outfile = open(output_pdb_filename, 'w') outfile = open(output_pdb_filename, 'w')
timeout_seconds = 30.0 success = True
timeout_seconds = 0.1
watchdog = Watchdog(timeout_seconds) watchdog = Watchdog(timeout_seconds)
try: try:
from pdbfixer.pdbfixer import PDBFixer, PdbStructure from pdbfixer.pdbfixer import PDBFixer, PdbStructure
...@@ -151,11 +152,19 @@ def test_build_and_simulate(): ...@@ -151,11 +152,19 @@ def test_build_and_simulate():
stage = "Done." stage = "Done."
infile.close() infile.close()
outfile.close() outfile.close()
except Watchdog: except Watchdog:
print "timed out fixing PDB %s" % pdbcode print "timed out fixing PDB %s" % pdbcode
# Test simulating this with OpenMM. success = False
except Exception as e:
print str(e)
success = False
watchdog.stop() watchdog.stop()
del watchdog del watchdog
# Test simulating this with OpenMM.
if pdbcode in pdbcodes_to_simulate: if pdbcode in pdbcodes_to_simulate:
watchdog = Watchdog(timeout_seconds) watchdog = Watchdog(timeout_seconds)
try: try:
...@@ -164,7 +173,14 @@ def test_build_and_simulate(): ...@@ -164,7 +173,14 @@ def test_build_and_simulate():
except Watchdog: except Watchdog:
print "PDB code %s timed out in stage '%s'." % (pdbcode, stage) print "PDB code %s timed out in stage '%s'." % (pdbcode, stage)
success = False success = False
except Exception as e:
print str(e)
success = False
watchdog.stop() watchdog.stop()
del watchdog
# Clean up. # Clean up.
os.remove(input_pdb_filename) os.remove(input_pdb_filename)
os.remove(output_pdb_filename) os.remove(output_pdb_filename)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment