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
"""
Module simtk.unit.unit_definitions
Module openmm.unit.unit_definitions
This is part of the OpenMM molecular simulation toolkit originating from
Simbios, the NIH National Center for Physics-Based Simulation of
......
#!/bin/env python
"""
Module simtk.unit.math
Module openmm.unit.math
Arithmetic methods on Quantities and Units
......
#!/bin/env python
"""
Module simtk.unit.unit_operators
Module openmm.unit.unit_operators
Physical quantities with units, intended to produce similar functionality
to Boost.Units package in C++ (but with a runtime cost).
......@@ -9,7 +9,7 @@ but different internals to satisfy our local requirements.
In particular, there is no underlying set of 'canonical' base
units, whereas in Scientific.Physics.PhysicalQuantities all
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
"information".
......
......@@ -32,7 +32,7 @@ from __future__ import absolute_import, division
__author__ = "Peter Eastman"
__version__ = "1.0"
from .. import unit
from . import unit
from collections import namedtuple
class Vec3(namedtuple('Vec3', ['x', 'y', 'z'])):
......
......@@ -39,12 +39,12 @@ def removePackage(mod, verbose):
except AttributeError:
return
if len(pathList) > 1:
raise Exception("more than one item in simtk.__path__")
simtkInstallPath = pathList[0]
if os.path.exists(simtkInstallPath):
raise Exception("more than one item in openmm.__path__")
installPath = pathList[0]
if os.path.exists(installPath):
if verbose:
sys.stdout.write('REMOVING "%s"\n' % simtkInstallPath)
removeRecursive(simtkInstallPath)
sys.stdout.write('REMOVING "%s"\n' % installPath)
removeRecursive(installPath)
def uninstall(verbose=True):
save_path=sys.path[:]
......@@ -53,8 +53,8 @@ def uninstall(verbose=True):
if item!='.' and item!=os.getcwd():
sys.path.append(item)
try:
import simtk.openmm as openmm
removePackage(openmm, verbose)
import simtk.openmm
removePackage(simtk.openmm, verbose)
except ImportError:
pass
......@@ -63,10 +63,16 @@ def uninstall(verbose=True):
removePackage(unit, verbose)
except ImportError:
pass
try:
import openmm
removePackage(openmm, verbose)
except ImportError:
pass
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):
"""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
......@@ -125,27 +131,29 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
setupKeywords["version"] = "%s.%s.%s" % (major_version_num,
minor_version_num,
build_info)
setupKeywords["author"] = "Randall J. Radmer"
setupKeywords["author_email"] = "radmer@stanford.edu"
setupKeywords["author"] = "Peter Eastman"
setupKeywords["license"] = \
"Python Software Foundation License (BSD-like)"
setupKeywords["url"] = "https://simtk.org/home/openmm"
setupKeywords["download_url"] = "https://simtk.org/home/openmm"
setupKeywords["packages"] = ["simtk",
setupKeywords["url"] = "https://openmm.org"
setupKeywords["download_url"] = "https://openmm.org"
setupKeywords["packages"] = [
"simtk",
"simtk.unit",
"simtk.openmm",
"simtk.openmm.app",
"simtk.openmm.app.internal",
"simtk.openmm.app.internal.charmm",
"simtk.openmm.app.internal.pdbx",
"simtk.openmm.app.internal.pdbx.reader",
"simtk.openmm.app.internal.pdbx.writer"]
"openmm",
"openmm.unit",
"openmm",
"openmm.app",
"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["package_data"] = {"simtk" : [],
"simtk.unit" : [],
"simtk.openmm" : [],
"simtk.openmm.app" : ['data/*.xml', 'data/*.pdb', 'data/amber14/*.xml', 'data/charmm36/*.xml'],
"simtk.openmm.app.internal" : []}
setupKeywords["package_data"] = {"openmm" : [],
"openmm.app" : ['data/*.xml', 'data/*.pdb', 'data/amber14/*.xml', 'data/charmm36/*.xml'],
"openmm.app.internal" : []}
setupKeywords["platforms"] = ["Linux", "Mac OS X", "Windows"]
setupKeywords["description"] = \
"Python wrapper for OpenMM (a C++ MD package)"
......@@ -208,7 +216,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
include_dirs=openmm_include_path.split(';')
include_dirs.append(numpy.get_include())
extensionArgs = {"name": "simtk.openmm._openmm",
extensionArgs = {"name": "openmm._openmm",
"sources": ["src/swig_doxygen/OpenMMSwig.cxx"],
"include_dirs": include_dirs,
"define_macros": define_macros,
......@@ -219,7 +227,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
if platform.system() != "Windows":
extensionArgs["runtime_library_dirs"] = library_dirs
setupKeywords["ext_modules"] = [Extension(**extensionArgs)]
setupKeywords["ext_modules"] += cythonize('simtk/openmm/app/internal/*.pyx')
setupKeywords["ext_modules"] += cythonize('openmm/app/internal/*.pyx')
outputString = ''
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
stand-alone application for running simulations, or as a library you call
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"
from openmm import *
from . import app
import os, os.path
import sys
from . import version
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
import logging
logging.getLogger().warning("Warning: importing 'simtk.openmm' is deprecated. Import 'openmm' instead.")
\ No newline at end of file
"""
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.app 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 *
from openmm.unit import *
......@@ -3,7 +3,7 @@
try {
$action
} catch (std::exception &e) {
PyObject* mm = PyImport_AddModule("simtk.openmm");
PyObject* mm = PyImport_AddModule("openmm");
PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException");
PyErr_SetString(openmm_exception, const_cast<char*>(e.what()));
return NULL;
......@@ -16,7 +16,7 @@
$action
} catch (std::exception &e) {
PyEval_RestoreThread(_savePythonThreadState);
PyObject* mm = PyImport_AddModule("simtk.openmm");
PyObject* mm = PyImport_AddModule("openmm");
PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException");
PyErr_SetString(openmm_exception, const_cast<char*>(e.what()));
return NULL;
......@@ -30,7 +30,7 @@
$action
} catch (std::exception &e) {
PyEval_RestoreThread(_savePythonThreadState);
PyObject* mm = PyImport_AddModule("simtk.openmm");
PyObject* mm = PyImport_AddModule("openmm");
PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException");
PyErr_SetString(openmm_exception, const_cast<char*>(e.what()));
return NULL;
......
......@@ -8,7 +8,7 @@ PyObject *copyVVec3ToList(std::vector<Vec3> vVec3) {
n=vVec3.size();
pyList=PyList_New(n);
PyObject* mm = PyImport_AddModule("simtk.openmm");
PyObject* mm = PyImport_AddModule("openmm");
PyObject* vec3 = PyObject_GetAttrString(mm, "Vec3");
for (i=0; i<n; i++) {
OpenMM::Vec3& v = vVec3.at(i);
......
......@@ -17,8 +17,8 @@ if sys.version_info[0] == 2:
else:
_string_types = (bytes, str)
import simtk.unit as unit
from simtk.openmm.vec3 import Vec3
import openmm.unit as unit
from openmm.vec3 import Vec3
%}
......
%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.
*/
......@@ -8,7 +8,7 @@ PyObject* Vec3_to_PyVec3(const OpenMM::Vec3& v) {
static PyObject *__s_mm = NULL;
static PyObject *__s_Vec3 = NULL;
if (__s_mm == NULL) {
__s_mm = PyImport_AddModule("simtk.openmm");
__s_mm = PyImport_AddModule("openmm");
__s_Vec3 = PyObject_GetAttrString(__s_mm, "Vec3");
}
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) {
*
* This is equivalent to the following Python code
*
* >>> from simtk import unit
* >>> from openmm import unit
* >>> if isinstance(input, unit.Quantity)
* ... if input.is_compatible(unit.bar)
* ... return input.value_in_unit(unit.bar)
......@@ -41,9 +41,9 @@ PyObject* Py_StripOpenMMUnits(PyObject *input) {
if (__s_Quantity == NULL) {
PyObject* module = NULL;
module = PyImport_ImportModule("simtk.unit");
module = PyImport_ImportModule("openmm.unit");
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");
......
from __future__ import division
import unittest
from simtk.openmm import *
from simtk.openmm.app import *
from simtk.unit import *
from openmm import *
from openmm.app import *
from openmm.unit import *
import random
import math
......
import unittest
from validateConstraints import *
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
import simtk.openmm.app.element as elem
from openmm.app import *
from openmm import *
from openmm.unit import *
import openmm.app.element as elem
try:
from scipy.io import netcdf
SCIPY_IMPORT_FAILED = False
......
......@@ -2,10 +2,10 @@ import unittest
import os
import tempfile
from validateConstraints import *
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
import simtk.openmm.app.element as elem
from openmm.app import *
from openmm import *
from openmm.unit import *
import openmm.app.element as elem
prmtop1 = AmberPrmtopFile('systems/alanine-dipeptide-explicit.prmtop')
prmtop2 = AmberPrmtopFile('systems/alanine-dipeptide-implicit.prmtop')
......@@ -377,7 +377,7 @@ class TestAmberPrmtopFile(unittest.TestCase):
def testGBneckRadii(self):
""" 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()
# Make sure legal parameters do not raise
f.addParticle([0, 0.1, 0.5])
......
import unittest
import simtk.openmm as mm
import openmm as mm
class TestBytes(unittest.TestCase):
......
import unittest
from validateConstraints import *
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
import simtk.openmm.app.element as elem
from openmm.app import *
from openmm import *
from openmm.unit import *
import openmm.app.element as elem
import math
import os
import tempfile
......
import os
import unittest
import tempfile
from simtk.openmm import app
import simtk.openmm as mm
from simtk import unit
from openmm import app
import openmm as mm
from openmm import unit
class TestCheckpointReporter(unittest.TestCase):
......
import unittest
import tempfile
from simtk.openmm import app
import simtk.openmm as mm
from simtk import unit
from openmm import app
import openmm as mm
from openmm import unit
from random import random
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