OEGrid supports the following storage formats:
The ASCII format was developed by OpenEye to allow for easy integration with other software. The following is an example of the ASCII output:
Title: Example Grid Mid: 0.000000 0.000000 0.000000 Dim: 2 2 2 Spacing: 0.500000 Values: 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
Listing 2.8 is the code used to write the ASCII format out. It is provided here to leave no doubt as to how to inter-operate with the format.
ofs << "Title: " << grid.GetTitle() << oeendl;
char buffer[80];
sprintf(buffer, "Mid: %12.6f %12.6f %12.6f", grid.GetXMid(), grid.GetYMid(),
grid.GetZMid());
ofs << buffer << oeendl;
unsigned int xdim = grid.GetXDim();
unsigned int ydim = grid.GetYDim();
unsigned int zdim = grid.GetZDim();
sprintf(buffer, "Dim: %6d %6d %6d", xdim, ydim, zdim);
ofs << buffer << oeendl;
sprintf(buffer, "Spacing: %12.6f", grid.GetSpacing());
ofs << buffer << oeendl;
ofs << "Values:" << oeendl;
char numbuff[13];
for (unsigned int iz=0;iz<zdim;++iz)
for (unsigned int iy=0;iy<ydim;++iy)
for (unsigned int ix=0;ix<xdim;++ix)
{
sprintf(numbuff, "%-12.6e", grid.operator()(ix,iy,iz));
ofs << numbuff << oeendl;
}
To do this the binary writers inside OESystem need to be
initialized to handle grids. Listing 2.9
demonstrates how to properly attach surfaces to molecules.
oemolostream ofs;
if (!ofs.open(fname))
OEThrow.Fatal("Unable to open file: %s", fname);
OEInitGridHandlers(ofs);
OEGraphMol mol;
// Read a molecule into mol
OEScalarGrid grid;
OEMakeMolecularGaussianGrid(grid, mol, 1.0);
// Create a grid for a molecule
mol.SetData<OEScalarGrid>("grid", grid);
OEWriteMolecule(ofs, mol);