simulationTools
index
simulationTools.py


 
high-level refinement tools

 
Classes
       
potList.PotList(potList.rc_Pot)
PotListWithContext
AnnealIVM
FinalParams
InitialParams
RampedParameter
LinRamp
MultRamp
StaticRamp
StructureLoop

 
class AnnealIVM
   
 
class to perform simulated annealing using molecular dynamics. 
 
  Methods defined here:
__init__(s, initTemp, finalTemp, ivm=0, numSteps=None, tempStep=None, rampedParams={}, extraCommands=0, toleranceFactor=1000)

 
construct by specifying the intial and final annealing temperatures,
and an ivm.IVM object.
 
if tempStep is specified, it will be used to determine the number of
  dynamics runs at different temperatures. If if is omitted, numSteps
  will be used (and tempStep implicitly determined).
 
rampedParams is a list of MultRamp and LinRamp objects which specify
refinement parameters to adjust during the simulated annealing run.
extraCommands is a function or string which is run before dynamics at
each temperature. If it is a function, is is passed the current
AnnealIVM instance as the argument.
 
toleranceFactor is used to adjust the ivm.IVM's energy tolerance
as the temperature changes. The energy tolerance is calculated as
 
    eTolerance = temp / toleranceFactor
 
The ivm argument doesn't actually have to be an ivm.IVM, but it
must be an object which has the following methods defined:
  setBathTemp
  setETolerance
  run
finalParameters(s)

 
sets parameters to final values
initParameters(s)

 
initialize ramped parameters
printTemp(s)

 
run(s)

 
runExtraCommands(s)

 
runIVM(s, temp)

 
updateParameters(s)

 

 
class FinalParams
   
 
constructor takes a list of ramped parameters. The constructor invokes
each parameter such that it set to its final value.
Also, this object can be called as a function with zero arguments, to
set parameters to final values.
 
  Methods defined here:
__call__(s)

 
__init__(s, pList)

 

 
class InitialParams
   
 
constructor takes a list of ramped parameters. The constructor invokes
each parameter such that it set to its initial value.
Also, this object can be called as a function with zero arguments, to
set parameters to initial values
 
  Methods defined here:
__call__(s)

 
__init__(s, pList)

 

 
class LinRamp(RampedParameter)
   
 
convenience class for linearly
ramping a value from startValue to stopValue over numberSteps
constructor: MultRamp(startValue, stopValue, action)
methods:
  update() - increments value. It will not change the value beyond
             that specified by stopValue
  value()  - return the current value
  setNumSteps(ns) - set number of steps
  init(ns)        - set number of steps and initialize val to startValue
 
  Methods defined here:
__init__(s, startValue, stopValue, action=None)

 
setNumSteps(s, numSteps)

 
update(s, caller=0)

 

Methods inherited from RampedParameter:
finalize(s, caller=0)

 
init(s, numSteps, caller=0)

 
runAction(s, caller)

 
value(s)

 

 
class MultRamp(RampedParameter)
   
 
convenience class for multiplicatively (geometrically)
ramping a value from startValue to stopValue over numberSteps
constructor: MultRamp(startValue, stopValue, action)
methods:
  update() - increments value. It will not change the value beyond
             that specified by stopValue
  value()  - return the current value
  setNumSteps(ns) - set number of steps
  init(ns)        - set number of steps and initialize val to startValue
  finalize()      - set value to the final value.
 
  Methods defined here:
__init__(s, startValue, stopValue, action=None)

 
setNumSteps(s, numSteps)

 
update(s, caller=0)

 

Methods inherited from RampedParameter:
finalize(s, caller=0)

 
init(s, numSteps, caller=0)

 
runAction(s, caller)

 
value(s)

 

 
class PotListWithContext(potList.PotList)
   
 
potList.PotList with an initializing function called before
calcEnergy/calcEnergyAndDerivs
 
 
Method resolution order:
PotListWithContext
potList.PotList
potList.rc_Pot
__builtin__.object

Methods defined here:
__init__(s, name='', potList=None, context=None)

 
calcEnergy(s)

 
calcEnergyAndDerivs(s, derivs)

 

