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
16fdf4a8
"vscode:/vscode.git/clone" did not exist on "6a82ea51f237e61c1c2b3eaff2ade0f8cd32a49b"
Commit
16fdf4a8
authored
Aug 08, 2015
by
Jason Swails
Browse files
Add test cases for PDBxReporter
parent
8c91abb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
wrappers/python/tests/TestPdbxFile.py
wrappers/python/tests/TestPdbxFile.py
+64
-0
No files found.
wrappers/python/tests/TestPdbxFile.py
View file @
16fdf4a8
...
...
@@ -3,6 +3,7 @@ from simtk.openmm.app import *
from
simtk.openmm
import
*
from
simtk.unit
import
*
import
simtk.openmm.app.element
as
elem
import
os
class
TestPdbxFile
(
unittest
.
TestCase
):
"""Test the PDBx/mmCIF file parser"""
...
...
@@ -48,6 +49,69 @@ class TestPdbxFile(unittest.TestCase):
diff
=
abs
(
p1
[
i
]
-
p2
[
i
])
/
scale
self
.
assertTrue
(
diff
<
tol
)
def
testReporterImplicit
(
self
):
""" Tests the PDBxReporter without PBC """
parm
=
AmberPrmtopFile
(
'systems/alanine-dipeptide-implicit.prmtop'
)
system
=
parm
.
createSystem
()
sim
=
Simulation
(
parm
.
topology
,
system
,
VerletIntegrator
(
1
*
femtoseconds
),
Platform
.
getPlatformByName
(
'Reference'
))
sim
.
context
.
setPositions
(
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
).
getPositions
())
sim
.
reporters
.
append
(
PDBxReporter
(
'test.cif'
,
1
))
sim
.
step
(
10
)
pdb
=
PDBxFile
(
'test.cif'
)
self
.
assertEqual
(
len
(
list
(
pdb
.
topology
.
atoms
())),
len
(
list
(
parm
.
topology
.
atoms
())))
self
.
assertEqual
(
len
(
list
(
pdb
.
topology
.
residues
())),
len
(
list
(
parm
.
topology
.
residues
())))
for
res1
,
res2
in
zip
(
pdb
.
topology
.
residues
(),
parm
.
topology
.
residues
()):
self
.
assertEqual
(
res1
.
name
,
res2
.
name
)
for
atom1
,
atom2
in
zip
(
res1
.
atoms
(),
res2
.
atoms
()):
self
.
assertEqual
(
atom1
.
name
,
atom2
.
name
)
positions
=
pdb
.
getPositions
(
frame
=
9
)
self
.
assertFalse
(
all
(
x1
==
x2
for
x1
,
x2
in
zip
(
positions
,
pdb
.
getPositions
(
frame
=
0
))))
# There should only be 10 frames (0 through 9)
self
.
assertRaises
(
IndexError
,
lambda
:
pdb
.
getPositions
(
frame
=
10
))
self
.
assertIs
(
pdb
.
topology
.
getPeriodicBoxVectors
(),
None
)
os
.
unlink
(
'test.cif'
)
def
assertAlmostEqualVec
(
self
,
vec1
,
vec2
,
*
args
,
**
kwargs
):
if
is_quantity
(
vec1
):
vec1
=
vec1
.
value_in_unit_system
(
md_unit_system
)
if
is_quantity
(
vec2
):
vec2
=
vec2
.
value_in_unit_system
(
md_unit_system
)
for
x
,
y
in
zip
(
vec1
,
vec2
):
self
.
assertAlmostEqual
(
x
,
y
,
*
args
,
**
kwargs
)
def
testReporterExplicit
(
self
):
""" Tests the PDBxReporter with PBC """
parm
=
AmberPrmtopFile
(
'systems/alanine-dipeptide-explicit.prmtop'
)
system
=
parm
.
createSystem
(
nonbondedCutoff
=
1.0
,
nonbondedMethod
=
PME
)
sim
=
Simulation
(
parm
.
topology
,
system
,
VerletIntegrator
(
1
*
femtoseconds
),
Platform
.
getPlatformByName
(
'Reference'
))
orig_pdb
=
PDBFile
(
'systems/alanine-dipeptide-explicit.pdb'
)
sim
.
context
.
setPositions
(
orig_pdb
.
getPositions
())
sim
.
context
.
setPeriodicBoxVectors
(
*
parm
.
topology
.
getPeriodicBoxVectors
())
sim
.
reporters
.
append
(
PDBxReporter
(
'test.cif'
,
1
))
sim
.
step
(
10
)
pdb
=
PDBxFile
(
'test.cif'
)
self
.
assertEqual
(
len
(
list
(
pdb
.
topology
.
atoms
())),
len
(
list
(
parm
.
topology
.
atoms
())))
self
.
assertEqual
(
len
(
list
(
pdb
.
topology
.
residues
())),
len
(
list
(
parm
.
topology
.
residues
())))
for
res1
,
res2
in
zip
(
pdb
.
topology
.
residues
(),
parm
.
topology
.
residues
()):
self
.
assertEqual
(
res1
.
name
,
res2
.
name
)
for
atom1
,
atom2
in
zip
(
res1
.
atoms
(),
res2
.
atoms
()):
self
.
assertEqual
(
atom1
.
name
,
atom2
.
name
)
positions
=
pdb
.
getPositions
(
frame
=
9
)
self
.
assertFalse
(
all
(
x1
==
x2
for
x1
,
x2
in
zip
(
positions
,
pdb
.
getPositions
(
frame
=
0
))))
# There should only be 10 frames (0 through 9)
self
.
assertRaises
(
IndexError
,
lambda
:
pdb
.
getPositions
(
frame
=
10
))
self
.
assertAlmostEqualVec
(
parm
.
topology
.
getPeriodicBoxVectors
()[
0
],
pdb
.
topology
.
getPeriodicBoxVectors
()[
0
],
places
=
5
)
self
.
assertAlmostEqualVec
(
parm
.
topology
.
getPeriodicBoxVectors
()[
1
],
pdb
.
topology
.
getPeriodicBoxVectors
()[
1
],
places
=
5
)
self
.
assertAlmostEqualVec
(
parm
.
topology
.
getPeriodicBoxVectors
()[
2
],
pdb
.
topology
.
getPeriodicBoxVectors
()[
2
],
places
=
5
)
os
.
unlink
(
'test.cif'
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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