"plugins/amoeba/vscode:/vscode.git/clone" did not exist on "01260070fc5c4c51f8c977c68ebae95e56778a5b"
Commit b665dfcb authored by peastman's avatar peastman
Browse files

Merge pull request #1083 from rmcgibbo/wip-single-23-codebase

Single py2/3 codebase
parents 69a3f678 83d0e5e3
......@@ -30,6 +30,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import division
from __future__ import absolute_import
from simtk.openmm import CustomGBForce, Continuous2DFunction
......@@ -369,13 +370,13 @@ def GBSAGBn2Force(solventDielectric=78.5, soluteDielectric=1, SA=None,
def convertParameters(params, gbmodel):
"""Convert the GB parameters from the file into the values expected by the appropriate CustomGBForce."""
newparams = [None]*len(params)
if gbmodel == 'GBn2':
offset = 0.0195141
else:
offset = 0.009
for i in range(len(params)):
newparams[i] = list(params[i])
newparams[i][0] -= offset
newparams[i][1] *= newparams[i][0]
return newparams
for p in params:
newParam = list(p)
newParam[0] -= offset
newParam[1] *= newParam[0]
yield newParam
......@@ -36,6 +36,7 @@ The DataCategory class provides base storage container for instance
data and definition meta data.
"""
from __future__ import absolute_import
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
......@@ -99,13 +100,13 @@ class ContainerBase(object):
self.__name=name
def exists(self,name):
if self.__objCatalog.has_key(name):
if name in self.__objCatalog:
return True
else:
return False
def getObj(self,name):
if self.__objCatalog.has_key(name):
if name in self.__objCatalog:
return self.__objCatalog[name]
else:
return None
......@@ -118,7 +119,7 @@ class ContainerBase(object):
of the same name will be overwritten.
"""
if obj.getName() is not None:
if not self.__objCatalog.has_key(obj.getName()):
if obj.getName() not in self.__objCatalog:
# self.__objNameList is keeping track of object order here --
self.__objNameList.append(obj.getName())
self.__objCatalog[obj.getName()]=obj
......@@ -126,7 +127,7 @@ class ContainerBase(object):
def replace(self,obj):
""" Replace an existing object with the input object
"""
if ((obj.getName() is not None) and (self.__objCatalog.has_key(obj.getName())) ):
if ((obj.getName() is not None) and (obj.getName() in self.__objCatalog) ):
self.__objCatalog[obj.getName()]=obj
......@@ -158,7 +159,7 @@ class ContainerBase(object):
""" Revmove object by name. Return True on success or False otherwise.
"""
try:
if self.__objCatalog.has_key(curName):
if curName in self.__objCatalog:
del self.__objCatalog[curName]
i=self.__objNameList.index(curName)
del self.__objNameList[i]
......@@ -217,7 +218,7 @@ class DataContainer(ContainerBase):
def invokeDataBlockMethod(self,type,method,db):
self.__currentRow = 1
exec method.getInline()
exec(method.getInline())
def setGlobal(self):
self.__globalFlag=True
......@@ -328,7 +329,7 @@ class DataCategory(DataCategoryBase):
return self._rowList[0][ii]
except (IndexError, KeyError):
raise KeyError
raise TypeError, x
raise TypeError(x)
def getCurrentAttribute(self):
......@@ -464,7 +465,7 @@ class DataCategory(DataCategoryBase):
return self._rowList[rowI][self._attributeNameList.index(attribute)]
except (IndexError):
raise IndexError
raise IndexError, attribute
raise IndexError(attribute)
def setValue(self,value,attributeName=None,rowIndex=None):
if attributeName is None:
......@@ -544,13 +545,13 @@ class DataCategory(DataCategoryBase):
if (ind >= ll):
row.extend([None for ii in xrange(2*ind-ll)])
row[ind]=None
exec method.getInline()
exec(method.getInline())
self.__currentRowIndex+=1
currentRowIndex=self.__currentRowIndex
def invokeCategoryMethod(self,type,method,db):
self.__currentRowIndex = 0
exec method.getInline()
exec(method.getInline())
def getAttributeLengthMaximumList(self):
mList=[0 for i in len(self._attributeNameList)]
......@@ -750,7 +751,7 @@ class DataCategory(DataCategoryBase):
except (IndexError):
self.__lfh.write("attributeName %s rowI %r rowdata %r\n" % (attributeName,rowI,self._rowList[rowI]))
raise IndexError
raise TypeError, attribute
raise TypeError(attribute)
def getValueFormattedByIndex(self,attributeIndex,rowIndex):
......
......@@ -27,6 +27,7 @@ Acknowledgements:
See: http://pymmlib.sourceforge.net/
"""
from __future__ import absolute_import
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
......@@ -137,7 +138,7 @@ class PdbxReader(object):
# Find the first reserved word and begin capturing data.
#
while True:
curCatName, curAttName, curQuotedString, curWord = tokenizer.next()
curCatName, curAttName, curQuotedString, curWord = next(tokenizer)
if curWord is None:
continue
reservedWord, state = self.__getState(curWord)
......@@ -194,7 +195,7 @@ class PdbxReader(object):
# Get the data for this attribute from the next token
tCat, tAtt, curQuotedString, curWord = tokenizer.next()
tCat, tAtt, curQuotedString, curWord = next(tokenizer)
if tCat is not None or (curQuotedString is None and curWord is None):
self.__syntaxError("Missing data for item _%s.%s" % (curCatName,curAttName))
......@@ -215,7 +216,7 @@ class PdbxReader(object):
else:
self.__syntaxError("Missing value in item-value pair")
curCatName, curAttName, curQuotedString, curWord = tokenizer.next()
curCatName, curAttName, curQuotedString, curWord = next(tokenizer)
continue
#
......@@ -225,14 +226,14 @@ class PdbxReader(object):
# The category name in the next curCatName,curAttName pair
# defines the name of the category container.
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
if curCatName is None or curAttName is None:
self.__syntaxError("Unexpected token in loop_ declaration")
return
# Check for a previous category declaration.
if categoryIndex.has_key(curCatName):
if curCatName in categoryIndex:
self.__syntaxError("Duplicate category declaration in loop_")
return
......@@ -248,7 +249,7 @@ class PdbxReader(object):
# Read the rest of the loop_ declaration
while True:
curCatName, curAttName, curQuotedString, curWord = tokenizer.next()
curCatName, curAttName, curQuotedString, curWord = next(tokenizer)
if curCatName is None:
break
......@@ -280,7 +281,7 @@ class PdbxReader(object):
elif curQuotedString is not None:
curRow.append(curQuotedString)
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
# loop_ data processing ends if -
......@@ -306,7 +307,7 @@ class PdbxReader(object):
categoryIndex = {}
curCategory = None
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
elif state == "ST_DATA_CONTAINER":
#
......@@ -317,7 +318,7 @@ class PdbxReader(object):
containerList.append(curContainer)
categoryIndex = {}
curCategory = None
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
elif state == "ST_STOP":
return
......@@ -327,7 +328,7 @@ class PdbxReader(object):
containerList.append(curContainer)
categoryIndex = {}
curCategory = None
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
elif state == "ST_UNKNOWN":
self.__syntaxError("Unrecogized syntax element: " + str(curWord))
......@@ -366,7 +367,7 @@ class PdbxReader(object):
## Tokenizer loop begins here ---
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
# Dump comments
......@@ -379,7 +380,7 @@ class PdbxReader(object):
if line.startswith(";"):
mlString = [line[1:]]
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
if line.startswith(";"):
break
......@@ -451,7 +452,7 @@ class PdbxReader(object):
## Tokenizer loop begins here ---
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
# Dump comments
......@@ -464,7 +465,7 @@ class PdbxReader(object):
if line.startswith(";"):
mlString = [line[1:]]
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
if line.startswith(";"):
break
......
......@@ -10,6 +10,7 @@
##
""" Various tests caess for PDBx/mmCIF data file and dictionary reader and writer.
"""
from __future__ import absolute_import
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
......
......@@ -22,6 +22,7 @@ Acknowledgements:
See: http://pymmlib.sourceforge.net/
"""
from __future__ import absolute_import
import re,sys
from simtk.openmm.app.internal.pdbx.reader.PdbxContainers import *
......@@ -126,7 +127,7 @@ class PdbxReader(object):
# Find the first reserved word and begin capturing data.
#
while True:
curCatName, curAttName, curQuotedString, curWord = tokenizer.next()
curCatName, curAttName, curQuotedString, curWord = next(tokenizer)
if curWord is None:
continue
reservedWord, state = self.__getState(curWord)
......@@ -183,7 +184,7 @@ class PdbxReader(object):
# Get the data for this attribute from the next token
tCat, tAtt, curQuotedString, curWord = tokenizer.next()
tCat, tAtt, curQuotedString, curWord = next(tokenizer)
if tCat is not None or (curQuotedString is None and curWord is None):
self.__syntaxError("Missing data for item _%s.%s" % (curCatName,curAttName))
......@@ -204,7 +205,7 @@ class PdbxReader(object):
else:
self.__syntaxError("Missing value in item-value pair")
curCatName, curAttName, curQuotedString, curWord = tokenizer.next()
curCatName, curAttName, curQuotedString, curWord = next(tokenizer)
continue
#
......@@ -214,14 +215,14 @@ class PdbxReader(object):
# The category name in the next curCatName,curAttName pair
# defines the name of the category container.
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
if curCatName is None or curAttName is None:
self.__syntaxError("Unexpected token in loop_ declaration")
return
# Check for a previous category declaration.
if categoryIndex.has_key(curCatName):
if curCatName in categoryIndex:
self.__syntaxError("Duplicate category declaration in loop_")
return
......@@ -237,7 +238,7 @@ class PdbxReader(object):
# Read the rest of the loop_ declaration
while True:
curCatName, curAttName, curQuotedString, curWord = tokenizer.next()
curCatName, curAttName, curQuotedString, curWord = next(tokenizer)
if curCatName is None:
break
......@@ -269,7 +270,7 @@ class PdbxReader(object):
elif curQuotedString is not None:
curRow.append(curQuotedString)
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
# loop_ data processing ends if -
......@@ -295,7 +296,7 @@ class PdbxReader(object):
categoryIndex = {}
curCategory = None
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
elif state == "ST_DATA_CONTAINER":
#
......@@ -306,7 +307,7 @@ class PdbxReader(object):
containerList.append(curContainer)
categoryIndex = {}
curCategory = None
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
elif state == "ST_STOP":
return
......@@ -316,7 +317,7 @@ class PdbxReader(object):
containerList.append(curContainer)
categoryIndex = {}
curCategory = None
curCatName,curAttName,curQuotedString,curWord = tokenizer.next()
curCatName,curAttName,curQuotedString,curWord = next(tokenizer)
elif state == "ST_UNKNOWN":
self.__syntaxError("Unrecogized syntax element: " + str(curWord))
......@@ -355,7 +356,7 @@ class PdbxReader(object):
## Tokenizer loop begins here ---
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
# Dump comments
......@@ -368,7 +369,7 @@ class PdbxReader(object):
if line.startswith(";"):
mlString = [line[1:]]
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
if line.startswith(";"):
break
......@@ -426,7 +427,7 @@ class PdbxReader(object):
## Tokenizer loop begins here ---
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
# Dump comments
......@@ -439,7 +440,7 @@ class PdbxReader(object):
if line.startswith(";"):
mlString = [line[1:]]
while True:
line = fileIter.next()
line = next(fileIter)
self.__curLineNumber += 1
if line.startswith(";"):
break
......
......@@ -12,6 +12,7 @@
Test cases for reading PDBx/mmCIF data files PdbxReader class -
"""
from __future__ import absolute_import
import sys, unittest, traceback
import sys, time, os, os.path, shutil
......
......@@ -11,6 +11,7 @@
Classes for writing data and dictionary containers in PDBx/mmCIF format.
"""
from __future__ import absolute_import
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "jwest@rcsb.rutgers.edu"
......
......@@ -12,6 +12,7 @@
Test implementing PDBx/mmCIF write and formatting operations.
"""
from __future__ import absolute_import
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "jwest@rcsb.rutgers.edu"
......
......@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
__author__ = "Peter Eastman"
__version__ = "1.0"
......
......@@ -29,6 +29,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import division
from __future__ import absolute_import
__author__ = "Peter Eastman"
__version__ = "1.0"
......@@ -40,7 +41,7 @@ from simtk.openmm.vec3 import Vec3
from simtk.openmm import System, Context, NonbondedForce, CustomNonbondedForce, HarmonicBondForce, HarmonicAngleForce, VerletIntegrator, LocalEnergyMinimizer
from simtk.unit import nanometer, molar, elementary_charge, amu, gram, liter, degree, sqrt, acos, is_quantity, dot, norm
import simtk.unit as unit
import element as elem
from . import element as elem
import os
import random
import xml.etree.ElementTree as etree
......@@ -877,7 +878,7 @@ class Modeller(object):
# Create copies of all residue templates that have had all extra points removed.
templatesNoEP = {}
for resName, template in forcefield._templates.iteritems():
for resName, template in forcefield._templates.items():
if any(atom.element is None for atom in template.atoms):
index = 0
newIndex = {}
......
......@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
__author__ = "Peter Eastman"
__version__ = "1.0"
......
......@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
__author__ = "Peter Eastman"
__version__ = "1.0"
......@@ -133,7 +134,7 @@ class Simulation(object):
def _simulate(self, endStep=None, endTime=None):
if endStep is None:
endStep = sys.maxint
endStep = sys.maxsize
nextReport = [None]*len(self.reporters)
while self.currentStep < endStep and (endTime is None or datetime.now() < endTime):
nextSteps = endStep-self.currentStep
......
......@@ -28,6 +28,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
from __future__ import print_function
__author__ = "Peter Eastman"
__version__ = "1.0"
......@@ -146,7 +148,7 @@ class StateDataReporter(object):
if not self._hasInitialized:
self._initializeConstants(simulation)
headers = self._constructHeaders()
print >>self._out, '#"%s"' % ('"'+self._separator+'"').join(headers)
print('#"%s"' % ('"'+self._separator+'"').join(headers), file=self._out)
try:
self._out.flush()
except AttributeError:
......@@ -163,7 +165,7 @@ class StateDataReporter(object):
values = self._constructReportValues(simulation, state)
# Write the values.
print >>self._out, self._separator.join(str(v) for v in values)
print(self._separator.join(str(v) for v in values), file=self._out)
try:
self._out.flush()
except AttributeError:
......
......@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
__author__ = "Peter Eastman"
__version__ = "1.0"
......
......@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
__author__ = "Peter Eastman"
__version__ = "1.0"
......
......@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
__author__ = "Peter Eastman"
__version__ = "1.0"
......
from __future__ import print_function
from __future__ import absolute_import
from functools import wraps
import os
import sys
......
"""
Physical quantities with units for dimensional analysis and automatic unit conversion.
"""
__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 *
"""
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 *
......@@ -807,8 +807,8 @@ def _is_string(x):
if isinstance(x, str):
return True
try:
first_item = iter(x).next()
inner_item = iter(first_item).next()
first_item = next(iter(x))
inner_item = next(iter(first_item))
if first_item is inner_item:
return True
else:
......
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