Commit a5e76b21 by Matthew Harrigan

Print function

parent 05fea2f4
from __future__ import print_function
import pdbfixer import pdbfixer
import simtk.openmm import simtk.openmm
...@@ -79,7 +80,7 @@ def simulate(pdbcode, pdb_filename): ...@@ -79,7 +80,7 @@ def simulate(pdbcode, pdb_filename):
del context, integrator del context, integrator
print "Simulation completed: potential = %.3f kcal/mol" % potential print("Simulation completed: potential = %.3f kcal/mol" % potential)
return return
...@@ -105,8 +106,8 @@ def test_build_and_simulate(): ...@@ -105,8 +106,8 @@ def test_build_and_simulate():
failures = list() failures = list()
for pdbcode in pdbcodes_to_build: for pdbcode in pdbcodes_to_build:
print "------------------------------------------------" print("------------------------------------------------")
print pdbcode print(pdbcode)
output_pdb_filename = 'output.pdb' output_pdb_filename = 'output.pdb'
...@@ -152,14 +153,14 @@ def test_build_and_simulate(): ...@@ -152,14 +153,14 @@ def test_build_and_simulate():
except Watchdog: except Watchdog:
message = "timed out in stage %s" % stage message = "timed out in stage %s" % stage
print message print(message)
failures.append((pdbcode, Exception(message))) failures.append((pdbcode, Exception(message)))
except Exception as e: except Exception as e:
print "EXCEPTION DURING BUILD" print("EXCEPTION DURING BUILD")
#import traceback #import traceback
#print traceback.print_exc() #print traceback.print_exc()
print str(e) print(str(e))
failures.append((pdbcode, e)) failures.append((pdbcode, e))
watchdog.stop() watchdog.stop()
...@@ -173,14 +174,14 @@ def test_build_and_simulate(): ...@@ -173,14 +174,14 @@ def test_build_and_simulate():
except Watchdog: except Watchdog:
message = "timed out in simulation" message = "timed out in simulation"
print message print(message)
failures.append((pdbcode, Exception(message))) failures.append((pdbcode, Exception(message)))
except Exception as e: except Exception as e:
print "EXCEPTION DURING SIMULATE" print("EXCEPTION DURING SIMULATE")
#import traceback #import traceback
#print traceback.print_exc() #print traceback.print_exc()
print str(e) print(str(e))
failures.append((pdbcode, e)) failures.append((pdbcode, e))
watchdog.stop() watchdog.stop()
...@@ -189,21 +190,21 @@ def test_build_and_simulate(): ...@@ -189,21 +190,21 @@ def test_build_and_simulate():
# Clean up. # Clean up.
os.remove(output_pdb_filename) os.remove(output_pdb_filename)
print "------------------------------------------------" print("------------------------------------------------")
if len(failures) != 0: if len(failures) != 0:
print "" print("")
print "SUMMARY OF FAILURES:" print("SUMMARY OF FAILURES:")
print "" print("")
for failure in failures: for failure in failures:
(pdbcode, exception) = failure (pdbcode, exception) = failure
print "%6s : %s" % (pdbcode, str(exception)) print("%6s : %s" % (pdbcode, str(exception)))
print "" print("")
raise Exception("Build test failed on one or more PDB files.") raise Exception("Build test failed on one or more PDB files.")
else: else:
print "All tests succeeded." print("All tests succeeded.")
if __name__ == '__main__': if __name__ == '__main__':
test_build_and_simulate() test_build_and_simulate()
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