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
ab767c49
Commit
ab767c49
authored
Nov 19, 2014
by
peastman
Browse files
Merge pull request #739 from swails/conda-testing
Conda testing
parents
ae338b59
3b85cf43
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8992 additions
and
60 deletions
+8992
-60
.travis.yml
.travis.yml
+2
-0
examples/testInstallation.py
examples/testInstallation.py
+2
-60
wrappers/python/simtk/openmm/app/data/test.pdb
wrappers/python/simtk/openmm/app/data/test.pdb
+8874
-0
wrappers/python/simtk/testInstallation.py
wrappers/python/simtk/testInstallation.py
+114
-0
No files found.
.travis.yml
View file @
ab767c49
...
@@ -21,6 +21,8 @@ script:
...
@@ -21,6 +21,8 @@ script:
-
make -j2
-
make -j2
-
make -j2 install
-
make -j2 install
-
sudo make PythonInstall
-
sudo make PythonInstall
-
# Run the testInstallation script
-
python -m simtk.testInstallation
-
# run all of the tests
-
# run all of the tests
-
ctest -j2 -V
-
ctest -j2 -V
-
# get a list of all of the failed tests into this stupid ctest format
-
# get a list of all of the failed tests into this stupid ctest format
...
...
examples/testInstallation.py
View file @
ab767c49
from
__future__
import
print_function
from
__future__
import
print_function
# First make sure OpenMM is installed.
# First make sure OpenMM is installed.
from
simtk
import
testInstallation
import
sys
testInstallation
.
run_tests
()
try
:
from
simtk.openmm.app
import
*
from
simtk.openmm
import
*
from
simtk.unit
import
*
except
ImportError
as
err
:
print
(
"Failed to import OpenMM packages:"
,
err
.
message
)
print
(
"Make sure OpenMM is installed and the library path is set correctly."
)
sys
.
exit
()
# Create a System for the tests.
pdb
=
PDBFile
(
'input.pdb'
)
forcefield
=
ForceField
(
'amber99sb.xml'
,
'tip3p.xml'
)
system
=
forcefield
.
createSystem
(
pdb
.
topology
,
nonbondedMethod
=
PME
,
nonbondedCutoff
=
1
*
nanometer
,
constraints
=
HBonds
)
# List all installed platforms and compute forces with each one.
numPlatforms
=
Platform
.
getNumPlatforms
()
print
(
"There are"
,
numPlatforms
,
"Platforms available:"
)
print
()
forces
=
[
None
]
*
numPlatforms
platformErrors
=
{}
for
i
in
range
(
numPlatforms
):
platform
=
Platform
.
getPlatform
(
i
)
print
(
i
+
1
,
platform
.
getName
(),
end
=
" "
)
integrator
=
LangevinIntegrator
(
300
*
kelvin
,
1
/
picosecond
,
0.002
*
picoseconds
)
try
:
simulation
=
Simulation
(
pdb
.
topology
,
system
,
integrator
,
platform
)
simulation
.
context
.
setPositions
(
pdb
.
positions
)
forces
[
i
]
=
simulation
.
context
.
getState
(
getForces
=
True
).
getForces
()
del
simulation
print
(
"- Successfully computed forces"
)
except
:
print
(
"- Error computing forces with"
,
platform
.
getName
(),
"platform"
)
platformErrors
[
platform
.
getName
()]
=
sys
.
exc_info
()[
1
]
# Give details of any errors.
for
platform
in
platformErrors
:
print
()
print
(
"%s platform error: %s"
%
(
platform
,
platformErrors
[
platform
]))
# See how well the platforms agree.
if
numPlatforms
>
1
:
print
()
print
(
"Median difference in forces between platforms:"
)
print
()
for
i
in
range
(
numPlatforms
):
for
j
in
range
(
i
):
if
forces
[
i
]
is
not
None
and
forces
[
j
]
is
not
None
:
errors
=
[]
for
f1
,
f2
in
zip
(
forces
[
i
],
forces
[
j
]):
d
=
f1
-
f2
error
=
sqrt
((
d
[
0
]
*
d
[
0
]
+
d
[
1
]
*
d
[
1
]
+
d
[
2
]
*
d
[
2
])
/
(
f1
[
0
]
*
f1
[
0
]
+
f1
[
1
]
*
f1
[
1
]
+
f1
[
2
]
*
f1
[
2
]))
errors
.
append
(
error
)
print
(
"{} vs. {}: {:g}"
.
format
(
Platform
.
getPlatform
(
j
).
getName
(),
Platform
.
getPlatform
(
i
).
getName
(),
sorted
(
errors
)[
len
(
errors
)
//
2
]))
wrappers/python/simtk/openmm/app/data/test.pdb
0 → 100644
View file @
ab767c49
This diff is collapsed.
Click to expand it.
wrappers/python/simtk/testInstallation.py
0 → 100644
View file @
ab767c49
from
__future__
import
print_function
from
functools
import
wraps
import
os
import
sys
# First make sure OpenMM is installed.
class
TestingError
(
Exception
):
"""
An error is encountered when
"""
pass
try
:
from
simtk.openmm.app
import
*
from
simtk.openmm
import
*
from
simtk.unit
import
*
except
ImportError
as
err
:
simtk_import_failed
=
True
simtk_import_error
=
err
.
message
else
:
simtk_import_failed
=
False
def
error_converter
(
error_type
):
""" Converts all exceptions to the given Exception type """
def
wrapper
(
func
):
@
wraps
(
func
)
def
new_func
(
*
args
,
**
kwargs
):
try
:
func
(
*
args
,
**
kwargs
)
except
error_type
:
# Pass the existing error through
raise
except
BaseException
as
err
:
raise
TestingError
(
'Problem with OpenMM installation '
'encountered. OpenMM will not work until the problem '
'has been fixed.
\n\n
Error message: %s'
%
err
.
message
)
return
new_func
return
wrapper
@
error_converter
(
TestingError
)
def
run_tests
():
"""
Runs a set of tests to determine which platforms are available and tests the
relative accuracy between them. This can be used to determine if the Python
API is installed and working properly, as well as the fidelity of the
underlying OpenMM libraries with respect to computing energies and forces on
the different platforms supported by your installation.
This test prints the available platforms and the relative force errors
between them for a test system. If a problem is detected, TestingError is
raised.
"""
if
simtk_import_failed
:
raise
TestingError
(
'Failed to import OpenMM packages; OpenMM will not work.
\n
'
'Make sure OpenMM is installed and the library path is set correctly.'
'
\n\n
Error message: %s'
%
simtk_import_error
)
# Create a System for the tests.
data_dir
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
split
(
__file__
)[
0
]),
'openmm'
,
'app'
,
'data'
)
pdb
=
PDBFile
(
os
.
path
.
join
(
data_dir
,
'test.pdb'
))
forcefield
=
ForceField
(
'amber99sb.xml'
,
'tip3p.xml'
)
system
=
forcefield
.
createSystem
(
pdb
.
topology
,
nonbondedMethod
=
PME
,
nonbondedCutoff
=
1
*
nanometer
,
constraints
=
HBonds
)
# List all installed platforms and compute forces with each one.
numPlatforms
=
Platform
.
getNumPlatforms
()
print
(
"There are"
,
numPlatforms
,
"Platforms available:"
)
print
()
forces
=
[
None
]
*
numPlatforms
platformErrors
=
{}
for
i
in
range
(
numPlatforms
):
platform
=
Platform
.
getPlatform
(
i
)
print
(
i
+
1
,
platform
.
getName
(),
end
=
" "
)
integrator
=
LangevinIntegrator
(
300
*
kelvin
,
1
/
picosecond
,
0.002
*
picoseconds
)
try
:
simulation
=
Simulation
(
pdb
.
topology
,
system
,
integrator
,
platform
)
simulation
.
context
.
setPositions
(
pdb
.
positions
)
forces
[
i
]
=
simulation
.
context
.
getState
(
getForces
=
True
).
getForces
()
del
simulation
print
(
"- Successfully computed forces"
)
except
:
print
(
"- Error computing forces with"
,
platform
.
getName
(),
"platform"
)
platformErrors
[
platform
.
getName
()]
=
sys
.
exc_info
()[
1
]
# Give details of any errors.
for
platform
in
platformErrors
:
print
()
print
(
"%s platform error: %s"
%
(
platform
,
platformErrors
[
platform
]))
# See how well the platforms agree.
if
numPlatforms
>
1
:
print
()
print
(
"Median difference in forces between platforms:"
)
print
()
for
i
in
range
(
numPlatforms
):
for
j
in
range
(
i
):
if
forces
[
i
]
is
not
None
and
forces
[
j
]
is
not
None
:
errors
=
[]
for
f1
,
f2
in
zip
(
forces
[
i
],
forces
[
j
]):
d
=
f1
-
f2
error
=
sqrt
((
d
[
0
]
*
d
[
0
]
+
d
[
1
]
*
d
[
1
]
+
d
[
2
]
*
d
[
2
])
/
(
f1
[
0
]
*
f1
[
0
]
+
f1
[
1
]
*
f1
[
1
]
+
f1
[
2
]
*
f1
[
2
]))
errors
.
append
(
error
)
print
(
"{} vs. {}: {:g}"
.
format
(
Platform
.
getPlatform
(
j
).
getName
(),
Platform
.
getPlatform
(
i
).
getName
(),
sorted
(
errors
)[
len
(
errors
)
//
2
]))
if
__name__
==
'__main__'
:
try
:
run_tests
()
except
TestingError
as
err
:
print
(
err
.
message
)
sys
.
exit
(
1
)
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