Methods inherited from potList.PotList:
__del__(self, destroy=<built-in function delete_PotList>)

 
__deref__(*args)

 
__getattr__ lambda self, name

 
__getitem__(self, cnt)

 
__getslice__(*args)

 
__len__(*args)

 
__mul__(*args)

 
__oldinit__ = __init__(self, *args)

 
__repr__(self)

 
__setattr__ lambda self, name, value

 
add(self, pot)

 
addEnergyReport(*args)

 
append(self, pot)

 
byName(*args)

 
clearEnergyReports(*args)

 
copy(self, potList)

 
decrRefCount(*args)

 
energyMaybeDerivs0(*args)

 
energyMaybeDerivs1(*args)

 
energyMaybeDerivs2(*args)

 
energyMaybeDerivs3(*args)

 
energyMaybeDerivs4(*args)

 
energyReports(*args)

 
ensWeight(*args)

 
getitem_int(*args)

 
getitem_string(*args)

 
help(*args)

 
incrRefCount(*args)

 
instanceData(*args)

 
keys(self)

 
list(*args)

 
numRestraints(*args)

 
pointer(*args)

 
registerInstanceData(*args)

 
registerTo(*args)

 
remove(self, name)

 
removeAll(*args)

 
renamed_add(*args)

 
renamed_remove(*args)

 
resetPotName(*args)

 
rms(*args)

 
setEnsWeights(*args)

 
setThreshold(*args)

 
setUseSimEnsWeights(*args)

 
showReport(*args)

 
simulation(*args)

 
size(*args)

 
threshold(*args)

 
unRegister(*args)

 
updateDelta(*args)

 
updateValues(*args)

 
useSimEnsWeights(*args)

 
violations(*args)

 

Properties inherited from potList.PotList:
instanceData_

 
get = PotList_instanceData__get(...)

 
set = PotList_instanceData__set(...)

 
modified

 
get = PotList_modified_get(...)

 
set = PotList_modified_set(...)

 
registeredSimulations

 
get = PotList_registeredSimulations_get(...)

 
set = PotList_registeredSimulations_set(...)

 

Data and other attributes inherited from potList.PotList:
__swig_getmethods__ = {'instanceData_': <built-in function PotList_instanceData__get>, 'modified': <built-in function PotList_modified_get>, 'registeredSimulations': <built-in function PotList_registeredSimulations_get>}
__swig_setmethods__ = {'instanceData_': <built-in function PotList_instanceData__set>, 'modified': <built-in function PotList_modified_set>, 'registeredSimulations': <built-in function PotList_registeredSimulations_set>}

Methods inherited from potList.rc_Pot:
instanceName(*args)

 
potName(*args)

 
scale(*args)

 
setScale(*args)

 

Data and other attributes inherited from potList.rc_Pot:
__dict__ = <dictproxy object at 0x1ecfa60>

 
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'rc_Pot' objects>

 
list of weak references to the object (if defined)

 
class RampedParameter
   
 
Base class for ramped parameters.
update() - increments value. It will not change the value beyond
           that specified by stopValue
value()  - return the current value
init(ns)        - set number of steps and initialize val to startValue
finalize()      - set value to the final value.
 
  Methods defined here:
__init__(s, action)

 
finalize(s, caller=0)

 
init(s, numSteps, caller=0)

 
runAction(s, caller)

 
setNumSteps(s, numSteps)

 
update(s, caller=0)

 
value(s)

 

 
class StaticRamp(RampedParameter)
   
 
convenience class for static parameter setup.
update() - increments value. It will not change the value beyond
           that specified by stopValue
value()  - return the current value
setNumSteps(ns) - set number of steps
init(ns)        - set number of steps and initialize val to startValue
 
  Methods defined here:
__init__(s, action)

 
update(s, caller=0)

 

