Package schrodinger :: Package structutils :: Module minimize :: Class Minimizer
[hide private]
[frames] | no frames]

Class Minimizer

A class to provide force field energy and minimization.

For simple cases the minimize_structure function can be used. Direct use of this class is mostly useful for cases where multiple conformers are to be minimized, as the updateCoordinates() method allows one to avoid running atom-typing for every conformer.

Instance Methods [hide private]
 
__init__(self, ffld_version=OPLS_2005, struct=None, cleanup=False, **kwargs)
Initialize.
 
__del__(self)
Clean up library resources.
 
getStructure(self)
Return the current structure.
 
updateCoordinates(self, struct)
Update the coordinates of the current structure with the values from the provided struct.
 
minimize(self)
Minimize the provided Structure.
 
getTotalEnergy(self)
get the total energy of the system
 
getStretchEnergy(self)
get the stretch energy of the system
 
getBendingEnergy(self)
get the beinding energy of the system
 
getTorsionEnergy(self)
get the torsion energy of the system
 
getImpTorsionEnergy(self)
get the imporoper torsion energy of the system
 
get14LJEnergy(self)
get the 1,4-Lennard Jones energy of the system
 
getLJEnergy(self)
get the Lennard Jones energy of the system
 
get14EleEnergy(self)
get the 1,4-electrostatic energy of the system
 
getEleEnergy(self)
get the electrostatic energy of the system
 
getBondedEnergyComponents(self, stretch_item_list, bending_item_list, torsion_item_list, imp_torsion_item_list)
Get energy components for bonded terms given in an list of stretches/bend/torsions/improper torsions (given as integer numbers) in *_item_list.
 
getNBEnergyComponents(self, atom_list_i, atom_list_j, nb_energy_component_list)
TODO: this API should be eliminated.
 
getNBEnergyForTwoAtomLists(self, atom_list_i, atom_list_j)
Get the non-bonded energy components for two arbitrary list of atoms.
 
getTotalAtom(self)
get the total number of atoms
 
getTotalStretch(self)
get the total number of stretch
 
getStretch(self, istr)
get the stretch type information and parameters
 
getTotalBending(self)
get the total number of bending
 
getBending(self, ibnd)
get the bending type information and parameters
 
getTotalTorsion(self)
get the total number of torsion
 
getTorsion(self, itor)
get the torsion type information and parameters
 
getTotalImpTorsion(self)
get the total number of improper torsion
 
getImpTorsion(self, imp_tor)
get the improper torsion type information and parameters
 
getTotal14Pair(self)
get the total number of 1,4-pairs
 
getNB14Pairs(self, i14pair)
get the 1,4-pair information
 
getExcludedAtomList(self, iatom, excluded_atoms)
get the excluded atoms
 
setStructure(self, struct)
Change the structure to be minimized.
 
getEnergy(self, recalc=None)
Get the energy for the current structure from properties if possible, otherwise run a zero-step minimization to calculate the energy.
 
setOptions(self, **kwargs)
Set Minimizer options by keyword.
 
getOptions(self)
Return the values for all properties that control Minimizer behavior.
 
setLigandCleanupOptions(self)
Obsolete.
 
addTorsionRestraint(self, i, j, k, l, force_constant, target, flat_bottom=0.0)
Define a torsional restraint.
 
addAngleRestraint(self, i, j, k, force_constant, target, flat_bottom=0.0)
Define an angle restraint.
 
addDistanceRestraint(self, i, j, force_constant, target, flat_bottom=0.0)
Define a distance restraint.
 
addPosRestraint(self, i, force_constant, flat_bottom=0.0)
Define a positional restraint.
 
addPosFrozen(self, i)
Define a frozen atom.
 
deleteAllRestraints(self, rest_type=mm.MMFfldAllRestType)
Delete all the restraints for a given type (default all types).
 
printParameters(self)
Print all parameters for the entered molecules.
 
min_converged(self)
Return 1 if last minimization converged, 0 if it didn't.
 
min_rms_gradient(self)
Return the RMS gradient of the last minimization.
 
