3.1 Molecular Volume Overlap

   

One of the simplest measures of molecular similarity is volume overlap. With OESpicoli, and the help of the OEGrid library, it becomes very easy to calculate the percentage of volume overlap. To do this, the volume of the reference molecule is calculated first. The fit molecule is then used to mask away the overlapping portions of the two molecules. The remaining volume is then calculated and divided by the volume of the reference molecule.

Listing 3.1 also illustrates the relationship between grids and surfaces. Notice how the reference molecule is first mapped onto a grid with the OEMakeMolecularGaussianGrid function. Grids are more efficient data structures to do the necessary masking operation, OEMaskGridByMolecule, to extract the common volume overlap. The two OESpicoli functions OEMakeSurfaceFromGrid and OESurfaceVolume are used to convert the grid to a surface and then calculate the enclosed volume of that surface.

 1 /*******************************************************************
 2   * Copyright 2006, OpenEye Scientific Software, Inc.
 3   *******************************************************************/
 4 #include "openeye.h"
 5
 6 #include "oeplatform.h"
 7 #include "oesystem.h"
 8 #include "oechem.h"
 9 #include "oegrid.h"
10 #include "oespicoli.h"
11
12 using namespace OEPlatform;
13 using namespace OESystem;
14 using namespace OEChem;
15 using namespace OESpicoli;
16
17 int main(int argc, char *argv[])
18 {
19   if (argc!=3)
20     OEThrow.Usage("%s <ref> <fit>", argv[0]);
21
22   oemolistream refifs(argv[1]);
23   OEGraphMol refmol;
24   OEReadMolecule(refifs, refmol);
25   OEAssignBondiVdWRadii(refmol);
26
27   oemolistream fitifs(argv[2]);
28   OEGraphMol fitmol;
29   OEReadMolecule(fitifs, fitmol);
30   OEAssignBondiVdWRadii(fitmol);
31
32   // Map the reference molecule onto a grid
33   OEScalarGrid grd;
34   OEMakeMolecularGaussianGrid(grd, refmol, 0.5f);
35
36   // Get the total volume of the reference molecule
37   OESurface refsrf;
38   OEMakeSurfaceFromGrid(refsrf, grd, 1.0f);
39   float totalv = OESurfaceVolume(refsrf);
40
41   // Mask out the fit molecule
42   OEMaskGridByMolecule(grd, fitmol);
43
44   // Find how much of the reference volume is remaining
45   OESurface fitsrf;
46   OEMakeSurfaceFromGrid(fitsrf, grd, 1.0f);
47   float remaining = OESurfaceVolume(fitsrf);
48
49   oeout << "Percent overlap: " << (1.0f - (remaining/totalv)) * 100.0f << oeendl;
50
51   return 0;
52 }

Listing:3.1 overlap.cpp

Caution: this program expects the reference and fit input molecules to have already been aligned to each other. Alignment can be done by OpenEye's shape technology in ROCS and the OEShape toolkit.