Unverified Commit e53bdc5e authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Top level Python module is now "openmm" (#3000)

* Top level Python module is now "openmm"

* Updated module names in examples

* Updated module names in documentation

* Updated module in CI scripts

* Added deprecation warning
parent eff1f26e
#!/bin/env python #!/bin/env python
""" """
Module simtk.unit.unit_definitions Module openmm.unit.unit_definitions
This is part of the OpenMM molecular simulation toolkit originating from This is part of the OpenMM molecular simulation toolkit originating from
Simbios, the NIH National Center for Physics-Based Simulation of Simbios, the NIH National Center for Physics-Based Simulation of
......
#!/bin/env python #!/bin/env python
""" """
Module simtk.unit.math Module openmm.unit.math
Arithmetic methods on Quantities and Units Arithmetic methods on Quantities and Units
......
#!/bin/env python #!/bin/env python
""" """
Module simtk.unit.unit_operators Module openmm.unit.unit_operators
Physical quantities with units, intended to produce similar functionality Physical quantities with units, intended to produce similar functionality
to Boost.Units package in C++ (but with a runtime cost). to Boost.Units package in C++ (but with a runtime cost).
...@@ -9,7 +9,7 @@ but different internals to satisfy our local requirements. ...@@ -9,7 +9,7 @@ but different internals to satisfy our local requirements.
In particular, there is no underlying set of 'canonical' base In particular, there is no underlying set of 'canonical' base
units, whereas in Scientific.Physics.PhysicalQuantities all units, whereas in Scientific.Physics.PhysicalQuantities all
units are secretly in terms of SI units. Also, it is easier units are secretly in terms of SI units. Also, it is easier
to add new fundamental dimensions to simtk.dimensions. You to add new fundamental dimensions to basedimension. You
might want to make new dimensions for, say, "currency" or might want to make new dimensions for, say, "currency" or
"information". "information".
......
...@@ -32,7 +32,7 @@ from __future__ import absolute_import, division ...@@ -32,7 +32,7 @@ from __future__ import absolute_import, division
__author__ = "Peter Eastman" __author__ = "Peter Eastman"
__version__ = "1.0" __version__ = "1.0"
from .. import unit from . import unit
from collections import namedtuple from collections import namedtuple
class Vec3(namedtuple('Vec3', ['x', 'y', 'z'])): class Vec3(namedtuple('Vec3', ['x', 'y', 'z'])):
......
...@@ -39,12 +39,12 @@ def removePackage(mod, verbose): ...@@ -39,12 +39,12 @@ def removePackage(mod, verbose):
except AttributeError: except AttributeError:
return return
if len(pathList) > 1: if len(pathList) > 1:
raise Exception("more than one item in simtk.__path__") raise Exception("more than one item in openmm.__path__")
simtkInstallPath = pathList[0] installPath = pathList[0]
if os.path.exists(simtkInstallPath): if os.path.exists(installPath):
if verbose: if verbose:
sys.stdout.write('REMOVING "%s"\n' % simtkInstallPath) sys.stdout.write('REMOVING "%s"\n' % installPath)
removeRecursive(simtkInstallPath) removeRecursive(installPath)
def uninstall(verbose=True): def uninstall(verbose=True):
save_path=sys.path[:] save_path=sys.path[:]
...@@ -53,8 +53,8 @@ def uninstall(verbose=True): ...@@ -53,8 +53,8 @@ def uninstall(verbose=True):
if item!='.' and item!=os.getcwd(): if item!='.' and item!=os.getcwd():
sys.path.append(item) sys.path.append(item)
try: try:
import simtk.openmm as openmm import simtk.openmm
removePackage(openmm, verbose) removePackage(simtk.openmm, verbose)
except ImportError: except ImportError:
pass pass
...@@ -63,10 +63,16 @@ def uninstall(verbose=True): ...@@ -63,10 +63,16 @@ def uninstall(verbose=True):
removePackage(unit, verbose) removePackage(unit, verbose)
except ImportError: except ImportError:
pass pass
try:
import openmm
removePackage(openmm, verbose)
except ImportError:
pass
sys.path=save_path sys.path=save_path
def writeVersionPy(filename="simtk/openmm/version.py", major_version_num=MAJOR_VERSION_NUM, def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION_NUM,
minor_version_num=MINOR_VERSION_NUM, build_info=BUILD_INFO): minor_version_num=MINOR_VERSION_NUM, build_info=BUILD_INFO):
"""Write a version.py file into the python source directory before installation. """Write a version.py file into the python source directory before installation.
If a version.py file already exists, we assume that it contains only the git_revision If a version.py file already exists, we assume that it contains only the git_revision
...@@ -125,27 +131,29 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, ...@@ -125,27 +131,29 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
setupKeywords["version"] = "%s.%s.%s" % (major_version_num, setupKeywords["version"] = "%s.%s.%s" % (major_version_num,
minor_version_num, minor_version_num,
build_info) build_info)
setupKeywords["author"] = "Randall J. Radmer" setupKeywords["author"] = "Peter Eastman"
setupKeywords["author_email"] = "radmer@stanford.edu"
setupKeywords["license"] = \ setupKeywords["license"] = \
"Python Software Foundation License (BSD-like)" "Python Software Foundation License (BSD-like)"
setupKeywords["url"] = "https://simtk.org/home/openmm" setupKeywords["url"] = "https://openmm.org"
setupKeywords["download_url"] = "https://simtk.org/home/openmm" setupKeywords["download_url"] = "https://openmm.org"
setupKeywords["packages"] = ["simtk", setupKeywords["packages"] = [
"simtk",
"simtk.unit", "simtk.unit",
"simtk.openmm", "simtk.openmm",
"simtk.openmm.app", "simtk.openmm.app",
"simtk.openmm.app.internal", "openmm",
"simtk.openmm.app.internal.charmm", "openmm.unit",
"simtk.openmm.app.internal.pdbx", "openmm",
"simtk.openmm.app.internal.pdbx.reader", "openmm.app",
"simtk.openmm.app.internal.pdbx.writer"] "openmm.app.internal",
"openmm.app.internal.charmm",
"openmm.app.internal.pdbx",
"openmm.app.internal.pdbx.reader",
"openmm.app.internal.pdbx.writer"]
setupKeywords["data_files"] = [] setupKeywords["data_files"] = []
setupKeywords["package_data"] = {"simtk" : [], setupKeywords["package_data"] = {"openmm" : [],
"simtk.unit" : [], "openmm.app" : ['data/*.xml', 'data/*.pdb', 'data/amber14/*.xml', 'data/charmm36/*.xml'],
"simtk.openmm" : [], "openmm.app.internal" : []}
"simtk.openmm.app" : ['data/*.xml', 'data/*.pdb', 'data/amber14/*.xml', 'data/charmm36/*.xml'],
"simtk.openmm.app.internal" : []}
setupKeywords["platforms"] = ["Linux", "Mac OS X", "Windows"] setupKeywords["platforms"] = ["Linux", "Mac OS X", "Windows"]
setupKeywords["description"] = \ setupKeywords["description"] = \
"Python wrapper for OpenMM (a C++ MD package)" "Python wrapper for OpenMM (a C++ MD package)"
...@@ -208,7 +216,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, ...@@ -208,7 +216,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
include_dirs=openmm_include_path.split(';') include_dirs=openmm_include_path.split(';')
include_dirs.append(numpy.get_include()) include_dirs.append(numpy.get_include())
extensionArgs = {"name": "simtk.openmm._openmm", extensionArgs = {"name": "openmm._openmm",
"sources": ["src/swig_doxygen/OpenMMSwig.cxx"], "sources": ["src/swig_doxygen/OpenMMSwig.cxx"],
"include_dirs": include_dirs, "include_dirs": include_dirs,
"define_macros": define_macros, "define_macros": define_macros,
...@@ -219,7 +227,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, ...@@ -219,7 +227,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
if platform.system() != "Windows": if platform.system() != "Windows":
extensionArgs["runtime_library_dirs"] = library_dirs extensionArgs["runtime_library_dirs"] = library_dirs
setupKeywords["ext_modules"] = [Extension(**extensionArgs)] setupKeywords["ext_modules"] = [Extension(**extensionArgs)]
setupKeywords["ext_modules"] += cythonize('simtk/openmm/app/internal/*.pyx') setupKeywords["ext_modules"] += cythonize('openmm/app/internal/*.pyx')
outputString = '' outputString = ''
firstTab = 40 firstTab = 40
......
import openmm
import openmm.unit as unit
\ No newline at end of file
"""OpenMM is a toolkit for molecular simulation. It can be used either as a from openmm import *
stand-alone application for running simulations, or as a library you call from . import app
from your own code. It provides a combination of extreme flexibility
(through custom forces and integrators), openness, and high performance
(especially on recent GPUs) that make it truly unique among simulation codes.
"""
from __future__ import absolute_import
__author__ = "Peter Eastman"
import os, os.path import logging
import sys logging.getLogger().warning("Warning: importing 'simtk.openmm' is deprecated. Import 'openmm' instead.")
from . import version \ No newline at end of file
if sys.platform == 'win32':
_path = os.environ['PATH']
os.environ['PATH'] = '%(lib)s;%(lib)s\plugins;%(path)s' % {
'lib': version.openmm_library_path, 'path': _path}
from simtk.openmm.openmm import *
from simtk.openmm.vec3 import Vec3
from simtk.openmm.mtsintegrator import MTSIntegrator, MTSLangevinIntegrator
from simtk.openmm.amd import AMDIntegrator, AMDForceGroupIntegrator, DualAMDIntegrator
if os.getenv('OPENMM_PLUGIN_DIR') is None and os.path.isdir(version.openmm_library_path):
pluginLoadedLibNames = Platform.loadPluginsFromDirectory(os.path.join(version.openmm_library_path, 'plugins'))
else:
pluginLoadedLibNames = Platform.loadPluginsFromDirectory(Platform.getDefaultPluginsDirectory())
if sys.platform == 'win32':
os.environ['PATH'] = _path
del _path
__version__ = Platform.getOpenMMVersion()
class OpenMMException(Exception):
"""This is the class used for all exceptions thrown by the C++ library."""
pass
""" from openmm.app import *
OpenMM Application
"""
from __future__ import absolute_import
__docformat__ = "epytext en"
__author__ = "Peter Eastman"
__copyright__ = "Copyright 2016-2019, Stanford University and Peter Eastman"
__credits__ = []
__license__ = "MIT"
__maintainer__ = "Peter Eastman"
__email__ = "peastman@stanford.edu"
from .topology import Topology, Chain, Residue, Atom
from .pdbfile import PDBFile
from .pdbxfile import PDBxFile
from .forcefield import ForceField
from .simulation import Simulation
from .pdbreporter import PDBReporter, PDBxReporter
from .amberprmtopfile import AmberPrmtopFile, HCT, OBC1, OBC2, GBn, GBn2
from .amberinpcrdfile import AmberInpcrdFile
from .dcdfile import DCDFile
from .gromacsgrofile import GromacsGroFile
from .gromacstopfile import GromacsTopFile
from .dcdreporter import DCDReporter
from .modeller import Modeller
from .statedatareporter import StateDataReporter
from .element import Element
from .desmonddmsfile import DesmondDMSFile
from .checkpointreporter import CheckpointReporter
from .charmmcrdfiles import CharmmCrdFile, CharmmRstFile
from .charmmparameterset import CharmmParameterSet
from .charmmpsffile import CharmmPsfFile, CharmmPSFWarning
from .simulatedtempering import SimulatedTempering
from .metadynamics import Metadynamics, BiasVariable
# Enumerated values
NoCutoff = forcefield.NoCutoff
CutoffNonPeriodic = forcefield.CutoffNonPeriodic
CutoffPeriodic = forcefield.CutoffPeriodic
Ewald = forcefield.Ewald
PME = forcefield.PME
LJPME = forcefield.LJPME
HBonds = forcefield.HBonds
AllBonds = forcefield.AllBonds
HAngles = forcefield.HAngles
Single = topology.Single
Double = topology.Double
Triple = topology.Triple
Aromatic = topology.Aromatic
Amide = topology.Amide
""" from openmm.unit import *
Physical quantities with units for dimensional analysis and automatic unit conversion.
"""
from __future__ import absolute_import
__docformat__ = "epytext en"
__author__ = "Christopher M. Bruns"
__copyright__ = "Copyright 2010, Stanford University and Christopher M. Bruns"
__credits__ = []
__license__ = "MIT"
__maintainer__ = "Christopher M. Bruns"
__email__ = "cmbruns@stanford.edu"
from .unit import Unit, is_unit
from .quantity import Quantity, is_quantity
from .unit_math import *
from .unit_definitions import *
from .constants import *
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
try { try {
$action $action
} catch (std::exception &e) { } catch (std::exception &e) {
PyObject* mm = PyImport_AddModule("simtk.openmm"); PyObject* mm = PyImport_AddModule("openmm");
PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException"); PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException");
PyErr_SetString(openmm_exception, const_cast<char*>(e.what())); PyErr_SetString(openmm_exception, const_cast<char*>(e.what()));
return NULL; return NULL;
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
$action $action
} catch (std::exception &e) { } catch (std::exception &e) {
PyEval_RestoreThread(_savePythonThreadState); PyEval_RestoreThread(_savePythonThreadState);
PyObject* mm = PyImport_AddModule("simtk.openmm"); PyObject* mm = PyImport_AddModule("openmm");
PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException"); PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException");
PyErr_SetString(openmm_exception, const_cast<char*>(e.what())); PyErr_SetString(openmm_exception, const_cast<char*>(e.what()));
return NULL; return NULL;
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
$action $action
} catch (std::exception &e) { } catch (std::exception &e) {
PyEval_RestoreThread(_savePythonThreadState); PyEval_RestoreThread(_savePythonThreadState);
PyObject* mm = PyImport_AddModule("simtk.openmm"); PyObject* mm = PyImport_AddModule("openmm");
PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException"); PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException");
PyErr_SetString(openmm_exception, const_cast<char*>(e.what())); PyErr_SetString(openmm_exception, const_cast<char*>(e.what()));
return NULL; return NULL;
......
...@@ -8,7 +8,7 @@ PyObject *copyVVec3ToList(std::vector<Vec3> vVec3) { ...@@ -8,7 +8,7 @@ PyObject *copyVVec3ToList(std::vector<Vec3> vVec3) {
n=vVec3.size(); n=vVec3.size();
pyList=PyList_New(n); pyList=PyList_New(n);
PyObject* mm = PyImport_AddModule("simtk.openmm"); PyObject* mm = PyImport_AddModule("openmm");
PyObject* vec3 = PyObject_GetAttrString(mm, "Vec3"); PyObject* vec3 = PyObject_GetAttrString(mm, "Vec3");
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
OpenMM::Vec3& v = vVec3.at(i); OpenMM::Vec3& v = vVec3.at(i);
......
...@@ -17,8 +17,8 @@ if sys.version_info[0] == 2: ...@@ -17,8 +17,8 @@ if sys.version_info[0] == 2:
else: else:
_string_types = (bytes, str) _string_types = (bytes, str)
import simtk.unit as unit import openmm.unit as unit
from simtk.openmm.vec3 import Vec3 from openmm.vec3 import Vec3
%} %}
......
%fragment("Vec3_to_PyVec3", "header") { %fragment("Vec3_to_PyVec3", "header") {
/** /**
* Convert an OpenMM::Vec3 into a Python simtk.openmm.Vec3 object * Convert an OpenMM::Vec3 into a Python openmm.Vec3 object
* *
* Returns a new reference. * Returns a new reference.
*/ */
...@@ -8,7 +8,7 @@ PyObject* Vec3_to_PyVec3(const OpenMM::Vec3& v) { ...@@ -8,7 +8,7 @@ PyObject* Vec3_to_PyVec3(const OpenMM::Vec3& v) {
static PyObject *__s_mm = NULL; static PyObject *__s_mm = NULL;
static PyObject *__s_Vec3 = NULL; static PyObject *__s_Vec3 = NULL;
if (__s_mm == NULL) { if (__s_mm == NULL) {
__s_mm = PyImport_AddModule("simtk.openmm"); __s_mm = PyImport_AddModule("openmm");
__s_Vec3 = PyObject_GetAttrString(__s_mm, "Vec3"); __s_Vec3 = PyObject_GetAttrString(__s_mm, "Vec3");
} }
PyObject* tuple = Py_BuildValue("(d,d,d)", v[0], v[1], v[2]); PyObject* tuple = Py_BuildValue("(d,d,d)", v[0], v[1], v[2]);
...@@ -25,7 +25,7 @@ PyObject* Vec3_to_PyVec3(const OpenMM::Vec3& v) { ...@@ -25,7 +25,7 @@ PyObject* Vec3_to_PyVec3(const OpenMM::Vec3& v) {
* *
* This is equivalent to the following Python code * This is equivalent to the following Python code
* *
* >>> from simtk import unit * >>> from openmm import unit
* >>> if isinstance(input, unit.Quantity) * >>> if isinstance(input, unit.Quantity)
* ... if input.is_compatible(unit.bar) * ... if input.is_compatible(unit.bar)
* ... return input.value_in_unit(unit.bar) * ... return input.value_in_unit(unit.bar)
...@@ -41,9 +41,9 @@ PyObject* Py_StripOpenMMUnits(PyObject *input) { ...@@ -41,9 +41,9 @@ PyObject* Py_StripOpenMMUnits(PyObject *input) {
if (__s_Quantity == NULL) { if (__s_Quantity == NULL) {
PyObject* module = NULL; PyObject* module = NULL;
module = PyImport_ImportModule("simtk.unit"); module = PyImport_ImportModule("openmm.unit");
if (!module) { if (!module) {
PyErr_SetString(PyExc_ImportError, "simtk.unit"); Py_CLEAR(module); return NULL; PyErr_SetString(PyExc_ImportError, "openmm.unit"); Py_CLEAR(module); return NULL;
} }
__s_Quantity = PyObject_GetAttrString(module, "Quantity"); __s_Quantity = PyObject_GetAttrString(module, "Quantity");
......
from __future__ import division from __future__ import division
import unittest import unittest
from simtk.openmm import * from openmm import *
from simtk.openmm.app import * from openmm.app import *
from simtk.unit import * from openmm.unit import *
import random import random
import math import math
......
import unittest import unittest
from validateConstraints import * from validateConstraints import *
from simtk.openmm.app import * from openmm.app import *
from simtk.openmm import * from openmm import *
from simtk.unit import * from openmm.unit import *
import simtk.openmm.app.element as elem import openmm.app.element as elem
try: try:
from scipy.io import netcdf from scipy.io import netcdf
SCIPY_IMPORT_FAILED = False SCIPY_IMPORT_FAILED = False
......
...@@ -2,10 +2,10 @@ import unittest ...@@ -2,10 +2,10 @@ import unittest
import os import os
import tempfile import tempfile
from validateConstraints import * from validateConstraints import *
from simtk.openmm.app import * from openmm.app import *
from simtk.openmm import * from openmm import *
from simtk.unit import * from openmm.unit import *
import simtk.openmm.app.element as elem import openmm.app.element as elem
prmtop1 = AmberPrmtopFile('systems/alanine-dipeptide-explicit.prmtop') prmtop1 = AmberPrmtopFile('systems/alanine-dipeptide-explicit.prmtop')
prmtop2 = AmberPrmtopFile('systems/alanine-dipeptide-implicit.prmtop') prmtop2 = AmberPrmtopFile('systems/alanine-dipeptide-implicit.prmtop')
...@@ -377,7 +377,7 @@ class TestAmberPrmtopFile(unittest.TestCase): ...@@ -377,7 +377,7 @@ class TestAmberPrmtopFile(unittest.TestCase):
def testGBneckRadii(self): def testGBneckRadii(self):
""" Tests that GBneck radii limits are correctly enforced """ """ Tests that GBneck radii limits are correctly enforced """
from simtk.openmm.app.internal.customgbforces import GBSAGBnForce from openmm.app.internal.customgbforces import GBSAGBnForce
f = GBSAGBnForce() f = GBSAGBnForce()
# Make sure legal parameters do not raise # Make sure legal parameters do not raise
f.addParticle([0, 0.1, 0.5]) f.addParticle([0, 0.1, 0.5])
......
import unittest import unittest
import simtk.openmm as mm import openmm as mm
class TestBytes(unittest.TestCase): class TestBytes(unittest.TestCase):
......
import unittest import unittest
from validateConstraints import * from validateConstraints import *
from simtk.openmm.app import * from openmm.app import *
from simtk.openmm import * from openmm import *
from simtk.unit import * from openmm.unit import *
import simtk.openmm.app.element as elem import openmm.app.element as elem
import math import math
import os import os
import tempfile import tempfile
......
import os import os
import unittest import unittest
import tempfile import tempfile
from simtk.openmm import app from openmm import app
import simtk.openmm as mm import openmm as mm
from simtk import unit from openmm import unit
class TestCheckpointReporter(unittest.TestCase): class TestCheckpointReporter(unittest.TestCase):
......
import unittest import unittest
import tempfile import tempfile
from simtk.openmm import app from openmm import app
import simtk.openmm as mm import openmm as mm
from simtk import unit from openmm import unit
from random import random from random import random
import os import os
......
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