# The Way of Zap¶

There follows a dozen or so examples of using ZAP. The list is always growing because the toolkit philosophy really does work. Most of the examples use OEInterface to provide consistent command-line argument handling.

## Partial Charges and Atomic Radii¶

There are three essential quantities for any PB calculation: coordinates, dielectric model (including radii), and charge. Coordinates will come from the atomic coordinates of the input molecule, but partial charges and the dielectric model deserve some extra attention.

Charges and radii can be calculated at run-time using functions provided by OEChem or other OpenEye toolkits (AM1-BCC charges from Quacpac TK for example). The dielectric model consists of both the value of the inner and outer dielectric, as well as how the dielectric adjusts from one to the other. ZAP uses atomic radii as the basis for its dielectric algorithm. By default, we recommend using Bondi VdW radii which can be set on a molecule using the function OEAssignBondiVdWRadii Or you can set specific radii on an atom-by-atom basis using the OEAtomBase::SetRadius function.

The current recommended value for the inner and outer dielectrics for a molecule in an aqueous solution are 1.0 and 80.0. Therefore, these are the default values for the OEZap and OEBind implementations. The historic value for the inner dielectric is 2.0, and this value may be set using the SetInnerDielectric method. Additionally, the default value for the inner dielectric of the OEET implementation remains at 2.0 for the time being.

Accurate PB calculations also depend on quality atomic charges. In OEChem, we provide MMFF94 partial charges as the lowest level of charges that we consider usable in PB. The examples that follow will use these charges, so that they don’t depend on any toolkits beside ZAP and OEChem. But for production use, we recommend AM1-BCC charges

If your input file format can store partial charges and/or radii, you can use those values instead of calculating them at run time. OEB files can store radii and partial charges, so they serve as a useful intermediate file between many OpenEye programs. Note that charges and radii will only be written to an OEB file if they are present on the molecule when written.

Atomic charges can come in a PDB file, along with atomic radii, in the form of the extra fields added after the coordinates. This style originated with DelPhi. Note that to get OEChem to read charges and radii from these fields in a PDB file, you need to set a specific flavor on the input oemolistream before reading any molecules from the stream.

oemolistream ifs = new oemolistream();
ifs.SetFlavor(OEFormat.PDB, OEIFlavor.PDB.Default | OEIFlavor.PDB.DELPHI);


## Grids¶

ZAP uses regular cubic lattices, or grids, to solve the PB equation. The examples here illustrate how to retrieve such from the calculation and to manipulate and store the information held by each. Typically, grids are not used per se but information is extracted, such as the potential at particular points in space, as is illustrated in the next section. However, some programs, such as VIDA, can read grids and display their properties. Also, having direct access to grids allows for manipulations of the potential map that may not have been anticipated.

This first example shows the simplest method of generating a grid of potentials using ZAP. We save the grid in OpenEye GRD (*.grd) format which is a compact, binary format that can be visualized in VIDA. Alternatively, the grid can be written into GRASP format (*.phi), which means that the grid stored will be 65 cubed irregardless of the size of the grid used in the calculation. A $$65^3$$ grid is obtained by interpolation to a grid with that many points that fits over the largest dimension of the grid calculated.

Listing 1: Calculating a potential grid

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oegrid.*;
import openeye.oezap.*;

public class ZapGrid1 {

public static void main(String argv[]) {
if (argv.length != 1) {
System.err.println("usage: ZapGrid1 <molfile>");
System.exit(1);
}

OEGraphMol mol = new OEGraphMol();
oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open for reading: " + argv[0]);
System.exit(1);
}
oechem.OEMMFFAtomTypes(mol);
oechem.OEMMFF94PartialCharges(mol);
ifs.close();

OEZap zap = new OEZap();
zap.SetInnerDielectric(1.0f);
zap.SetGridSpacing(0.5f);
zap.SetMolecule(mol);

OEScalarGrid grid = new OEScalarGrid();
if (zap.CalcPotentialGrid(grid))
oegrid.OEWriteGrid("zap.grd", grid);
zap.delete();
}
}


