Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
408cfe6c
Commit
408cfe6c
authored
Aug 12, 2015
by
Robert McGibbon
Browse files
Fix two tests for python3
parent
ff0cdceb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
20 deletions
+29
-20
wrappers/python/tests/TestGromacsTopFile.py
wrappers/python/tests/TestGromacsTopFile.py
+20
-16
wrappers/python/tests/TestPdbFile.py
wrappers/python/tests/TestPdbFile.py
+9
-4
No files found.
wrappers/python/tests/TestGromacsTopFile.py
View file @
408cfe6c
...
...
@@ -3,12 +3,16 @@ from validateConstraints import *
from
simtk.openmm.app
import
*
from
simtk.openmm
import
*
from
simtk.unit
import
*
from
simtk.openmm.app.gromacstopfile
import
_defaultGromacsIncludeDir
import
simtk.openmm.app.element
as
elem
GROMACS_INCLUDE
=
_defaultGromacsIncludeDir
()
@
unittest
.
skipIf
(
not
os
.
path
.
exists
(
GROMACS_INCLUDE
),
'GROMACS is not installed'
)
class
TestGromacsTopFile
(
unittest
.
TestCase
):
"""Test the GromacsTopFile.createSystem() method."""
def
setUp
(
self
):
"""Set up the tests by loading the input files."""
...
...
@@ -20,15 +24,15 @@ class TestGromacsTopFile(unittest.TestCase):
def
test_NonbondedMethod
(
self
):
"""Test all five options for the nonbondedMethod parameter."""
methodMap
=
{
NoCutoff
:
NonbondedForce
.
NoCutoff
,
CutoffNonPeriodic
:
NonbondedForce
.
CutoffNonPeriodic
,
CutoffPeriodic
:
NonbondedForce
.
CutoffPeriodic
,
methodMap
=
{
NoCutoff
:
NonbondedForce
.
NoCutoff
,
CutoffNonPeriodic
:
NonbondedForce
.
CutoffNonPeriodic
,
CutoffPeriodic
:
NonbondedForce
.
CutoffPeriodic
,
Ewald
:
NonbondedForce
.
Ewald
,
PME
:
NonbondedForce
.
PME
}
for
method
in
methodMap
:
system
=
self
.
top1
.
createSystem
(
nonbondedMethod
=
method
)
forces
=
system
.
getForces
()
self
.
assertTrue
(
any
(
isinstance
(
f
,
NonbondedForce
)
and
f
.
getNonbondedMethod
()
==
methodMap
[
method
]
self
.
assertTrue
(
any
(
isinstance
(
f
,
NonbondedForce
)
and
f
.
getNonbondedMethod
()
==
methodMap
[
method
]
for
f
in
forces
))
def
test_ff99SBILDN
(
self
):
...
...
@@ -49,8 +53,8 @@ class TestGromacsTopFile(unittest.TestCase):
"""Test to make sure the nonbondedCutoff parameter is passed correctly."""
for
method
in
[
CutoffNonPeriodic
,
CutoffPeriodic
,
Ewald
,
PME
]:
system
=
self
.
top1
.
createSystem
(
nonbondedMethod
=
method
,
nonbondedCutoff
=
2
*
nanometer
,
system
=
self
.
top1
.
createSystem
(
nonbondedMethod
=
method
,
nonbondedCutoff
=
2
*
nanometer
,
constraints
=
HBonds
)
cutoff_distance
=
0.0
*
nanometer
cutoff_check
=
2.0
*
nanometer
...
...
@@ -63,8 +67,8 @@ class TestGromacsTopFile(unittest.TestCase):
"""Test to make sure the ewaldErrorTolerance parameter is passed correctly."""
for
method
in
[
Ewald
,
PME
]:
system
=
self
.
top1
.
createSystem
(
nonbondedMethod
=
method
,
ewaldErrorTolerance
=
1e-6
,
system
=
self
.
top1
.
createSystem
(
nonbondedMethod
=
method
,
ewaldErrorTolerance
=
1e-6
,
constraints
=
HBonds
)
tolerance
=
0
tolerance_check
=
1e-6
...
...
@@ -86,9 +90,9 @@ class TestGromacsTopFile(unittest.TestCase):
topology
=
self
.
top1
.
topology
for
constraints_value
in
[
None
,
HBonds
,
AllBonds
,
HAngles
]:
for
rigidWater_value
in
[
True
,
False
]:
system
=
self
.
top1
.
createSystem
(
constraints
=
constraints_value
,
system
=
self
.
top1
.
createSystem
(
constraints
=
constraints_value
,
rigidWater
=
rigidWater_value
)
validateConstraints
(
self
,
topology
,
system
,
validateConstraints
(
self
,
topology
,
system
,
constraints_value
,
rigidWater_value
)
def
test_ImplicitSolvent
(
self
):
...
...
@@ -102,8 +106,8 @@ class TestGromacsTopFile(unittest.TestCase):
"""Test that solventDielectric and soluteDielectric are passed correctly.
"""
system
=
self
.
top2
.
createSystem
(
implicitSolvent
=
OBC2
,
solventDielectric
=
50.0
,
system
=
self
.
top2
.
createSystem
(
implicitSolvent
=
OBC2
,
solventDielectric
=
50.0
,
soluteDielectric
=
0.9
)
found_matching_solvent_dielectric
=
False
found_matching_solute_dielectric
=
False
...
...
@@ -115,12 +119,12 @@ class TestGromacsTopFile(unittest.TestCase):
found_matching_solute_dielectric
=
True
if
isinstance
(
force
,
NonbondedForce
):
self
.
assertEqual
(
force
.
getReactionFieldDielectric
(),
1.0
)
self
.
assertTrue
(
found_matching_solvent_dielectric
and
self
.
assertTrue
(
found_matching_solvent_dielectric
and
found_matching_solute_dielectric
)
def
test_HydrogenMass
(
self
):
"""Test that altering the mass of hydrogens works correctly."""
topology
=
self
.
top1
.
topology
hydrogenMass
=
4
*
amu
system1
=
self
.
top1
.
createSystem
()
...
...
wrappers/python/tests/TestPdbFile.py
View file @
408cfe6c
import
sys
import
unittest
from
simtk.openmm.app
import
*
from
simtk.openmm
import
*
from
simtk.unit
import
*
import
simtk.openmm.app.element
as
elem
import
cStringIO
if
sys
.
version_info
>=
(
3
,
0
):
from
StringIO
import
StringIO
else
:
from
cStringIO
import
StringIO
class
TestPdbFile
(
unittest
.
TestCase
):
"""Test the PDB file parser"""
def
test_Triclinic
(
self
):
"""Test parsing a file that describes a triclinic box."""
pdb
=
PDBFile
(
'systems/triclinic.pdb'
)
...
...
@@ -43,9 +48,9 @@ class TestPdbFile(unittest.TestCase):
def
test_WriteFile
(
self
):
"""Write a file, read it back, and make sure it matches the original."""
pdb1
=
PDBFile
(
'systems/triclinic.pdb'
)
output
=
cStringIO
.
StringIO
()
output
=
StringIO
()
PDBFile
.
writeFile
(
pdb1
.
topology
,
pdb1
.
positions
,
output
)
input
=
cStringIO
.
StringIO
(
output
.
getvalue
())
input
=
StringIO
(
output
.
getvalue
())
pdb2
=
PDBFile
(
input
)
output
.
close
();
input
.
close
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment