Package ffx.algorithms.optimize
Class RotamerOptimization
java.lang.Object
ffx.algorithms.optimize.RotamerOptimization
- All Implemented Interfaces:
Terminatable
Optimize protein side-chain conformations and nucleic acid backbone conformations using rotamers.
- Since:
- 1.0
- Author:
- Michael J. Schnieders, Jacob M. Litman, Stephen D. LuCore, Mallory R. Tollefson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Rotamer Optimization Methods.static enum
static enum
Allows get2BodyDistance to find the shortest distance between any two rotamers or two residues. -
Field Summary
Modifier and TypeFieldDescriptionprotected final AlgorithmListener
AlgorithmListener who should receive updates as the optimization runs.protected RotamerLibrary
RotamerLibrary instance.protected final MolecularAssembly
MolecularAssembly to perform rotamer optimization on.protected final Potential
The Potential to evaluate during rotamer optimization. -
Constructor Summary
ConstructorDescriptionRotamerOptimization
(MolecularAssembly molecularAssembly, Potential potential, AlgorithmListener algorithmListener) RotamerOptimization constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkNeighboringPair
(int i, int j) Checks if residue i is considered to be interacting with residue j, and thus has non-null elements in the pair energies matrix.boolean
checkNeighboringTriple
(int i, int j, int k) Checks if residue i is considered to be interacting with residue j, that residue k is interacting with either i or j, and thus i-j-k has non-null elements in the triple energy matrix.boolean
checkValidMove
(int i, int ri, int[] currentRots) Checks the pair elimination array to see if this permutation has been eliminated.double
computeBackboneEnergy
(Residue[] residues) Computes the environment/backbone energy, defined as energy with all sidechains under consideration turned off in their 0th rotamer.double
computeEnergy
(Residue[] residues, int[] rotamers, boolean print) Uses existing backbone, self, 2-Body, and 3-body energies from rotamerEnergies() to calculate an approximate energy for a rotamer permutation.double
currentEnergy
(Residue[] resArray) Calculates the energy at the current state.double
currentEnergyWrapper
(List<Residue> resList) Wrapper intended for use with RotamerMatrixMC.double
Forces the use of a ForceFieldEnergyOpenMM's underlying ForceFieldEnergy.formatEnergy
(double energy) Utility method for formatting energies, using 16 spaces with 8 digits of precision.double
double
List
<ResidueState[]> getEnsemble.double[][]
Get the ensemble average of protonated rotamers for all titratable sitesint[]
Return an integer array of optimized rotamers following rotamer optimization.double
getPH()
double
double[][]
Get the Protonated Boltzmann for all sitesvoid
getPopulations
(Residue[] residues, int i, int[] currentRotamers) Calculate Populations for Residuesdouble
Get reference energy for partition function boltzmann weightsReturn the residue list.Returns the restart file.double
Get the total boltzmann weight for an ensembledouble
goldsteinPairSumOverK
(Residue[] residues, int lb, int ub, int i, int riA, int riB, int j, int rjC, int rjD, List<Residue> blockedResidues, int[] possK) void
logIfRank0
(String msg) void
logIfRank0
(String msg, Level level) double
optimize()
Execute the rotamer optimization.double
optimize
(RotamerOptimization.Algorithm algorithm) Perform the rotamer optimization using the specified algorithm.void
partitionFunction
(Residue[] residues, int i, int[] currentRotamers) A global optimization over side-chain rotamers using a recursive algorithm and information about eliminated rotamers, rotamer pairs and rotamer triples.double
rotamerOptimization
(MolecularAssembly molecularAssembly, Residue[] residues, int i, double lowEnergy, int[] optimum) A brute-force global optimization over side-chain rotamers using a recursive algorithm.void
setApproxBoxLength
(double approxBoxLength) Sets the approximate dimensions of boxes, over-riding numXYZBoxes in determining box size.void
setBoxBorderSize
(double boxBorderSize) Sets the amount of overlap between adjacent boxes for box optimization.void
setBoxEnd
(int boxEnd) Set the ending box index.void
setBoxInclusionCriterion
(int boxInclusionCriterion) Sets behavior for how Residues are added to boxOptCells; 1 uses just reference atom (C alpha for protein, N1/9 for nucleic acids), 2 uses any atom, 3 uses any atom in any rotamer.void
setBoxStart
(int boxStart) Set the starting box index.void
setCoordinatesToEnsemble
(int ensnum) setCoordinatesToEnsemble.void
setDecomposeOriginal
(boolean decomposeOriginal) Sets the decompose-original flag.void
setDirection
(RotamerOptimization.Direction direction) Set the optimization direction to forward or backward.void
setDistanceCutoff
(double distance) Set the cut-off distance for inclusion of residues in sliding box and window methods.void
setEnergyRestartFile
(File file) Setter for the fieldenergyRestartFile
.void
setEnsemble
(int ensemble) setEnsemble.void
setEnsemble
(int ensemble, double ensembleBuffer) setEnsemble.void
setIncrement
(int increment) Set the residue increment for sliding window.void
setMaxRotCheckDepth
(int maxRotCheckDepth) Control the depth of self-consistency checking with a rotamer is eliminated.void
setMinimumNumberAcceptedNARotamers
(int minNumberAcceptedNARotamers) Set the minimum number of accepted nucleic acid rotamers.void
setMonteCarlo
(boolean monteCarlo, int nMCsteps) Sets the option to use a number of Monte Carlo steps for final optimization.void
setMonteCarloTesting
(boolean bool) Sets the monteCarloTesting boolean in RotamerOptimization.java to true or false.void
setNucleicCorrectionThreshold
(double nucleicCorrectionThreshold) The nucleic acid correction threshold.void
setNucleicPruningFactor
(double nucleicPruningFactor) Also sets derivative pruning factors.void
setNumXYZBoxes
(int[] numXYZBoxes) Sets the number of boxes in the x, y, and z axes if the box optimization is to be carried out.void
setOnlyProtons
(boolean onlyProtons) void
setPairClashThreshold
(double pairClashThreshold) Setter for the fieldpairClashThreshold
.void
setpH
(double pH) void
setPHRestraint
(double pHRestraint) void
setPrintFiles
(boolean printFiles) Sets whether rotamer optimization should print out any files, or act solely to optimize a structure in memory.void
setPruning
(int set) Sets level of pruning: 0 for fully off, 1 for only singles, 2 for single and pair pruning.void
setRecomputeSelf
(boolean recomputeSelf) void
setResidues
(List<Residue> residueList) Set the residue list.void
setResiduesIgnoreNull
(List<Residue> residues) Accepts a list of residues but throws out null residues.void
setRevert
(boolean revert) Set the algorithm to revert to starting coordinates if the energy increases.void
void
setSingletonClashThreshold
(double singletonClashThreshold) setSingletonClashThreshold.void
setSuperpositionThreshold
(double superpositionThreshold) Setter for the fieldsuperpositionThreshold
.void
setThreeBodyCutoff
(double threeBodyCutoffDist) Sets the threeBodyCutoffDist.void
setThreeBodyEnergy
(boolean threeBodyTerm) Flag to control use of 3-body energy terms.void
setTwoBodyCutoff
(double twoBodyCutoffDist) Sets the twoBodyCutoffDist.void
setUseGoldstein
(boolean useGoldstein) Specify use of Goldstein optimization.void
setWindowSize
(int windowSize) Setter for the fieldwindowSize
.void
setWriteEnergyRestart
(boolean writeEnergyRestart) Set the writeEnergyRestart flag.void
This should be implemented as a blocking interrupt; when the method returns theTerminatable
algorithm has reached a clean termination point.toString()
void
turnOffAllResidues
(Residue[] residues) void
turnOffResidue
(Residue residue) void
turnOnAllResidues
(Residue[] residues) void
turnOnResidue
(Residue residue, int ri) void
ONLY FOR UNIT TESTING.void
ONLY FOR UNIT TESTING.
-
Field Details
-
molecularAssembly
MolecularAssembly to perform rotamer optimization on. -
potential
The Potential to evaluate during rotamer optimization. -
algorithmListener
AlgorithmListener who should receive updates as the optimization runs. -
library
RotamerLibrary instance.
-
-
Constructor Details
-
RotamerOptimization
public RotamerOptimization(MolecularAssembly molecularAssembly, Potential potential, AlgorithmListener algorithmListener) RotamerOptimization constructor.- Parameters:
molecularAssembly
- The MolecularAssembly to search rotamers for.potential
- aPotential
object.algorithmListener
- AlgorithmListener to update the GUI.
-
-
Method Details
-
setWriteEnergyRestart
public void setWriteEnergyRestart(boolean writeEnergyRestart) Set the writeEnergyRestart flag.- Parameters:
writeEnergyRestart
- If true, write out an energy restart file.
-
checkNeighboringPair
public boolean checkNeighboringPair(int i, int j) Checks if residue i is considered to be interacting with residue j, and thus has non-null elements in the pair energies matrix.- Parameters:
i
- A residue index.j
- A residue index j != i.- Returns:
- If i and j interact.
-
checkNeighboringTriple
public boolean checkNeighboringTriple(int i, int j, int k) Checks if residue i is considered to be interacting with residue j, that residue k is interacting with either i or j, and thus i-j-k has non-null elements in the triple energy matrix.- Parameters:
i
- A residue index.j
- A residue index j != i.k
- A residue index k != i, k != j.- Returns:
- If i, j, and k form an interacting triple.
-
checkValidMove
public boolean checkValidMove(int i, int ri, int[] currentRots) Checks the pair elimination array to see if this permutation has been eliminated.- Parameters:
i
- Residue numberri
- Rotamer numbercurrentRots
- Array of current rotamers indeces.- Returns:
- If valid
-
computeBackboneEnergy
Computes the environment/backbone energy, defined as energy with all sidechains under consideration turned off in their 0th rotamer.- Parameters:
residues
- Residues under optimization.- Returns:
- Backbone energy Eenv/bb.
- Throws:
ArithmeticException
- If an exception in calculating energy is found.
-
computeEnergy
Uses existing backbone, self, 2-Body, and 3-body energies from rotamerEnergies() to calculate an approximate energy for a rotamer permutation.- Parameters:
residues
- Current window of optimization.rotamers
- Set of rotamers to calculate an approximate energy for.print
- Verbosity flag- Returns:
- Approximate permutation energy (backbone + selfs + pairs + trimers).
-
currentEnergy
Calculates the energy at the current state.- Parameters:
resArray
- Array of residues in current energy term.- Returns:
- Energy of the current state.
- Throws:
ArithmeticException
-
currentEnergyWrapper
Wrapper intended for use with RotamerMatrixMC.- Parameters:
resList
- Reside list.- Returns:
- Returns the current energy.
- Throws:
ArithmeticException
- Thrown if there is an arithmetic exception computing the energy.
-
currentFFXPE
public double currentFFXPE()Forces the use of a ForceFieldEnergyOpenMM's underlying ForceFieldEnergy.- Returns:
- Current potential energy as calculated by FFX reference platform.
-
formatEnergy
Utility method for formatting energies, using 16 spaces with 8 digits of precision.- Parameters:
energy
- Energy to format.- Returns:
- A string representing the energy.
-
getApproximate
public double getApproximate() -
getBackboneEnergy
public double getBackboneEnergy() -
getEliminatedRotamers
-
getEnergyExpansion
-
getEnsemble
getEnsemble.- Returns:
- a
List
object.
-
setEnsemble
public void setEnsemble(int ensemble) setEnsemble.- Parameters:
ensemble
- a int.
-
getResidues
Return the residue list.- Returns:
- a
List
object.
-
setResidues
Set the residue list.- Parameters:
residueList
- aList
object.
-
getRestartFile
Returns the restart file.- Returns:
- energyRestartFile File with saved side-chain energies.
-
goldsteinPairSumOverK
-
logIfRank0
-
logIfRank0
-
optimize
Perform the rotamer optimization using the specified algorithm.- Parameters:
algorithm
- aRotamerOptimization.Algorithm
object.- Returns:
- the lowest energy found.
-
optimize
public double optimize()Execute the rotamer optimization.- Returns:
- The lowest energy found.
-
rotamerOptimization
public double rotamerOptimization(MolecularAssembly molecularAssembly, Residue[] residues, int i, double lowEnergy, int[] optimum) A brute-force global optimization over side-chain rotamers using a recursive algorithm.- Parameters:
molecularAssembly
- aMolecularAssembly
object.residues
- an array ofResidue
objects.i
- a int.lowEnergy
- a double.optimum
- an array ofinvalid reference
int
- Returns:
- the current energy.
-
setPHRestraint
public void setPHRestraint(double pHRestraint) -
setpH
public void setpH(double pH) -
setRecomputeSelf
public void setRecomputeSelf(boolean recomputeSelf) -
setOnlyProtons
public void setOnlyProtons(boolean onlyProtons) -
getPHRestraint
public double getPHRestraint() -
getPH
public double getPH() -
setApproxBoxLength
public void setApproxBoxLength(double approxBoxLength) Sets the approximate dimensions of boxes, over-riding numXYZBoxes in determining box size. Rounds box size up and number of boxes down to get a whole number of boxes along each axis.- Parameters:
approxBoxLength
- Optional box dimensions parameter (Angstroms).
-
setBoxBorderSize
public void setBoxBorderSize(double boxBorderSize) Sets the amount of overlap between adjacent boxes for box optimization.- Parameters:
boxBorderSize
- Box overlap in Angstroms.
-
setBoxEnd
public void setBoxEnd(int boxEnd) Set the ending box index.- Parameters:
boxEnd
- a int.
-
setBoxInclusionCriterion
public void setBoxInclusionCriterion(int boxInclusionCriterion) Sets behavior for how Residues are added to boxOptCells; 1 uses just reference atom (C alpha for protein, N1/9 for nucleic acids), 2 uses any atom, 3 uses any atom in any rotamer.- Parameters:
boxInclusionCriterion
- Criterion to use
-
setBoxStart
public void setBoxStart(int boxStart) Set the starting box index.- Parameters:
boxStart
- a int.
-
setCoordinatesToEnsemble
public void setCoordinatesToEnsemble(int ensnum) setCoordinatesToEnsemble.- Parameters:
ensnum
- a int.
-
setDecomposeOriginal
public void setDecomposeOriginal(boolean decomposeOriginal) Sets the decompose-original flag.- Parameters:
decomposeOriginal
- If true, decompose the energy of the structure without optimizing.
-
setDirection
Set the optimization direction to forward or backward.- Parameters:
direction
- aRotamerOptimization.Direction
object.
-
setDistanceCutoff
public void setDistanceCutoff(double distance) Set the cut-off distance for inclusion of residues in sliding box and window methods.- Parameters:
distance
- a double.
-
setEnergyRestartFile
Setter for the fieldenergyRestartFile
.- Parameters:
file
- aFile
object.
-
setEnsemble
public void setEnsemble(int ensemble, double ensembleBuffer) setEnsemble.- Parameters:
ensemble
- a int.ensembleBuffer
- a double.
-
setIncrement
public void setIncrement(int increment) Set the residue increment for sliding window.- Parameters:
increment
- a int.
-
setMaxRotCheckDepth
public void setMaxRotCheckDepth(int maxRotCheckDepth) Control the depth of self-consistency checking with a rotamer is eliminated.- Parameters:
maxRotCheckDepth
- a int.
-
setMinimumNumberAcceptedNARotamers
public void setMinimumNumberAcceptedNARotamers(int minNumberAcceptedNARotamers) Set the minimum number of accepted nucleic acid rotamers.- Parameters:
minNumberAcceptedNARotamers
- a int.
-
setMonteCarlo
public void setMonteCarlo(boolean monteCarlo, int nMCsteps) Sets the option to use a number of Monte Carlo steps for final optimization.- Parameters:
monteCarlo
- If Monte Carlo is to be considerednMCsteps
- Number of steps to be taken
-
setMonteCarloTesting
public void setMonteCarloTesting(boolean bool) Sets the monteCarloTesting boolean in RotamerOptimization.java to true or false. This should only be set to true when monte carlo is being tested through the ManyBodyTest script. When true, the method sets a seed for the pseudo-random number generator and allows the monte carlo rotamer optimization to be deterministic.- Parameters:
bool
- True or false.
-
setNucleicCorrectionThreshold
public void setNucleicCorrectionThreshold(double nucleicCorrectionThreshold) The nucleic acid correction threshold.- Parameters:
nucleicCorrectionThreshold
- a double.
-
setNucleicPruningFactor
public void setNucleicPruningFactor(double nucleicPruningFactor) Also sets derivative pruning factors.- Parameters:
nucleicPruningFactor
- a double.
-
setNumXYZBoxes
public void setNumXYZBoxes(int[] numXYZBoxes) Sets the number of boxes in the x, y, and z axes if the box optimization is to be carried out.- Parameters:
numXYZBoxes
- Int[3] of number of boxes in x, y, z.
-
setPairClashThreshold
public void setPairClashThreshold(double pairClashThreshold) Setter for the fieldpairClashThreshold
.- Parameters:
pairClashThreshold
- a double.
-
setPrintFiles
public void setPrintFiles(boolean printFiles) Sets whether rotamer optimization should print out any files, or act solely to optimize a structure in memory.- Parameters:
printFiles
- a boolean.
-
setPruning
public void setPruning(int set) Sets level of pruning: 0 for fully off, 1 for only singles, 2 for single and pair pruning.- Parameters:
set
- Pruning option.
-
setResiduesIgnoreNull
Accepts a list of residues but throws out null residues. Used by the -lR flag.- Parameters:
residues
- aList
object.
-
setRevert
public void setRevert(boolean revert) Set the algorithm to revert to starting coordinates if the energy increases.- Parameters:
revert
- a boolean.
-
setRotamerLibrary
-
setSingletonClashThreshold
public void setSingletonClashThreshold(double singletonClashThreshold) setSingletonClashThreshold.- Parameters:
singletonClashThreshold
- a double.
-
setSuperpositionThreshold
public void setSuperpositionThreshold(double superpositionThreshold) Setter for the fieldsuperpositionThreshold
.- Parameters:
superpositionThreshold
- a double.
-
setThreeBodyCutoff
public void setThreeBodyCutoff(double threeBodyCutoffDist) Sets the threeBodyCutoffDist. All three-body energies where the rotamers have a separation distance larger than the cutoff are set to 0.- Parameters:
threeBodyCutoffDist
- Separation distance at which the interaction of three side-chains is assumed to have an energy of 0.
-
setThreeBodyEnergy
public void setThreeBodyEnergy(boolean threeBodyTerm) Flag to control use of 3-body energy terms.- Parameters:
threeBodyTerm
- a boolean.
-
setTwoBodyCutoff
public void setTwoBodyCutoff(double twoBodyCutoffDist) Sets the twoBodyCutoffDist. All two-body energies where the rotamers have a separation distance larger than the cutoff are set to 0.- Parameters:
twoBodyCutoffDist
- Separation distance at which the interaction of two side-chains is assumed to have an energy of 0.
-
setUseGoldstein
public void setUseGoldstein(boolean useGoldstein) Specify use of Goldstein optimization.- Parameters:
useGoldstein
- a boolean.
-
setWindowSize
public void setWindowSize(int windowSize) Setter for the fieldwindowSize
.- Parameters:
windowSize
- a int.
-
terminate
public void terminate()This should be implemented as a blocking interrupt; when the method returns theTerminatable
algorithm has reached a clean termination point. For example, between minimize or molecular dynamics steps.- Specified by:
terminate
in interfaceTerminatable
-
toString
-
turnOffAllResidues
-
turnOffResidue
-
turnOnAllResidues
-
turnOnResidue
-
turnRotamerPairEliminationOff
public void turnRotamerPairEliminationOff()ONLY FOR UNIT TESTING. Sets a boolean to turn the pair elimination criteria off. -
turnRotamerSingleEliminationOff
public void turnRotamerSingleEliminationOff()ONLY FOR UNIT TESTING. Sets a boolean to turn the self elimination criteria off. -
partitionFunction
A global optimization over side-chain rotamers using a recursive algorithm and information about eliminated rotamers, rotamer pairs and rotamer triples.- Parameters:
residues
- Residue array.i
- Current number of permutations.currentRotamers
- Current rotamer list.- Throws:
Exception
-
getRefEnergy
public double getRefEnergy()Get reference energy for partition function boltzmann weights- Returns:
- ref energy
-
getTotalBoltzmann
public double getTotalBoltzmann()Get the total boltzmann weight for an ensemble- Returns:
- total boltzmann
-
getFraction
public double[][] getFraction()Get the ensemble average of protonated rotamers for all titratable sites- Returns:
- fraction of protonated residues
-
getPopulationBoltzmann
public double[][] getPopulationBoltzmann()Get the Protonated Boltzmann for all sites- Returns:
- fraction of protonated residues
-
getPopulations
Calculate Populations for Residues- Parameters:
residues
- residue arrayi
- intcurrentRotamers
- empty array- Throws:
Exception
- too many permutations to continue
-
getOptimumRotamers
public int[] getOptimumRotamers()Return an integer array of optimized rotamers following rotamer optimization.- Returns:
- The optimal rotamer array.
-