The next example is an elaboration of the previous simple version where we add in control of the parameters of the calculation. Options are provided to set the internal and external (solute and solvent) dielectric constants, the distance between the molecule and the edges of the grid (boundary spacing or buffer) and the grid spacing. A smaller grid spacing implies a more dense and accurate grid, but it does come with a larger memory footprint.

Listing 2: Calculating potential grid with optional parameters

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import java.net.URL;
import openeye.oechem.*;
import openeye.oegrid.*;
import openeye.oezap.*;

public class ZapGrid2 {
static {
oechem.OEThrow.SetStrict(true);
}

private void createGrid(OEInterface itf) {
OEGraphMol mol = new OEGraphMol();
oemolistream ifs = new oemolistream();
if (!ifs.open(itf.GetString("-in"))) {
System.err.println("Unable to open for reading: " + itf.GetString("-in"));
System.exit(1);
}
oechem.OEMMFFAtomTypes(mol);
oechem.OEMMFF94PartialCharges(mol);
ifs.close();

OEZap zap = new OEZap();
zap.SetInnerDielectric(itf.GetFloat("-epsin"));
zap.SetOuterDielectric(itf.GetFloat("-epsout"));
zap.SetGridSpacing(itf.GetFloat("-grid_spacing"));
zap.SetBoundarySpacing(itf.GetFloat("-buffer"));
zap.SetMolecule(mol);

OEScalarGrid grid = new OEScalarGrid();
if (zap.CalcPotentialGrid(grid)) {
}
}
oegrid.OEWriteGrid(itf.GetString("-out"), grid);
zap.delete();
}

public static void main(String argv[]) {
ZapGrid2 app = new ZapGrid2();
OEInterface itf = new OEInterface();
URL fileURL = app.getClass().getResource("ZapGrid2.txt");
try {
oechem.OEConfigureFromURL(itf, fileURL);
if (oechem.OECheckHelp(itf, argv)) {
return;
}
oechem.OEParseCommandLine(itf, argv);
app.createGrid(itf);
} catch (java.io.IOException e) {
System.err.println("Unable to open interface file");
}
}
}


Here we show how to calculate a difference-map, that is to say the potential difference between a standard, two dielectric, calculation and a single dielectric calculation (approximating pure Coulombic potentials). These difference potentials represent the electrostatic response of the solvent to the charges within the solute molecule. If we mask away everything outside the molecule, we can see the contributions from the charges inside the molecule.

Listing 3: Calculating potential grid with optional parameters

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oegrid.*;
import openeye.oezap.*;

public class ZapGrid3 {

public static void main(String argv[]) {
if (argv.length != 1) {
System.err.println("usage: ZapGrid3 <molfile>");
System.exit(1);
}

OEGraphMol mol = new OEGraphMol();
oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open for reading: " + argv[0]);
System.exit(1);
}
ifs.close();

oechem.OEMMFFAtomTypes(mol);
oechem.OEMMFF94PartialCharges(mol);

OEZap zap = new OEZap();
zap.SetInnerDielectric(1.0f);
zap.SetGridSpacing(0.5f);
zap.SetMolecule(mol);

// calculate standard 2-dielectric grid
OEScalarGrid grid1 = new OEScalarGrid();
zap.CalcPotentialGrid(grid1);

// calculate grid with single dielectric
OEScalarGrid grid2 = new OEScalarGrid();
zap.SetOuterDielectric(zap.GetInnerDielectric());
zap.CalcPotentialGrid(grid2);

// take the difference
oegrid.OESubtractScalarGrid(grid1, grid2);

// mask out everything outside the molecule

oegrid.OEWriteGrid("zap_diff.grd", grid1);

// explicit clean ups
grid1.delete();
grid2.delete();
zap.delete();
}
}


## Atom Potentials¶

The potentials at any charge, as calculated by PB, can be decomposed into three forms

1. Induced solvent potential: the potential produced by the polarization of the solvent.
2. Inter-charge Coulombic energy: the potential that would be produced if the solvent had the same dielectric as the solute molecule from all other charges.
3. Self potential: the potential produced by a charge at itself. Of course, as mentioned above, this is infinite analytically, but PB will produce an “approximation” to this infinity because the grid spacing is finite.

This example program shows how to calculate each of these quantities. In addition to command line flags to control dielectric, grid spacing, etc., there are three flags that affect the type of potentials calculated:

• -calc_type solvent_only
• -calc_type remove_self
• -calc_type coulombic

With none of these flags, the code executes a single PB calculation, interpolates the potentials from the grid produced, reports the sum of these potentials multiplied by the charge on the respective atoms and outputs these potentials and charges in a table. This potential corresponds to (a)+(b)+(b) above.

Using the -calc_type solvent_only option executes two PB calculations, the standard calculation plus a second calculation where the external dielectric has been set to the solute dielectric. The atom potentials are then formed from the difference of these two calculations such that the remaining potential is that produced by the solvent alone. The sum of this set of atomic potentials multiplied by atomic charges all multiplied by 0.5 is the electrostatic component of transferring from a media of the same dielectric as the solute to water. These potentials correspond to (a) above.

The -calc_type remove_self flag for the example program below executes an internal algorithm in the ZAP toolkit that extracts from each atom potential that potential produced by that atom, if it is charged. This it removes the artifactual energy from the grid, i.e. energy that is not actually physical but a manifestation of the finite resolution of the grids used. The remaining potential is then that from the solvent and that from all the other charges, that is (a)+(b) above.

The -calc_type coulombic flag actually prevents any PB calculation. It merely uses Coulomb’s Law to calculate the potential (b), the inner-atomic Coulombic potential.

Listing 4: Calculating atom potentials

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import java.net.URL;
import openeye.oechem.*;
import openeye.oezap.*;

public class ZapAtoms1 {
static {
oechem.OEThrow.SetStrict(true);
}

private static void Output(OEMolBase mol, OEFloatArray apot, boolean atomtable) {
System.out.println("Title: " + mol.GetTitle());
if (atomtable) {
System.out.println("Atom potentials");
System.out.println("Index Elem Charge Potential");
}
double energy = 0.0f;
OEAtomBaseIter aiter = mol.GetAtoms();
while (aiter.hasNext()) {
OEAtomBase atom = aiter.next();
energy += atom.GetPartialCharge() * apot.getItem(atom.GetIdx());
if (atomtable) {
System.out.println(String.format("%4d   %2s   %4.1f  %8.3f",
atom.GetIdx(),
oechem.OEGetAtomicSymbol(atom.GetAtomicNum()),
atom.GetPartialCharge(),
apot.getItem(atom.GetIdx())));
}
}
System.out.println("Sum of (Potential * Charge * 0.5) in kT = " + energy * 0.5f);
}

private void Calc(OEInterface itf) {
OEGraphMol mol = new OEGraphMol();
oemolistream ifs = new oemolistream();
String infile = itf.GetString("-in");

if (!ifs.open(infile)) {
System.err.println("Unable to open for reading: " + infile);
System.exit(1);
}

if (!itf.GetBool("-file_charges")) {
oechem.OEMMFFAtomTypes(mol);
oechem.OEMMFF94PartialCharges(mol);
}
ifs.close();

OEZap zap = new OEZap();
zap.SetMolecule(mol);
zap.SetInnerDielectric(itf.GetFloat("-epsin"));
zap.SetBoundarySpacing(itf.GetFloat("-boundary"));
zap.SetGridSpacing(itf.GetFloat("-grid_spacing"));

String calcType = itf.GetString("-calc_type");
if (calcType.equals("default")) {
OEFloatArray apot = new OEFloatArray(mol.GetMaxAtomIdx());
zap.CalcAtomPotentials(apot);
System.out.println("Before Output");
Output(mol, apot, itf.GetBool("-atomtable"));
} else if (calcType.equals("solvent_only")) {
OEFloatArray apot = new OEFloatArray(mol.GetMaxAtomIdx());
zap.CalcAtomPotentials(apot);
OEFloatArray apot2 = new OEFloatArray(mol.GetMaxAtomIdx());
zap.SetOuterDielectric(zap.GetInnerDielectric());
zap.CalcAtomPotentials(apot2);
OEAtomBaseIter aiter = mol.GetAtoms();
float potdiff;
while (aiter.hasNext()) {
OEAtomBase atom = aiter.next();
potdiff = apot.getItem(atom.GetIdx()) - apot2.getItem(atom.GetIdx());
apot.setItem(atom.GetIdx(), potdiff);
}
Output(mol, apot, itf.GetBool("-atomtable"));
} else if (calcType.equals("remove_self")) {
OEFloatArray apot = new OEFloatArray(mol.GetMaxAtomIdx());
zap.CalcAtomPotentials(apot);
Output(mol, apot, itf.GetBool("-atomtable"));
} else if (calcType.equals("coulombic")) {
float x = oezaplib.OECoulombicSelfEnergy(mol, itf.GetFloat("-epsin"));
System.out.println("Coulombic Assembly Energy ");
System.out.println("Sum of {Potential * Charge over all atoms * 0.5} in kT = " + x);
}
zap.delete();
}

public static void main(String argv[]) {
ZapAtoms1 app = new ZapAtoms1();
OEInterface itf = new OEInterface();

URL fileURL = app.getClass().getResource("ZapAtoms1.txt");
try {
oechem.OEConfigureFromURL(itf, fileURL);
if (oechem.OECheckHelp(itf, argv)) {
return;
}
oechem.OEParseCommandLine(itf, argv);
app.Calc(itf);
} catch (java.io.IOException e) {
System.err.println("Unable to open interface file");
}
}
}


## Solvation Energies: PBSA¶

A principle use of PB is to calculate the energy stored in the exterior dielectric, for example the partial alignment of water dipoles. This corresponds to the difference between a calculation with uniform dielectric and one with a different external dielectric. In the examples for atom potentials this would be the sum of the solvent potentials at each atom, multiplied by the charges on that atom all multiplied by 0.5.

However, we know water also has an energy component due to hydrophobicity, which is typically estimated as a constant (approximately 10-25 calories per square Angstrom) multiplied by the accessible area of the molecule. This value is an open scientific question. We recommend using 10 for vacuum-water transfer energies and 25 for protein calculations, but ultimately your own scientific judgment should be used. These examples include an area calculation. Taken together these numbers are an approximation of the transfer energy from a low dielectric medium (alkane solvent, protein interior) into water.

The following examples use the OEArea object to calculate the accessible surface area of the molecule. The area is calculated using the same grid based Gaussians that ZAP uses. Therefore, it will not give the same results as triangle summation methods for calculating surface area, which are used in OESpicoli.

Listing 5: Calculating solvation energies

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oezap.*;

public class ZapSolv1 {

private static float epsin = 1.0f;

public static void main(String argv[]) {
if (argv.length != 1) {
System.err.println("usage: ZapSolv1 <molfile>");
System.exit(1);
}

OEZap zap = new OEZap();
zap.SetInnerDielectric(epsin);
zap.SetGridSpacing(0.5f);

OEArea area = new OEArea();

oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open for reading: " + argv[0]);
System.exit(1);
}
OEGraphMol mol = new OEGraphMol();
oechem.OEMMFFAtomTypes(mol);
oechem.OEMMFF94PartialCharges(mol);
zap.SetMolecule(mol);
float solv = zap.CalcSolvationEnergy();
float aval = area.GetArea(mol);
float coul = oezaplib.OECoulombicSelfEnergy(mol, epsin);
float total = 0.59f * solv + 0.025f * aval;
System.out.println("Title: " + mol.GetTitle());
System.out.println("  Solv (kcal)         : " + 0.59 * solv);
System.out.println("  Area (Ang^2)        : " + aval);
System.out.println("  Total (kcal)        : " + total);
System.out.println("  Int.Coulombic (kcal): " + 0.59 * coul);
System.out.println();
}
ifs.close();
area.delete();
zap.delete();
}
}


