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.
1 #!/usr/bin/env python
2 #############################################################################
3 # Copyright (C) 2006, 2007, 2008 OpenEye Scientific Software, Inc.
4 #############################################################################
5 ### zap_grid1.py
6 #############################################################################
7
8 import os, sys
9 from openeye.oechem import *
10 from openeye.oegrid import *
11 from openeye.oezap import *
12
13 def main(argv = [__name__]):
14 if len(argv) != 2:
15 OEThrow.Usage("%s <molfile>" % argv[0])
16
17 ifs = oemolistream()
18 if not ifs.open(argv[1]):
19 OEThrow.Fatal("Unable to open %s for reading" % argv[1])
20 mol = OEGraphMol()
21 OEReadMolecule(ifs, mol)
22 OEAssignBondiVdWRadii(mol)
23 OEMMFFAtomTypes(mol)
24 OEMMFF94PartialCharges(mol)
25
26 epsin = 1.0
27 zap = OEZap()
28 zap.SetInnerDielectric(epsin)
29 zap.SetMolecule(mol)
30
31 grid = OEScalarGrid()
32 if zap.CalcPotentialGrid(grid):
33 OEWriteGrid("zap.grd", grid)
34
35
36 if __name__ == "__main__":
37 sys.exit(main(sys.argv))
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.
1 #!/usr/bin/env python
2 #############################################################################
3 # Copyright (C) 2006, 2008 OpenEye Scientific Software, Inc.
4 #############################################################################
5 ### zap_grid2.py
6 #############################################################################
7
8 import os, sys
9 from openeye.oechem import *
10 from openeye.oegrid import *
11 from openeye.oezap import *
12
13 def main(argv = [__name__]):
14 itf = OEInterface()
15 if not SetupInterface(argv, itf):
16 return 1
17
18 zap = OEZap()
19 zap.SetInnerDielectric(itf.GetFloat("-epsin"))
20 zap.SetOuterDielectric(itf.GetFloat("-epsout"))
21 zap.SetGridSpacing(itf.GetFloat("-grid_spacing"))
22 zap.SetBoundarySpacing(itf.GetFloat("-buffer"))
23
24 mol = OEGraphMol()
25 ifs = oemolistream()
26 if not ifs.open(itf.GetString("-in")):
27 OEThrow.Fatal("Unable to open %s for reading" % itf.GetString("-in"))
28 OEReadMolecule(ifs,mol)
29 OEAssignBondiVdWRadii(mol)
30 OEMMFFAtomTypes(mol)
31 OEMMFF94PartialCharges(mol)
32
33 zap.SetMolecule(mol)
34
35 grid = OEScalarGrid()
36 if zap.CalcPotentialGrid(grid):
37 if itf.GetBool("-mask"):
38 OEMaskGridByMolecule(grid, mol)
39 OEWriteGrid(itf.GetString("-out"), grid)
40 return 0
41
42 InterfaceData = """
43 #zap_grid2 interface definition
44
45 !PARAMETER -in
46 !TYPE string
47 !BRIEF Input molecule file
48 !REQUIRED true
49 !END
50
51 !PARAMETER -out
52 !TYPE string
53 !BRIEF Output grid file
54 !REQUIRED true
55 !END
56
57 !PARAMETER -epsin
58 !TYPE float
59 !BRIEF Inner dielectric
60 !DEFAULT 1.0
61 !LEGAL_RANGE 0.0 100.0
62 !END
63
64 !PARAMETER -epsout
65 !TYPE float
66 !BRIEF Outer dielectric
67 !DEFAULT 80.0
68 !LEGAL_RANGE 0.0 100.0
69 !END
70
71 !PARAMETER -grid_spacing
72 !TYPE float
73 !DEFAULT 0.5
74 !BRIEF Spacing between grid points (Angstroms)
75 !LEGAL_RANGE 0.1 2.0
76 !END
77
78 !PARAMETER -buffer
79 !TYPE float
80 !DEFAULT 2.0
81 !BRIEF Extra buffer outside extents of molecule.
82 !LEGAL_RANGE 0.1 10.0
83 !END
84
85 !PARAMETER -mask
86 !TYPE bool
87 !DEFAULT false
88 !BRIEF Mask potential grid by the molecule
89 !END
90 """
91
92 def SetupInterface(argv, itf):
93 OEConfigure(itf, InterfaceData)
94 if OECheckHelp(itf, argv):
95 return False
96 if not OEParseCommandLine(itf, argv):
97 return False
98 if not OEIsReadable(OEGetFileType(OEGetFileExtension(itf.GetString("-in")))):
99 OEThrow.Warning("%s is not a readable input file" % itf.GetString("-in"))
100 return False
101 if not OEIsWriteableGrid(OEGetGridFileType(OEGetFileExtension(itf.GetString("-out")))):
102 OEThrow.Warning("%s is not a writable grid file" % itf.GetString("-out"));
103 return False
104 return True
105
106 if __name__ == "__main__":
107 sys.exit(main(sys.argv))
Here we show how to calculate a difference-map, that is to say the potential difference between a standard, two dielectric, calculation and 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.
1 #!/usr/bin/env python
2 #############################################################################
3 # Copyright (C) 2006, 2007, 2008 OpenEye Scientific Software, Inc.
4 #############################################################################
5 ### zap_grid3.py
6 #############################################################################
7 import os, sys
8 from openeye.oechem import *
9 from openeye.oegrid import *
10 from openeye.oezap import *
11
12 def main(argv = [__name__]):
13 if len(argv) != 2:
14 OEThrow.Usage("%s <molfile>" % argv[0])
15
16 ifs = oemolistream()
17 if not ifs.open(argv[1]):
18 OEThrow.Fatal("Unable to open %s for reading" % argv[1])
19 mol = OEGraphMol()
20
21 OEReadMolecule(ifs, mol)
22 OEAssignBondiVdWRadii(mol)
23 OEMMFFAtomTypes(mol)
24 OEMMFF94PartialCharges(mol)
25
26 zap = OEZap()
27 zap.SetInnerDielectric(1.0)
28 zap.SetMolecule(mol)
29
30 # calculate standard 2-dielectric grid
31 grid1 = OEScalarGrid()
32 zap.CalcPotentialGrid(grid1)
33
34 # calculate grid with single dielectric
35 grid2 = OEScalarGrid()
36 zap.SetOuterDielectric(zap.GetInnerDielectric())
37 zap.CalcPotentialGrid(grid2)
38
39 # take the difference
40 OESubtractScalarGrid(grid1, grid2)
41
42 # mask out everything outside the molecule
43 OEMaskGridByMolecule(grid1, mol, OEGridMaskType_GaussianMinus)
44
45 OEWriteGrid("zap_diff.grd", grid1)
46
47
48 if __name__ == "__main__":
49 sys.exit(main(sys.argv))