pyPot
index
pyPot.py


PyPot: base class used by potential terms written in Python.
 
to write a potential term in Python, define a class which derives from
pyPot.PyPot, and make sure to call the base class' constructor.
Then, the new class should define two methods: 
calcEnergy, and calcEnergyAndDerivList(DerivList). 
 
Here is a simple example of a potential term for a single bond:
 
from pyPot import PyPot ; from vec3 import norm, Vec3
class BondPot(PyPot):
    ''' example class to evaluate energy, derivs of a single bond
    '''
    def __init__(self,name,atom1,atom2,length,forcec=1):
        ''' constructor - force constant is optional.'''
        PyPot.__init__(self,name) #first call base class constructor
        self.a1 = atom1     ; self.a2     = atom2
        self.length = length; self.forcec = forcec
        return
    def calcEnergy(self):
        self.q1 = self.a1.pos() ; self.q2 = self.a2.pos()
        self.dist = norm(self.q1-self.q2)
        return 0.5 * self.forcec * (self.dist-self.length)**2
    def calcEnergyAndDerivList(self,derivs):
        energy = self.calcEnergy()
        deriv1 = Vec3(map(lambda x,y:x*y,
                       [self.forcec * (self.dist-self.length) / self.dist]*3 ,
                         ( self.q1[0]-self.q2[0], 
                           self.q1[1]-self.q2[1], 
                           self.q1[2]-self.q2[2] )))
        derivs[self.a1] = deriv1
        derivs[self.a2] = -deriv1
        return energy
    pass
 
# The term can be instantiated like:
p = BondPot('bond',AtomSel('resid 1 and name C')[0],
                   AtomSel('resid 1 and name O')[0], length=1.5)
 
 
 
# This file was created automatically by SWIG.
# Don't modify this file, modify the SWIG interface instead.
# This file is compatible with both classic and new-style classes.

 
Classes
       
__builtin__.object
Modified
ModifiedPtr
ModifiedBase
ModifiedBasePtr
PyPot
PyPotPtr
PyPot_LetterClass
PyPot_LetterClassPtr

 
class Modified(__builtin__.object)
   
 

 
  Methods defined here:
__call__(*args)

 
__del__(self, destroy=<built-in function delete_Modified>)

 
__getattr__ lambda self, name

 
__init__(self, *args)

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
clear(*args)

 
set(*args)

 
update(*args)

 
value(*args)

 

Data and other attributes defined here:
MOD_SELF = 1
MOD_SIMULATION = 2
__dict__ = <dictproxy object at 0x26a5e18>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {}
__swig_setmethods__ = {}
__weakref__ = <attribute '__weakref__' of 'Modified' objects>

 
list of weak references to the object (if defined)

 
class ModifiedBase(__builtin__.object)
   
 

 
  Methods defined here:
__del__(self, destroy=<built-in function delete_ModifiedBase>)

 
__getattr__ lambda self, name

 
__init__(self)

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
registerTo(*args)

 
unRegister(*args)

 
updateValues(*args)

 

Properties defined here:
modified

 
get = ModifiedBase_modified_get(...)

 
set = ModifiedBase_modified_set(...)

 
registeredSimulations

 
get = ModifiedBase_registeredSimulations_get(...)

 
set = ModifiedBase_registeredSimulations_set(...)

 

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x26a5e18>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {'modified': <built-in function ModifiedBase_modified_get>, 'registeredSimulations': <built-in function ModifiedBase_registeredSimulations_get>}
__swig_setmethods__ = {'modified': <built-in function ModifiedBase_modified_set>, 'registeredSimulations': <built-in function ModifiedBase_registeredSimulations_set>}
__weakref__ = <attribute '__weakref__' of 'ModifiedBase' objects>

 
list of weak references to the object (if defined)

 
class ModifiedBasePtr(ModifiedBase)
   
 

 
 
Method resolution order:
ModifiedBasePtr
ModifiedBase
__builtin__.object

Methods defined here:
__init__(self, this)

 

Methods inherited from ModifiedBase:
__del__(self, destroy=<built-in function delete_ModifiedBase>)

 
__getattr__ lambda self, name

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
registerTo(*args)

 
unRegister(*args)

 
updateValues(*args)

 

Properties inherited from ModifiedBase:
modified

 
get = ModifiedBase_modified_get(...)

 
set = ModifiedBase_modified_set(...)

 
registeredSimulations

 
get = ModifiedBase_registeredSimulations_get(...)

 
set = ModifiedBase_registeredSimulations_set(...)

 

Data and other attributes inherited from ModifiedBase:
__dict__ = <dictproxy object at 0x26a5bb0>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {'modified': <built-in function ModifiedBase_modified_get>, 'registeredSimulations': <built-in function ModifiedBase_registeredSimulations_get>}
__swig_setmethods__ = {'modified': <built-in function ModifiedBase_modified_set>, 'registeredSimulations': <built-in function ModifiedBase_registeredSimulations_set>}
__weakref__ = <attribute '__weakref__' of 'ModifiedBase' objects>

 
list of weak references to the object (if defined)

 
class ModifiedPtr(Modified)
   
 

 
 
Method resolution order:
ModifiedPtr
Modified
__builtin__.object

Methods defined here:
__init__(self, this)

 

Methods inherited from Modified:
__call__(*args)

 
__del__(self, destroy=<built-in function delete_Modified>)

 
__getattr__ lambda self, name

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
clear(*args)

 
set(*args)

 
update(*args)

 
value(*args)

 

Data and other attributes inherited from Modified:
MOD_SELF = 1
MOD_SIMULATION = 2
__dict__ = <dictproxy object at 0x26a5a60>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {}
__swig_setmethods__ = {}
__weakref__ = <attribute '__weakref__' of 'Modified' objects>

 
list of weak references to the object (if defined)

 
class PyPot(__builtin__.object)
   
 

 
  Methods defined here:
__del__(self, destroy=<built-in function delete_PyPot>)

 
__deref__(*args)

 
__getattr__ lambda self, name

 
__init__ = construct(self, *args)

 
__mul__(*args)

 
__oldinit__ = __init__(self, *args)

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
calcEnergy(*args)

 
calcEnergyAndDerivs(*args)

 
decrRefCount(*args)

 
help(*args)

 
incrRefCount(*args)

 
instanceData(*args)

 
instanceName(*args)

 
numRestraints(*args)

 
pointer(*args)

 
potName(*args)

 
pythonPot(*args)

 
registerInstanceData(*args)

 
registerTo(*args)

 
resetPotName(*args)

 
rms(*args)

 
scale(*args)

 
setScale(*args)

 
setThreshold(*args)

 
threshold(*args)

 
unRegister(*args)

 
updateDelta(*args)

 
updateValues(*args)

 
violations(*args)

 

Properties defined here:
instanceData_

 
get = PyPot_instanceData__get(...)

 
set = PyPot_instanceData__set(...)

 
modified

 
get = PyPot_modified_get(...)

 
set = PyPot_modified_set(...)

 
registeredSimulations

 
get = PyPot_registeredSimulations_get(...)

 
set = PyPot_registeredSimulations_set(...)

 

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x26a5f68>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {'instanceData_': <built-in function PyPot_instanceData__get>, 'modified': <built-in function PyPot_modified_get>, 'registeredSimulations': <built-in function PyPot_registeredSimulations_get>}
__swig_setmethods__ = {'instanceData_': <built-in function PyPot_instanceData__set>, 'modified': <built-in function PyPot_modified_set>, 'registeredSimulations': <built-in function PyPot_registeredSimulations_set>}
__weakref__ = <attribute '__weakref__' of 'PyPot' objects>

 
list of weak references to the object (if defined)

 
class PyPotPtr(PyPot)
   
 

 
 
Method resolution order:
PyPotPtr
PyPot
__builtin__.object

Methods defined here:
__init__(self, this)

 

Methods inherited from PyPot:
__del__(self, destroy=<built-in function delete_PyPot>)

 
__deref__(*args)

 
__getattr__ lambda self, name

 
__mul__(*args)

 
__oldinit__ = __init__(self, *args)

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
calcEnergy(*args)

 
calcEnergyAndDerivs(*args)

 
decrRefCount(*args)

 
help(*args)

 
incrRefCount(*args)

 
instanceData(*args)

 
instanceName(*args)

 
numRestraints(*args)

 
pointer(*args)

 
potName(*args)

 
pythonPot(*args)

 
registerInstanceData(*args)

 
registerTo(*args)

 
resetPotName(*args)

 
rms(*args)

 
scale(*args)

 
setScale(*args)

 
setThreshold(*args)

 
threshold(*args)

 
unRegister(*args)

 
updateDelta(*args)

 
updateValues(*args)

 
violations(*args)

 

Properties inherited from PyPot:
instanceData_

 
get = PyPot_instanceData__get(...)

 
set = PyPot_instanceData__set(...)

 
modified

 
get = PyPot_modified_get(...)

 
set = PyPot_modified_set(...)

 
registeredSimulations

 
get = PyPot_registeredSimulations_get(...)

 
set = PyPot_registeredSimulations_set(...)

 

Data and other attributes inherited from PyPot:
__dict__ = <dictproxy object at 0x26a5de0>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {'instanceData_': <built-in function PyPot_instanceData__get>, 'modified': <built-in function PyPot_modified_get>, 'registeredSimulations': <built-in function PyPot_registeredSimulations_get>}
__swig_setmethods__ = {'instanceData_': <built-in function PyPot_instanceData__set>, 'modified': <built-in function PyPot_modified_set>, 'registeredSimulations': <built-in function PyPot_registeredSimulations_set>}
__weakref__ = <attribute '__weakref__' of 'PyPot' objects>

 
list of weak references to the object (if defined)

 
class PyPot_LetterClass(__builtin__.object)
   
 

 
  Methods defined here:
__del__(self, destroy=<built-in function delete_PyPot_LetterClass>)

 
__getattr__ lambda self, name

 
__init__(self, *args)

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
help(*args)

 
numRestraints(*args)

 
pythonPot(*args)

 
rms(*args)

 
violations(*args)

 

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x26a5e88>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {}
__swig_setmethods__ = {}
__weakref__ = <attribute '__weakref__' of 'PyPot_LetterClass' objects>

 
list of weak references to the object (if defined)

 
class PyPot_LetterClassPtr(PyPot_LetterClass)
   
 

 
 
Method resolution order:
PyPot_LetterClassPtr
PyPot_LetterClass
__builtin__.object

Methods defined here:
__init__(self, this)

 

Methods inherited from PyPot_LetterClass:
__del__(self, destroy=<built-in function delete_PyPot_LetterClass>)

 
__getattr__ lambda self, name

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
help(*args)

 
numRestraints(*args)

 
pythonPot(*args)

 
rms(*args)

 
violations(*args)

 

Data and other attributes inherited from PyPot_LetterClass:
__dict__ = <dictproxy object at 0x26a5c58>

 
dictionary for instance variables (if defined)
__swig_getmethods__ = {}
__swig_setmethods__ = {}
__weakref__ = <attribute '__weakref__' of 'PyPot_LetterClass' objects>

 
list of weak references to the object (if defined)

 
Functions
       
construct(self, *args)

 
fromPy(...)

 
help(...)

 
oldConstructor = __init__(self, *args) unbound PyPot method

 

 
Data
        __package__ = None
pyXplorHelp = Type help() for interactive help, or help(object) for help about object.