This next solvation example calculates the transfer energy from vacuum to water.

Listing 6: Calculating vacuum-water transfer energies

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oezap.*;

public class ZapTransfer {

private static float epsin = 1.0f;

public static void main(String argv[]) {
if (argv.length != 1) {
System.err.println("usage: ZapTransfer <molfile>");
System.exit(1);
}

OEZap zap = new OEZap();
zap.SetInnerDielectric(epsin);
zap.SetGridSpacing(0.5f);

OEArea area = new OEArea();

oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open for reading: " + argv[0]);
System.exit(1);
}
OEGraphMol mol = new OEGraphMol();
oechem.OEMMFFAtomTypes(mol);
oechem.OEMMFF94PartialCharges(mol);
zap.SetMolecule(mol);
float solv = zap.CalcSolvationEnergy();
float aval = area.GetArea(mol);
float total = 0.59f * solv + 0.010f * aval;
System.out.println("Title: " + mol.GetTitle());
System.out.println("Vacuum->Water(kcal)        : " + total);
System.out.println();
}
ifs.close();
area.delete();
zap.delete();
}
}


## Binding Energies¶

Binding energies and other binding related properties can be calculated using the OEBind class. The OEBind class serves two primary purposes: 1) to have a class in place for users to easily calculate binding related data, and 2) to show how binding related data may be calculated. OEBind is not particularly well-suited for extremely efficient calculations required by simulations. This is because some of the data available from OEBind may be considered uninteresting for the project and there is no need to spend time calculating it, or because OEBind calculates the unbound protein and ligand properties every time, which is unnecessary if the same protein and ligand appear in multiple calculations. The API section for OEBind is detailed with regard to implementation, so the user can see how to create their own class or set of function calls if needed.

There are two classes that store the results of a binding calculation, OEBindResults and OESimpleBindResults. OEBindResults is a superset of OESimpleBindResults. For an in-depth understanding of what is calculated, the electrostatics portion of the algorithm for the SimpleBind function is shown in the API section.

The following is a sample program for using the OEBind class that is provided in the distribution.

Listing 7: Bind example

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oezap.*;

public class ZapBind {

public static void main(String argv[]) {
if (argv.length != 2) {
System.err.println("usage: ZapBind <protein> <ligands>");
System.exit(1);
}

OEMol protein = new OEMol();
oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open for reading: " + argv[0]);
System.exit(1);
}
oechem.OEMMFFAtomTypes(protein);
oechem.OEMMFF94PartialCharges(protein);
System.err.println("protein: " + protein.GetTitle());
ifs.close();

OEBind bind = new OEBind();
bind.SetProtein(protein);
OEBindResults results = new OEBindResults();

OEMol ligand = new OEMol();
if (!ifs.open(argv[1])) {
System.err.println("Unable to open for reading: " + argv[1]);
System.exit(1);
}
ifs.SetConfTest(new OEIsomericConfTest());
oechem.OEMMFFAtomTypes(ligand);
oechem.OEMMFF94PartialCharges(ligand);
System.err.println("ligand: " + ligand.GetTitle());

for (OEConfBase conf : ligand.GetConfs()) {
bind.Bind(conf, results);
System.err.println(" conf# " + conf.GetIdx() + " be = "
+ results.GetBindingEnergy());
}
System.err.println();
}
results.delete();
bind.delete();
}
}


## Focussing¶

Focussing is a way to achieve the desired precision around a target (such as a ligand) while maintaining reasonable time and memory limits for the calculation. The target for focussing is set using the OEZap.SetFocusTarget method.

