Hi,
On Wed, Mar 19, 2008 at 1:32 PM, Bob Hanson hansonr@stolaf.edu wrote:
Tim, this is really the idea I’m looking for – extracting out the
essentials of minimization. I realize that the VM idea is a possible
solution, but it’s not very practical, and a Java port should not be
that bad. I’d like to do it (next week if possible). It looks to me like
embedded in that 2Mb jar file is about 8300K of code and 200K of
parameters. That’s substantial, but not so bad, really. No need to have
the 1998K of VM tagging along.
The interesting thing is that we already have Jmol set up as an applet
that can accept optional packages. The packages are only downloaded to
the client if they are needed, almost like JPEG images on a page.
Can you point me to the source code for OBMinimize.class? I’d like to
see what it is about and how difficult it would be to do a Java port of
it. I believe we could have minimization in Jmol without too much
trouble. Then the world would have an outstanding molecular
visualization applet with the option for minimization. That would be
something to talk about!
The OBMinimize.class is the openbabel program obminimize. The source
can be found in tools/obminimize.cpp but it is just a small program to
access the OBForceField class. Below I’ll try to make a summary of
things you need to port to java to get basic MM features.
source can be found at:
http://openbabel.svn.sourceforge.net/viewvc/openbabel/openbabel/trunk/
The main class with general methods is the OBForceField class
(include/openbabel/forcefield.h, src/forcefield.cpp). Specific force
fields derived from this class and can be found in src/forcefields/.
As Geoff mentioned, MMFF94 is widely used but more complex to
implement compared to UFF. If you only intend to implement a single
FF, you could make a single java class with methods from OBForceField
and OBForceFieldUFF combined.
Essential methods from OBForceField for minimization:
double LineSearch(double *currentCoords, double *direction);
- Needed for steepest descent and/or conjugate gradients
void SteepestDescentInitialize(int steps = 1000, double econv = 1e-6f,
int method = OBFF_ANALYTICAL_GRADIENT);
bool SteepestDescentTakeNSteps(int n);
- Steepest descent: simple but works (this is probably what you
want for a rough minimization in an applet.
- There are similar methods for conjugate gradients
static double VectorBondDerivative(double *pos_i, double *pos_j,
double *force_i, double *force_j);
static double VectorAngleDerivative(double *pos_i, double *pos_j,
double *pos_k, double *force_i, double *force_j, double *force_k);
static double VectorOOPDerivative(double *pos_i, double *pos_j, double
*pos_k, double *pos_l, double *force_i, double *force_j, double
*force_k, double *force_l);
static double VectorTorsionDerivative(double *pos_i, double *pos_j,
double *pos_k, double *pos_l, double *force_i, double *force_j, double
*force_k, double *force_l);
- These functions help you calculate analytical gradients (If your
time is limited, you could also use numerical gradients, but
performance will be lower)
Here are the virtual methods that are reimplemented in specific force fields:
virtual bool ParseParamFile() { return false; }
- Load the parameters from the parameter file into a
vector (note: UFF has only one parameter file)
bool Setup(OBMol &mol);
- Make a copy of the molecule
- call the functions below…
virtual bool SetTypes() { return false; }
- Set the atom types used in the force field…
virtual bool SetFormalCharges() { return false; }
- Set the formal charges as specified by the force field… (note:
these are not used directly)
virtual bool SetPartialCharges() { return false; }
- Set the partial charges as specified by the force field…
virtual bool SetupCalculations() { return false; }
- Setup a vector for each energy term
(bond-stretching, angle bending, …)
- Again, OBFFCalculation is a general class, specific force fields
derive their own OBFFBondCalculationUFF for example.
(src/forcefields/forcefielduff.h)
- This function uses the atom type, partial charge, … to fill in
the values for each OBFFCalculation
virtual double Energy(bool = true) { return 0.0f; }
- call the functions below…
virtual double E_Bond(bool = true) { return 0.0f; }
- iterate over the bond vector, call
OBFFCalculation::Compute() and return the sum of the individual
interaction energies.
virtual double E_Angle(bool = true) { return 0.0f; }
- same…
virtual double E_StrBnd(bool = true) { return 0.0f; }
virtual double E_Torsion(bool = true) { return 0.0f; }
virtual double E_OOP(bool = true) { return 0.0f; }
virtual double E_VDW(bool = true) { return 0.0f; }
virtual double E_Electrostatic(bool = true) { return 0.0f; }
That’s about it I think. There are some very general things like
VectorCross, GetGradient, … but those names should speak for
themselves. If you have more specific questions, do not hesitate to
ask.
Tim