Methods inherited from RampedParameter:
finalize(s, caller=0)

 
init(s, numSteps, caller=0)

 
runAction(s, caller)

 
setNumSteps(s, numSteps)

 
value(s)

 

 
class StructureLoop
   
 
class which performs loop over structure calculations.
Constructor: StructureLoop()
  arguments:
    numStructures       -    number of structures to calculate
    startStructure      -    id of the first structure to calculate
    structureNums       -    sequence of explicit structure numbers to
                             calculate. 
    structLoopAction    -    a user-defined function which takes
                             one argument: an instance of this class.
                             If this argument is omitted, new structures
                             are not calculated. Rather, existing structures
                             in files specified by pdbTemplate are read-in,
                             and analyzed.
    pdbTemplate         -    template string used to create a filename
                             for the pdbFile method. The filename is
                             generated using the makeFilename method.
                             Note that the template string should always
                             include the STRUCTURE literal so that distinct
                             structure files are generated.
                             
  if numStructures<0,   existing files matching pdbTemplate are processed,
  starting at startStructure, and stopping when a file does not exist.
  This mode of operation does not work with structure parallelism, but
  it does work with ensemble parallelism.
 
 There are additional arguments if you would like an average structure
 to be calculated. If averaging is enabled, the output structure files
 will be fit to each other.
 
   averageFilename      - name for output structure file. If not specified,
                          the average structure will not be calculated.
   averagePotList       - potential terms to use for average structure
                          calculation. These terms are reported on in the
                          .stats file.
   averageRegularize    - flag determining whether or not structure
                          regularization (gradient minimization) is
                          carried out on the average structure, by
                          minimizing against averagePotList.
                          [default: True]
   averageSortPots      - potential terms used for sorting structures. The
                          top fraction or number of structures is reported
                          on in the .stats file.
                          [defaults to averagePotList]
   averageCrossTerms    - potential terms to report on, but not to use
                          in refinement of average structure.
   averageContext       - function to call to setup average minimization
                          run.  
   averageFitSel        - atom selection used to fit structures in
                          calculation of average structure [name CA].
   averageCompSel       - atom selection used for heavy atom rmsd
                          comparison metric [not (name H* and not PSEUDO)].
   averageTopFraction   - fraction of structures to use in calculation of
                          average structure. The structures are sorted
                          by energy, and the top fraction is retained.
                          [1 - all structures].
   averageTopNum        - number of structures to use in calculation of
                          average structure. Specify only one of 
                          averageTopFraction or averageTopNum.
 
   averageAccept        - function to call to assess whether it is
                          acceptable, i.e. meets violation, rmsd
                          requirements. The function has a single argument:
                          averagePotList [defaults to accepting all
                          structures.]
 
   averageRefineSteps   - number of minimization steps to take during
                          regularization refinement of the average
                          structure [50]
 
   genViolationStats    - flag controlling whether statics are gathered
                          (over all structures) on which restraints are
                          violated most often. The results are collected
                          in a file named pdbTemplate.stats. Statistics
                          will be gathered for all terms in
                          averagePotList, so this attribute must be
                          specified for this facility to work.
   averageRestrain      - flag the control the inclusion of probDist energy
                          potential in calculating the average structure
                          from the ensemble. averageRestrainSel helps in
                          selecting atoms from which the density map is
                          created. inconsistentAveStruct is a flag that
                          get set to 1 if the energy of calculated average
                          structure is greater than the ensemble.
                          
 
method: run():
   performs numStructures loop of action. In each pass, the coordinates
   of the current Simulation are reset to their initial values and the
   instance variable count is incremented. Also, the global random seed
   is incremented. If the current simulation is an EnsembleSimulation,
   the seed-setting takes this into account.
 
   After run() has completed, average structure coordinates are left in
   the current Simulation, if they have been calculated. If restraint
   statistics are generated, the StructureLoop instance will have the
   following members when run() returns:
     restraintStats 
     restraintStatsCross
   These are restraintStats.RestraintStats objects corresponding to
   potential terms in averagePotList and AverageCrossTerms, respectively.
   The precision of the calculated structures is stored in the members
     fitRMSD
     compRMSD
   corresponding to averageFitSel and averageCompSel, respectively.
   Also, the cpu time spent within the run() method will be contained
   in the members
     cpuTime
     cpuTimes
     cpuTimeTot
   The first contains the local process's cpu time, the second is an array
   of times from each process, and the third is the sum.
 
  Methods defined here:
__init__(s, numStructures=-1, startStructure=0, structureNums=[], structLoopAction=0, pdbTemplate='', genViolationStats=0, averageFilename='', averagePotList=<C rc_DerivedPot<(PotList)> instance at _608c2b0200000000_p_rc_DerivedPotTPotList_t>, averageRegularize=True, averageSortPots=None, averageCrossTerms=[], averageContext=<function <lambda> at 0x1e98f50>, averageFitSel='name CA', averageCompSel='not name H* and not PSEUDO', averageTopFraction=1, averageTopNum=-1, averageAccept=<function <lambda> at 0x1e9d050>, averageRefineSteps=50, averageRestrain=False, averageRestrainSel='name CA or name C or name N or name O')

 
analyze(s, potList, altPotList=<C rc_DerivedPot<(PotList)> instance at _f0a72b0200000000_p_rc_DerivedPotTPotList_t>)

 
print violation info to violations file
and return summary information as a string
filename(s)

 
return filename generated by makeFilename() from the pdbTemplate
argument of the class constructor.
genAveStats(s, comm, sim)

 
generate averages, statistics for calculated structures
        