For a typical ZAP electrostatics calculation, a consistent grid spacing is used for the entire system, where the default value is 0.5 Angstroms but it may be set to a custom value using OEZap.SetGridSpacing. This method is entirely appropriate for certain calculations, such as solvation energy calculations for small molecules. For other types of calculations, such as a binding energy calculation for a protein and ligand, a consistent grid spacing may cause the calculation to be either prohibitively expensive or insufficiently precise around the binding area.

Focussing alleviates this problem by using a fine grid for the target volume, and coarser grids away from the target. The grid spacing setting for ZAP is applied to the target volume, and the grid spacing is doubled for each addition coarse grid surrounding the target. A quadratic interpolation is used for the grid intersections. The implementation of the bind uses the SetFocusTarget() method to set the ligand as the target for focussing.

The following example program computes the binding energy of a protein and ligand twice, once without focussing and once with the ligand as the focussing target. The values of the binding energy and the time it took to calculate them are displayed. For a focussed atom potential calculation, the full electrostatics for the protein and complex would each be computed with multiple electrostatics calculations. The first calculation would create the potential grid for the target volume with a grid spacing of 0.5 (assuming the default spacing is being used). An additional calculation with a grid spacing of 1.0 would be done on a larger volume volume, and then additional calculations with grid spacings of 2.0, 4.0, and so on would be done until the grid is large enough to contain the entire volume of the system.

Listing 8: Focussing example

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oezap.*;

public class ZapFocussing {
static {
oechem.OEThrow.SetStrict(true);
}

public static void CalcBindingEnergy(OEZap zap, OEGraphMol protein,
OEGraphMol ligand, OEGraphMol cmplx) {
OEStopwatch stopwatch = new OEStopwatch();
stopwatch.Start();

OEFloatArray ppot = new OEFloatArray(protein.GetMaxAtomIdx());
zap.SetMolecule(protein);
zap.CalcAtomPotentials(ppot);
double proteinEnergy = 0.0;
for (OEAtomBase atom : protein.GetAtoms()) {
proteinEnergy += ppot.getItem(atom.GetIdx()) * atom.GetPartialCharge();
}
proteinEnergy *= 0.5;

OEFloatArray lpot = new OEFloatArray(ligand.GetMaxAtomIdx());
zap.SetMolecule(ligand);
zap.CalcAtomPotentials(lpot);
double ligandEnergy = 0.0;
for (OEAtomBase atom : ligand.GetAtoms()) {
ligandEnergy += lpot.getItem(atom.GetIdx()) * atom.GetPartialCharge();
}
ligandEnergy *= 0.5;

OEFloatArray cpot = new OEFloatArray(cmplx.GetMaxAtomIdx());
zap.SetMolecule(cmplx);
zap.CalcAtomPotentials(cpot);
double cmplxEnergy = 0.0;
for (OEAtomBase atom : cmplx.GetAtoms()) {
cmplxEnergy += cpot.getItem(atom.GetIdx()) * atom.GetPartialCharge();
}
cmplxEnergy *= 0.5;

double energy = cmplxEnergy - ligandEnergy - proteinEnergy;
float time = stopwatch.Elapsed();

if (zap.IsFocusTargetSet()) {
System.out.println("Yes\t\t" + (float) energy + "\t" + time);
} else {
System.out.println("No\t\t" + (float) energy + "\t" + time);
}

}

public static void main(String argv[]) {
if (argv.length != 2) {
System.err.println("usage: ZapFocussing <protein> <ligand>");
System.exit(1);
}

oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open file for reading: " + argv[0]);
System.exit(1);
}
OEGraphMol protein = new OEGraphMol();

oechem.OEMMFFAtomTypes(protein);
oechem.OEMMFF94PartialCharges(protein);

if (!ifs.open(argv[1])) {
System.err.println("Unable to open file for reading: " + argv[1]);
System.exit(1);
}
OEGraphMol ligand = new OEGraphMol();

oechem.OEMMFFAtomTypes(ligand);
oechem.OEMMFF94PartialCharges(ligand);

OEGraphMol cmplx = new OEGraphMol(protein);

float epsin = 1.0f;
float spacing = 0.5f;
OEZap zap = new OEZap();
zap.SetInnerDielectric(epsin);
zap.SetGridSpacing(spacing);

System.out.println("\nBinding Energy and Wall Clock Time for " + protein.GetTitle() + " and " + ligand.GetTitle());
System.out.println("\nFocussed?\tEnergy(kT)\tTime(s)");

CalcBindingEnergy(zap, protein, ligand, cmplx);
zap.SetFocusTarget(ligand);
CalcBindingEnergy(zap, protein, ligand, cmplx);
zap.delete();
ifs.close();
}
}