min_energy(self)
Return the energy calculated in the last minimization.
tuple
getBondedEnergies(self, atom_subset)
Return bonded energies for bonded interactions within the given atom subset.
float
getBondedInteractionEnergy(self, atomset1, atomset2=None, verbose=False)
Return the bonded component of the interaction energy between the two given atom sets.
tuple
getNonBondedEnergies(self, atom_subset, verbose=False)
Given a list of atoms representing a substructure (e.g.
float
getSelfEnergy(self, atom_subset, include_intra_nb=True)
Return the internal energy of the the given atoms.
float
getSubsetEnergy(self, atom_subset, include_intra_nb=True, verbose=False)
Return the potential energy of the the given atoms.
float
_getInteractionEnergyBetweenSubsets(self, atom_subset1, atom_subset2, include_bonded=False, verbose=False)
Returns the interaction energy between the two atom groups.
float
getInteractionEnergy(self, subset_atoms, consider_atoms=None, include_bonded=False, verbose=False)
Calculate the energy of interaction between the <subset_atoms> and the <consider_atoms>.
Static Methods [hide private]
 
initialize(error_handler=None)
Initialize needed mmlibs.
 
terminate()
Terminate the mmlibs initialized in the initialize method.
Class Variables [hide private]
  min_method = _minimizer_int_property(mm.MMFfldOption_MIN_METHO...
  max_steps = _minimizer_int_property(mm.MMFfldOption_MIN_MAX_ST...
  energy_criterion = _minimizer_float_property(mm.MMFfldOption_M...
  gradient_criterion = _minimizer_float_property(mm.MMFfldOption...
  verbose = _minimizer_int_property(mm.MMFfldOption_MIN_VERBOSE,...
  energy_no_electrostatics = _minimizer_int_property(mm.MMFfldOp...
  energy_lj_repulsive_only = _minimizer_int_property(mm.MMFfldOp...
  nonbonded_cutoff = _minimizer_float_property(mm.MMFfldOption_S...
  maintain_planarity = _minimizer_int_property(mm.MMFfldOption_T...
  dielectric_constant = _minimizer_float_property(mm.MMFfldOptio...
Method Details [hide private]

__init__(self, ffld_version=OPLS_2005, struct=None, cleanup=False, **kwargs)
(Constructor)

 

Initialize.

Additional keyword arguments will be used to set properties of the instance. See the __init__() method for supported property names.

Parameters

Parameters:
  • ffld_version (integer module constant) - Use one of the valid force fields from mmcommon_get_valid_forcefields()
  • struct (schrodinger.structure.Structure) - The structure to be minimized.
  • cleanup (bool) - If True, attempts to automatically clean up the structure will be made. (This uses the C function mmlewis_apply().) Note that this can modify the atom types of the passed in structure.
  • min_method (enum) - The minimizer method. Valid values are MinBFGS, MinAUTO and MinCG. Default is MinAUTO, which uses BFGS if number of atoms is less than 500, CG otherwise.
  • max_steps (int) - The maximum number of steps to run the mimization for. Default is 1500.
  • energy_criterion (float) - The energy convergence criterion. Default is 5.0e-09.
  • gradient_criterion (float) - The gradient convergence criterion. Default is 0.05.
  • verbose (bool) - Printing verbosity. Default is False.
  • energy_no_electrostatics (bool) - Whether to turn off electrostatics. Default is False, i.e. to use electrostatics. NOTE: Can not be modified after the instance is created
  • energy_lj_repulsive_only (bool) - Whether to use only the repulsive portion of the Lennard-Jones term. Default is False. NOTE: Can not be modified after the instance is created
  • nonbonded_cutoff (float) - The cutoff for non-bonded interactions. Default is 14.0.
  • maintain_planarity (bool) - Enable scaling of forces to artificially maintain planarity of certain sub-structures. This sets associated scale factors to their default values. Default is False. NOTE: Can not be modified after the instance is created
  • dielectric_constant (float) - The strength of the constant dielectric field used in the energy calculation. The default is 1.0 (vacuum).

initialize(error_handler=None)
Static Method

 

Initialize needed mmlibs.

This method is called by the Minimizer constructor, so if Minimizer objects are used there is no need to explicitly call it.

terminate()
Static Method

 

Terminate the mmlibs initialized in the initialize method.

It's only necessary to call this method if you want to free resources used by the underlying lib.

Note that this terminate method isn't automatically called in the __del__ method of Minimizer. This is because there is significant overhead to reading the force field data and it won't be re-read as long as the library reference count is greater than zero.

updateCoordinates(self, struct)

 

Update the coordinates of the current structure with the values from the provided struct.

This allows an additional conformer to be minimized without re-running atomtyping. It is the caller's responsibility to make sure the molecules are equivalent and have the same atomtypes (i.e. same charges, connectivity).

minimize(self)

 

Minimize the provided Structure. Store results as properties in the Structure.

Note that this method will require a valid product license. Currently, MacroModel, GLIDE, Impact, or PLOP will suffice.

getBondedEnergyComponents(self, stretch_item_list, bending_item_list, torsion_item_list, imp_torsion_item_list)

 

Get energy components for bonded terms given in an list of stretches/bend/torsions/improper torsions (given as integer numbers) in *_item_list. The *_energy_list arguments are ignored.

Returns the corresponding energies as a tuple of double lists: (stretch_energy_list, bending_energy_list, torsion_energy_list, imp_torsion_energy_list).

Atoms are counted starting at zero.

NOTE: The API of this function may change in the next release.

getNBEnergyComponents(self, atom_list_i, atom_list_j, nb_energy_component_list)

 

TODO: this API should be eliminated. This is currently called by test programs in /mmshare/mmlibs/mmffld/test/*.py and one could replace the use of this API by calling getInteractionEnergyComponents() see Ev:133233.

Get the non-bonded energy components for two cases:

  1. For one list of atoms given in atom_list_i and their neighbors obtained from the pairlist. In this case the atom_list_j is empty on input and on output contains all the pairs of atoms used in the calculation.
  2. For two lists of atoms ( if atom_list_j is not zero ).

Note that atom_list_j is a list (of len(atom_list_i)) of lists.

The energy components are returned in a vector of length atom_list_i of a vector (of length atom_list_j) of a vector of double which includes the following energy components: 1) A_ij *R^-12 2) -B_ij *R^-6 3) Coulomb energy 4) interatomic distance r_ij

Note that this method will require a valid product license. Currently, MacroModel, GLIDE, Impact, or PLOP will suffice.

Atoms are counted starting at zero.

getNBEnergyForTwoAtomLists(self, atom_list_i, atom_list_j)

 

Get the non-bonded energy components for two arbitrary list of atoms. The total Coulomb and LJ interaction energies are returned.

setStructure(self, struct)

 

Change the structure to be minimized.

This method generally won't need to be called by the end user. To minimize different molecules, it is preferable to create separate Minimizer instances.

If only the coordinates of the structure changed, it is much faster to call updateCoordinates() instead of setStructure().

getEnergy(self, recalc=None)

 

Get the energy for the current structure from properties if possible, otherwise run a zero-step minimization to calculate the energy.

Return the energy in addition to storing it in the structure properties. Units are kcal/mol.

Parameters:
  • recalc (bool or None) - If set to True, calculate the energy based on the current structure. If False, return an existing energy if present. If None (the default), issue a warning and recalculate the energy. This behavior was changed in Suite 2010; in previous releases, the default was not to recalculate.

setOptions(self, **kwargs)

 

Set Minimizer options by keyword. To be used only internally by the constructor.

addTorsionRestraint(self, i, j, k, l, force_constant, target, flat_bottom=0.0)

 

Define a torsional restraint.

Parameters:
  • i (int), j (int), k (int), l (int) - atoms defining the restraint
  • force_constant (float) - force constant
  • target (float) - target value
  • flat_bottom (float) - flat-bottom half width (default 0.0)

addAngleRestraint(self, i, j, k, force_constant, target, flat_bottom=0.0)

 

Define an angle restraint.

Parameters:
  • i (int), j (int), k (int) - atoms defining the restraint
  • force_constant (float) - force constant
  • target (float) - target value
  • flat_bottom (float) - flat-bottom half width (default 0.0)

addDistanceRestraint(self, i, j, force_constant, target, flat_bottom=0.0)

 

Define a distance restraint.

Parameters:
  • i (int), j (int) - atoms defining the restraint
  • force_constant (float) - force constant
  • target (float) - target value
  • flat_bottom (float) - flat-bottom half width (default 0.0)

addPosRestraint(self, i, force_constant, flat_bottom=0.0)

 

Define a positional restraint.

Parameters:
  • i (int) - atom defining the restraint
  • force_constant (float) - force constant
  • flat_bottom (float) - flat-bottom half width (default 0.0)

addPosFrozen(self, i)

 

Define a frozen atom.

Parameters:
  • i (int) - atom to be frozen

deleteAllRestraints(self, rest_type=mm.MMFfldAllRestType)

 

Delete all the restraints for a given type (default all types).

Parameters:
  • rest_type (mm Constant) - One of:
    • mm.MMFfldTorsionRest
    • mm.MMFfldPosRest
    • mm.MMFfldPosFrozen
    • mm.MMFfldAllRestType

min_converged(self)

 

Return 1 if last minimization converged, 0 if it didn't.

Decorators:
  • @property

min_rms_gradient(self)

 

Return the RMS gradient of the last minimization.

Decorators:
  • @property

min_energy(self)

 

Return the energy calculated in the last minimization.

Decorators:
  • @property

getBondedEnergies(self, atom_subset)

 

Return bonded energies for bonded interactions within the given atom subset.

Parameters:
  • atom_subset (List of atom indices.) - Atoms to calculate bonded energies for.
Returns: tuple
(stretch-energy, bend-energy, torsion-energy, imp-tor-energy)

getBondedInteractionEnergy(self, atomset1, atomset2=None, verbose=False)

 

Return the bonded component of the interaction energy between the two given atom sets. If the second subset is not specified, instead use all other atoms from the CT.

Parameters:
  • atomset1 (List of atom indices.) - Atoms from the first subset.
  • atomset2 (List of atom indices.) - Atoms from the second subset.
Returns: float
The bonded interaction energy.

getNonBondedEnergies(self, atom_subset, verbose=False)

 

Given a list of atoms representing a substructure (e.g. a residue), return a tuple of:

  1. the sum of non-bonded energies WITHIN the set.
  2. the sum of non-bonded energies between the set atoms and everything else.
Parameters:
  • atom_subset (List of atom indices.) - Atoms to calculate non-bonded energies for.
Returns: tuple
(internal non-bonded energy in kcal/mol, non-bonded interaction energy in kcal/mol)

getSelfEnergy(self, atom_subset, include_intra_nb=True)

 

Return the internal energy of the the given atoms. This is the sum of all bonded interactions between the given atoms.

Parameters:
  • atom_subset (List of atom indices.) - Atoms to calculate self-energy for.
  • include_intra_nb (bool) - If True, include non-bonded interaction energy within the given subset. If False, include only bonded interactions.
Returns: float
Total self-energy

getSubsetEnergy(self, atom_subset, include_intra_nb=True, verbose=False)

 

Return the potential energy of the the given atoms.

It is a sum of bonded interactions within the atom set and the non-bonded interactions between the atom set and the rest of the structure (honoring the NB-cutoff). By default, the internal interaction energy is also included.

Parameters:
  • atom_subset (List of atom indices.) - Atoms to calculate energy for.
  • include_intra_nb (bool) - If True, also include non-bonded interaction energy within the given subset.
Returns: float
Total energy of the subset

_getInteractionEnergyBetweenSubsets(self, atom_subset1, atom_subset2, include_bonded=False, verbose=False)

 

Returns the interaction energy between the two atom groups. Private method, use getInteractionEnergy() instead.

Parameters:
  • atom_subset1 (List of atom indices.) - First atom set.
  • atom_subset2 (List of atom indices.) - Second atom set.
  • include_bonded (Boolean.) - Whether to also include bonded terms. By default, only non-bonded interactions are included, even if the atom sets are covalently bonded, and any bonded interactions are excluded.
Returns: float
Interaction energy betwen the given atom sets. (key: j atom; value: interaction energy)).

getInteractionEnergy(self, subset_atoms, consider_atoms=None, include_bonded=False, verbose=False)

 

Calculate the energy of interaction between the <subset_atoms> and the <consider_atoms>. If <consider_atoms> is not specified, then returns a sum of all interactions between the <subset_atoms> and the rest of the atoms.

Note that in the default case where <consider_atoms> is None, atoms outside of the cutoff are not considered.

Parameters:
  • subset_atoms (List of atom indices.) - First atom set.
  • consider_atoms (List of atom indices.) - Second atom set (optional)
  • include_bonded (Boolean.) - Whether to also include bonded terms. By default, only non-bonded interactions are included, even if the atom sets are covalently bonded, and any bonded interactions are excluded.
Returns: float
Interaction energy betwen the given atom sets (or between the given atom sets and the rest of the structure).

Class Variable Details [hide private]

min_method

Value:
_minimizer_int_property(mm.MMFfldOption_MIN_METHOD, doc= "See the cons\
tructor method for documentation.", readonly= False)

max_steps

Value:
_minimizer_int_property(mm.MMFfldOption_MIN_MAX_STEP, doc= "See the co\
nstructor method for documentation.", readonly= False)

energy_criterion

Value:
_minimizer_float_property(mm.MMFfldOption_MIN_CONV_ENER, doc= "See the\
 constructor method for documentation.", readonly= False)

gradient_criterion

Value:
_minimizer_float_property(mm.MMFfldOption_MIN_CONV_GRAD, doc= "See the\
 constructor method for documentation.", readonly= False)

verbose

Value:
_minimizer_int_property(mm.MMFfldOption_MIN_VERBOSE, doc= "See the con\
structor method for documentation.", readonly= False)

energy_no_electrostatics

Value:
_minimizer_int_property(mm.MMFfldOption_ENE_NO_ELE, doc= "See the cons\
tructor method for documentation.", readonly= True)

energy_lj_repulsive_only

Value:
_minimizer_int_property(mm.MMFfldOption_ENE_LJ_REPULSIVE_ONLY, doc= "S\
ee the constructor method for documentation.", readonly= True)

nonbonded_cutoff

Value:
_minimizer_float_property(mm.MMFfldOption_SYS_CUTOFF, doc= "See the co\
nstructor method for documentation.", readonly= False)

maintain_planarity

Value:
_minimizer_int_property(mm.MMFfldOption_TYPER_PLANAR_SC_ENABLE, doc= "\
See the constructor method for documentation.", readonly= True)

dielectric_constant

Value:
_minimizer_float_property(mm.MMFfldOption_ENE_DIELECTRIC, doc= "See th\
e constructor method for documentation.", readonly= True)