makeFilename(s, template)

 
create a filename given a template. In the template:
the following substitutions are made:
    SCRIPT    -> name of input script (without .py suffix)
    STRUCTURE -> the structure number
    MEMBER    -> the ensemble member index
pdbFile(s)

 
return a PDBTool object whose filename is generated by
makeFilename() from the pdbTemplate argument of the class
constructor.
run(s)

 
structureNum(s)

 
return the current structure number, or -1.
writeStructure(s, potList=None, altPotList=None, extraRemarks='')

 
perform analysis using analyze(), then write a structure with
the analysis information included as remarks.
 
The filename is generated from the pdbTemplate argument of the
StructureLoop constructor.
 
A summary is written out for each term in potList (and in altPotList,
if specified), and more detailed violation information is output
to a file named filename + '.viols' .
 
If potList is not specified, it defaults to s.averagePotList.
If altPotList is not specified, it defaults to s.averageCrossTerms.
 
extraRemarks, if specified, is extra information in the REMARKS section
of the PDB file, printed after the usual summary.

 
Functions
       
analyze(potList, extraTerms=<C rc_DerivedPot<(PotList)> instance at _d0d22b0200000000_p_rc_DerivedPotTPotList_t>, outFilename=0)

 
pretty print appropriate terms from the given PotList and return
them in a remarks string.
The optional extraTerms is a PotList of terms which do not
contribute to the total energy, but which should be analyzed all the same-
use this for cross-validated potential terms. The potList and extraTerms
arguments can have type of Pot, PotList, list or tuple.
 
If outFilename is specified, the verbose violations info is written to
the specified file.
calcAverageStruct(structs, fitSel, compSel, potList=[], regularizeSteps=50, averageRestrainSel='', averageRestrain=False)

 
compute unregularized average structure given structs.
The structures are first fit using fitSel, and analysis is performed
using compSel.
 
For homogeneous ensembleSimulation.EnsembleSimulations with Ne>1, this
routine calculate the average of the ensemble averages.
 
if potList is set, the sum of the specified terms 
will be will be minimized with respect to the average coordinates, after
the straight average structure has been calculated.
convertToPotList(obj)

 
convert a single potential term or a sequence to a
potList.PotList, if necessary. 
ensembleAvePos()

 
return the (unregularized) average coordinates of the current ensemble
For heterogeneous ensembles, this average is not meaningful, and the
full ensemble is returned.
flattenPotList(potList)

 
genFilename(template, structure=0, member=0)

 
create a filename given a template. In the template:
the following substitutions are made:
    SCRIPT    -> name of input script (without .py suffix)
    STRUCTURE -> the structure argument
    MEMBER    -> the member argument
getPotTerms(potList, names)

 
return in a list all the potential terms in potList whose potType()
matches names. names can be a string or a list of strings.
minimizeRefine(potList, refineSteps=50, xplorPots=['BOND', 'ANGL', 'IMPR'], scaleMultiplier=0.001, rigidRegions=(), fixedRegions=())

 
simple refinement using gradient minimization in Cartesian coordinates.
Some potential terms are held fixed during minimization, while others are
scaled up from a smaller value progressively, during each round of
minimization.
 
refineSteps specifies how many rounds of minimization to perform.
xplorPots are XPLOR terms which are to always be present, and for which
          the scale constant is held constant.
scaleMultiplier specifies the initial value for the scale constant.
 
rigidRegions specifies selections of atoms which do not move relative to
each other.
 
fixedRegion specifies selections of atoms which do not move at all.
mktemp(suffix='', prefix='tmp', dir=None)

 
return a temporary file name which is unique for each process and
thread within an ensemble simulation.
potType(pot)

 
return the potential's type.
For most potential terms, the type is given by the potName() accessor,
exception:
  for avePotAvePot, potType(subPot()) is returned.
registerExtraStats(potType, name, function, supportsList=False)

 
register extra terms, averages over selected structures will be
reported by restraintStats
 
The four arguments are the potential type as given by the potName
accessor, the name of the property to be averaged, a
function to be called on the pot term, like this: function(term) and
which returns a floating value, and whether this function supports a
list of terms.
registerTerm(analyzeFunc, termTitle, termPrefix)

 
register an analysis function to be called by the analyze() function
[see below].
 