The solvent forces acting on the atoms in a molecule may be calculated using the OEZap.CalcForces method. The components of the forces are set to a float array of length 3N, where N is the number of atoms. The components of the gradient are equal in magnitude to the force, but have the opposite sign.

Listing 9: Calculating solvation forces

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oezap.*;

public class ZapForces {
static {
oechem.OEThrow.SetStrict(true);
}

public static void main(String argv[]) {
if (argv.length != 1) {
System.err.println("usage: ZapForces <molfile>");
System.exit(1);
}

OEZap zap = new OEZap();
zap.SetInnerDielectric(1.0f);
zap.SetGridSpacing(0.5f);

oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open file for reading: " + argv[0]);
System.exit(1);
}
OEGraphMol mol = new OEGraphMol();
System.out.println(String.format("\nForce Components for %s, in kT/Angstrom",
mol.GetTitle()));
System.out.println("Index   Element   -dE/dx    -dE/dy    -dE/dz");

OEFloatArray forces = new OEFloatArray(mol.GetMaxAtomIdx() * 3);
oechem.OEMMFFAtomTypes(mol);
oechem.OEMMFF94PartialCharges(mol);
zap.SetMolecule(mol);
zap.CalcForces(forces);
for (OEAtomBase atom : mol.GetAtoms()) {
System.out.println(String.format(" %4d     %2s     %7.3f   %7.3f   %7.3f",
atom.GetIdx(),
oechem.OEGetAtomicSymbol(atom.GetAtomicNum()),
forces.getItem(atom.GetIdx()),
forces.getItem(atom.GetIdx() + 1),
forces.getItem(atom.GetIdx() + 2)));
}
}
zap.delete();
ifs.close();
}
}


## Electrostatic Similarity¶

Electrostatic similarity may be calculated using the OEET class. The following example program shows how to obtain the electrostatic Tanimoto between a reference molecule and a trial molecule. The electrostatic Tanimoto is affected by the partial charges of the molecules as well as the three-dimensional structure, including the tautomer state, spacial orientation, and conformation. In the example program shown below, MMFF charges are assigned to the molecules, but it is assumed that they have already been spatially aligned.

Listing 10: Calculating electrostatic tanimoto

/*******************************************************************************
* Copyright 2004-2013 OpenEye Scientific Software, Inc.
******************************************************************************/
package openeye.examples.oezap;

import openeye.oechem.*;
import openeye.oezap.*;

public class CalcET {

public static void main(String argv[]) {
if (argv.length != 2) {
System.err.println("usage: CalcET <reference> <fitfile>");
System.exit(1);
}

OEGraphMol refmol = new OEGraphMol();
oemolistream ifs = new oemolistream();
if (!ifs.open(argv[0])) {
System.err.println("Unable to open for reading: " + argv[0]);
System.exit(1);
}
oechem.OEMMFFAtomTypes(refmol);
oechem.OEMMFF94PartialCharges(refmol);
ifs.close();

OEET et = new OEET();
et.SetRefMol(refmol);

System.err.println("dielectric: " + et.GetDielectric());
System.err.println("salt conc : " + et.GetSaltConcentration());
System.err.println("join      : " + et.GetJoin());

OEGraphMol fitmol = new OEGraphMol();
if (!ifs.open(argv[1])) {
System.err.println("Unable to open for reading: " + argv[1]);
System.exit(1);
}