def main(argv=[__name__]): itf = oechem.OEInterface() if not SetupInterface(argv, itf): return 1 zap = oezap.OEZap() zap.SetInnerDielectric(itf.GetFloat("-epsin")) zap.SetOuterDielectric(itf.GetFloat("-epsout")) zap.SetGridSpacing(itf.GetFloat("-grid_spacing")) zap.SetBoundarySpacing(itf.GetFloat("-buffer")) mol = oechem.OEGraphMol() ifs = oechem.oemolistream() if not ifs.open(itf.GetString("-in")): oechem.OEThrow.Fatal("Unable to open %s for reading" % itf.GetString("-in")) oechem.OEReadMolecule(ifs, mol) oechem.OEAssignBondiVdWRadii(mol) oechem.OEMMFFAtomTypes(mol) oechem.OEMMFF94PartialCharges(mol) zap.SetMolecule(mol) grid = oegrid.OEScalarGrid() if zap.CalcPotentialGrid(grid): if itf.GetBool("-mask"): oegrid.OEMaskGridByMolecule(grid, mol) oegrid.OEWriteGrid(itf.GetString("-out"), grid) return 0
def main(argv=[__name__]): if len(argv) != 2: oechem.OEThrow.Usage("%s <molfile>" % argv[0]) ifs = oechem.oemolistream() if not ifs.open(argv[1]): oechem.OEThrow.Fatal("Unable to open %s for reading" % argv[1]) mol = oechem.OEGraphMol() oechem.OEReadMolecule(ifs, mol) oechem.OEAssignBondiVdWRadii(mol) oechem.OEMMFFAtomTypes(mol) oechem.OEMMFF94PartialCharges(mol) zap = oezap.OEZap() zap.SetInnerDielectric(1.0) zap.SetGridSpacing(0.5) zap.SetMolecule(mol) # calculate standard 2-dielectric grid grid1 = oegrid.OEScalarGrid() zap.CalcPotentialGrid(grid1) # calculate grid with single dielectric grid2 = oegrid.OEScalarGrid() zap.SetOuterDielectric(zap.GetInnerDielectric()) zap.CalcPotentialGrid(grid2) # take the difference oegrid.OESubtractScalarGrid(grid1, grid2) # mask out everything outside the molecule oegrid.OEMaskGridByMolecule(grid1, mol, oegrid.OEGridMaskType_GaussianMinus) oegrid.OEWriteGrid("zap_diff.grd", grid1)
def main(argv=[__name__]): if len(argv) != 2: oechem.OEThrow.Usage("%s <molfile>" % argv[0]) ifs = oechem.oemolistream() if not ifs.open(argv[1]): oechem.OEThrow.Fatal("Unable to open %s for reading" % argv[1]) mol = oechem.OEGraphMol() oechem.OEReadMolecule(ifs, mol) oechem.OEAssignBondiVdWRadii(mol) oechem.OEMMFFAtomTypes(mol) oechem.OEMMFF94PartialCharges(mol) epsin = 1.0 zap = oezap.OEZap() zap.SetInnerDielectric(epsin) zap.SetMolecule(mol) grid = oegrid.OEScalarGrid() if zap.CalcPotentialGrid(grid): oegrid.OEWriteGrid("zap.grd", grid)
def main(args): if len(args) != 3: oechem.OEThrow.Usage("%s <ref> <fit>" % args[0]) refifs = oechem.oemolistream() if not refifs.open(args[1]): oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1]) refmol = oechem.OEGraphMol() oechem.OEReadMolecule(refifs, refmol) oechem.OEAssignBondiVdWRadii(refmol) fitifs = oechem.oemolistream() if not fitifs.open(args[2]): oechem.OEThrow.Fatal("Unable to open %s for reading" % args[2]) fitmol = oechem.OEGraphMol() oechem.OEReadMolecule(fitifs, fitmol) oechem.OEAssignBondiVdWRadii(fitmol) # Map the reference molecule onto a grid grd = oegrid.OEScalarGrid() oegrid.OEMakeMolecularGaussianGrid(grd, refmol, 0.5) # Get the total volume of the reference molecule refsrf = oespicoli.OESurface() oespicoli.OEMakeSurfaceFromGrid(refsrf, grd, 1.0) totalv = oespicoli.OESurfaceVolume(refsrf) # Mask out the fit molecule oegrid.OEMaskGridByMolecule(grd, fitmol) # Find how much of the reference volume is remaining fitsrf = oespicoli.OESurface() oespicoli.OEMakeSurfaceFromGrid(fitsrf, grd, 1.0) remaining = oespicoli.OESurfaceVolume(fitsrf) print("Percent overlap: %f" % ((1 - remaining / totalv) * 100)) return 0
def main(args): if len(args) != 4: oechem.OEThrow.Usage("%s <protein> <ligand> <surface>" % args[0]) prtfs = oechem.oemolistream(args[1]) prt = oechem.OEGraphMol() oechem.OEReadMolecule(prtfs, prt) oechem.OESuppressHydrogens(prt) oechem.OEAssignBondiVdWRadii(prt) ligfs = oechem.oemolistream(args[2]) lig = oechem.OEGraphMol() oechem.OEReadMolecule(ligfs, lig) oechem.OESuppressHydrogens(lig) oechem.OEAssignBondiVdWRadii(lig) grid = oegrid.OEScalarGrid() oespicoli.OEMakeVoidVolume(prt, lig, grid, 0.5) surf = oespicoli.OESurface() oespicoli.OEMakeSurfaceFromGrid(surf, grid, 0.5) oespicoli.OEWriteSurface(args[3], surf) return 0
def nmax_waters(protein, ligand, cutoff): # Grid Spacing in A spacing = 0.5 complex = oechem.OEMol(protein) oechem.OEAddMols(complex, ligand) surf = oespicoli.OESurface() oespicoli.OEMakeMolecularSurface(surf, complex, spacing) # oespicoli.OEWriteSurface("test_surf.oesrf", surf) center = oechem.OEFloatArray(3) extents = oechem.OEFloatArray(3) oechem.OEGetCenterAndExtents(ligand, center, extents) extents = oechem.OEFloatArray( [max(extents) * 2, max(extents) * 2, max(extents) * 2]) grid_reference = oegrid.OEScalarGrid() oegrid.OEMakeGridFromCenterAndExtents(grid_reference, center, extents, spacing) grid_spicoli = oegrid.OEScalarGrid() oespicoli.OEMakeBitGridFromSurface(grid_spicoli, surf) for iz in range(grid_reference.GetZDim()): for iy in range(grid_reference.GetYDim()): for ix in range(grid_reference.GetXDim()): x = grid_reference.GetX(ix) y = grid_reference.GetY(iy) z = grid_reference.GetZ(iz) ix_spicoli = grid_spicoli.GetXIdx(x) iy_spicoli = grid_spicoli.GetYIdx(y) iz_spicoli = grid_spicoli.GetZIdx(z) value = grid_spicoli.GetValue(ix_spicoli, iy_spicoli, iz_spicoli) grid_reference.SetValue(ix, iy, iz, value) # Invert Grid for iz in range(grid_reference.GetZDim()): for iy in range(grid_reference.GetYDim()): for ix in range(grid_reference.GetXDim()): # print("ix = {} iy = {} iz = {} value = {}".format(ix, iy, iz , grid.GetValue(ix, iy, iz))) if grid_reference.GetValue(ix, iy, iz) == 0.0: grid_reference.SetValue(ix, iy, iz, 1.0) else: grid_reference.SetValue(ix, iy, iz, 0.0) ligand_coords = ligand.GetCoords() for iz in range(grid_reference.GetZDim()): for iy in range(grid_reference.GetYDim()): for ix in range(grid_reference.GetXDim()): if grid_reference.GetValue(ix, iy, iz) == 1.0: x = grid_reference.GetX(ix) y = grid_reference.GetY(iy) z = grid_reference.GetZ(iz) min_sq = cutoff * cutoff for coord in ligand_coords.values(): distsq = dist2(coord, (x, y, z)) if distsq < min_sq: min_sq = distsq break if min_sq == cutoff * cutoff: grid_reference.SetValue(ix, iy, iz, 0.0) protein_coords = protein.GetCoords() for iz in range(grid_reference.GetZDim()): for iy in range(grid_reference.GetYDim()): for ix in range(grid_reference.GetXDim()): if grid_reference.GetValue(ix, iy, iz) == 1.0: x = grid_reference.GetX(ix) y = grid_reference.GetY(iy) z = grid_reference.GetZ(iz) min_sq = cutoff * cutoff for coord in protein_coords.values(): distsq = dist2(coord, (x, y, z)) if distsq < min_sq: min_sq = distsq break if min_sq == cutoff * cutoff: grid_reference.SetValue(ix, iy, iz, 0.0) # oegrid.OEWriteGrid("protein_ligand.grd", grid_reference) count = 0 for iz in range(grid_reference.GetZDim()): for iy in range(grid_reference.GetYDim()): for ix in range(grid_reference.GetXDim()): if grid_reference.GetValue(ix, iy, iz) == 1.0: count += 1 # Calculate Volume from count in Angstrom vcount = (spacing**3) * count # Number of water molecule in vcount volume nwaters = int(0.034 * vcount) return nwaters # def select_nmax_waters()
# subject to these terms. OpenEye claims no rights to Customer's # modifications. Modification of Sample Code is at Customer's sole and # exclusive risk. Sample Code may require Customer to have a then # current license or subscription to the applicable OpenEye offering. # THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED. OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT # NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be # liable for any damages or liability in connection with the Sample Code # or its use. # @ <SNIPPET> import sys from openeye import oechem from openeye import oegrid ifs = oechem.oemolistream(sys.argv[1]) mol = oechem.OEGraphMol() oechem.OEReadMolecule(ifs, mol) grid = oegrid.OEScalarGrid() oegrid.OEMakeMolecularGaussianGrid(grid, mol, 0.5) # @ <SNIPPET-SquarePoints> for i in range(grid.GetSize()): val = grid.GetValue(i) grid.SetValue(i, val * val) # @ </SNIPPET-SquarePoints> # @ </SNIPPET>
# subject to these terms. OpenEye claims no rights to Customer's # modifications. Modification of Sample Code is at Customer's sole and # exclusive risk. Sample Code may require Customer to have a then # current license or subscription to the applicable OpenEye offering. # THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED. OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT # NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be # liable for any damages or liability in connection with the Sample Code # or its use. # @ <SNIPPET> from __future__ import print_function from openeye import oegrid grid = oegrid.OEScalarGrid(2, 2, 2, 0.0, 0.0, 0.0, 0.5) grid.SetTitle("Simple Grid") print("Title:", grid.GetTitle()) print("Mid: %12.6f %12.6f %12.6f" % grid.GetMid()) print("Dim: %6d %6d %6d" % grid.GetDim()) print("Spacing: %12.6f" % grid.GetSpacing()) print("Values:") for iz in range(grid.GetZDim()): for iy in range(grid.GetYDim()): for ix in range(grid.GetXDim()): print("%-12.6e" % grid.GetValue(ix, iy, iz))
def main(argv=[__name__]): itf = oechem.OEInterface(InterfaceData, argv) NPolyMax = itf.GetInt("-NPolyMax") gridspacing = itf.GetFloat("-gridspacing") ifname = itf.GetString("-inputfile") ofname = itf.GetString("-outputgrid")\ ifs = oechem.oemolistream() if (not ifs.open(ifname)): oechem.OEThrow.Fatal("Unable to open %s for reading" % ifname) if (not ofname.endswith(".grd")): oechem.OEThrow.Fatal("Output grid file extension hast to be '.grd' ") mol = oechem.OEMol() if (not oechem.OEReadMolecule(ifs, mol)): oechem.OEThrow.Fatal("Unable to read molecule in %s" % ifname) prep = oeshape.OEOverlapPrep() prep.SetAssignColor(False) prep.Prep(mol) transfm = oechem.OETrans() oeshape.OEOrientByMomentsOfInertia(mol, transfm) hermiteoptions = oeshape.OEHermiteOptions() hermiteoptions.SetNPolyMax(NPolyMax) hermiteoptions.SetUseOptimalLambdas(True) hermite = oeshape.OEHermite(hermiteoptions) if (not hermite.Setup(mol)): oechem.OEThrow.Fatal( "Was not able to Setup the molecule for the OEHermite class.") hopts = hermite.GetOptions() print("Best lambdas found X=" + str(hopts.GetLambdaX()) + " Y=" + str(hopts.GetLambdaY()) + " Z=" + str(hopts.GetLambdaZ())) print("Hermite self-overlap=", hermite.GetSelfOverlap()) basis_size = int((NPolyMax + 1) * (NPolyMax + 2) * (NPolyMax + 3) / 6) coeffs = oechem.OEDoubleVector(basis_size) hermite.GetCoefficients(coeffs) NPolyMaxstring = str(NPolyMax) print("Hermite coefficients f_{l,m,n} in the following order l = 0..." + NPolyMaxstring + ", m = 0..." + NPolyMaxstring + "-l, n = " + NPolyMaxstring + "-l-m :") for x in coeffs: print(str(x) + " "), grid = oegrid.OEScalarGrid() hermite.CreateGrid(grid, gridspacing) if (not oegrid.OEWriteGrid(ofname, grid)): oechem.OEThrow.Fatal("Unable to write grid file") return 0
#!/usr/bin/env python # (C) 2017 OpenEye Scientific Software Inc. All rights reserved. # # TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is # provided to current licensees or subscribers of OpenEye products or # SaaS offerings (each a "Customer"). # Customer is hereby permitted to use, copy, and modify the Sample Code, # subject to these terms. OpenEye claims no rights to Customer's # modifications. Modification of Sample Code is at Customer's sole and # exclusive risk. Sample Code may require Customer to have a then # current license or subscription to the applicable OpenEye offering. # THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED. OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT # NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be # liable for any damages or liability in connection with the Sample Code # or its use. # @ <SNIPPET> from openeye import oegrid grid = oegrid.OEScalarGrid(64, 64, 64, 0.0, 0.0, 0.0, 0.5) # @ </SNIPPET>