One should specify an analysis function which takes a list of potential
terms as an argument, and two strings to identify the potential term - long
form, and short form, respecitively.
 
analyzeFunc should return a string containing an analysis summary. A more
detailed analysis can be printed to stdout.
saRefine(potList, refineSteps=50, xplorPots=['BOND', 'ANGL', 'IMPR', 'RAMA'], initTemp=10, finalTime=0.20000000000000001, initVel=1, scaleMultiplier=0.001, rigidRegions=(), fixedRegions=())

 
Added by Robin A Thottungal 
Add explanation 07/16/09
refineSteps specifies how many rounds of minimization to perform.
xplorPots are XPLOR terms which are to always be present, and for which
          the scale constant is held constant.
scaleMultiplier specifies the initial value for the scale constant.
 
rigidRegions specifies selections of atoms which do not move relative to
each other.
 
fixedRegion specifies selections of atoms which do not move at all.
summarizePotentials(potList)

 
get rms, violations summaries from potential terms
testGradient(pots, eachTerm=0, alwaysPrint=0, components=[0], tolerance=0.001, eTolerance=1e-08, epsilon=9.9999999999999995e-08, sim=0)

 
check the analytic gradient in the given potential terms against finite
difference values.
 
If the eachTerm argument is set, each term in the potList is tested
individually.
 
If alwaysPrint is set, all gradient terms will always be printed.
 
components specificies which of the three gradient components (x, y, z) to
test. By default this is just the x (0) component.
 
tolerance specifies the agreement expected between numerical and
analytic gradient
 
eTolerance specifies the ageement relative to the magnitude of the energy
 
epsilon specifies the stepsize used in the finite different gradient
calculation:
 
        dE/dqi(xyz) = E(qi(xyz)+epsilon) - E(qi(xyz)) / epsilon
 
where E(0) is the energy evaluated at the nominal coordinate value
qi(xyz).
 
For each atom, the following is printed:
atom identifying string  numerical gradient  analytical gradient
verticalFormat(name, nameValuePairs, minWidth=6, numericFormat='.2f')

 
waitForProcesses(numProcs, esim=0, timeOut=-1)

 
DEPRECATED: will be removed soon.
 
wait for all processing calculating structures in parallel to complete
their current computation.
 
If timeOut>=0, this specifies how long (in sec) to wait before abandoning
a process.
 
This routine acts like a barrier, suspending computation until all
processes have reached this point.
 
this routine assumes write access to the local directory, and that this
directory is shared by all processes.

 
Data
        __package__ = None
extraStats = {'RDCPot1': [('R-fac', <function Rfactor at 0x1e7f320>, False), ('R-infinite', <function Rfactor_infinite at 0x1e85f50>, False), ('Da', <function Da at 0x1e8ecf8>, False), ('Rhombicity', <function Rh at 0x1e92578>, False)]}
modules = {'UserDict': <module 'UserDict' from '/home/schwitrs/opt/python-amd64/lib/python2.6/UserDict.pyo'>, '__builtin__': <module '__builtin__' (built-in)>, '__future__': <module '__future__' from '/home/schwitrs/opt/python-amd64/lib/python2.6/__future__.pyo'>, '__main__': <module '__main__' (built-in)>, '_abcoll': <module '_abcoll' from '/home/schwitrs/opt/python-amd64/lib/python2.6/_abcoll.pyo'>, '_atom': <module '_atom' from '/home/schwitrs/xplor-bzr/bin.Linux_2.6_x86_64/_atom.so'>, '_atomSel': <module '_atomSel' from '/home/schwitrs/xplor-bzr/bin.Linux_2.6_x86_64/_atomSel.so'>, '_atomSelAction': <module '_atomSelAction' from '/home/schwitrs/xplor-bzr/bin.Linux_2.6_x86_64/_atomSelAction.so'>, '_avePot1': <module '_avePot1' from '/home/schwitrs/xplor-bzr/bin.Linux_2.6_x86_64/_avePot1.so'>, '_cdsList': <module '_cdsList' from '/home/schwitrs/xplor-bzr/bin.Linux_2.6_x86_64/_cdsList.so'>, ...}
registeredTerms = [(<function RDC_analyze at 0x1e8e578>, 'Dipolar Coupling Analysis', 'RDC')]