Beispiel #1
0
def main(args):
    if len(args) != 3:
        oechem.OEThrow.Usage("%s <protein> <ligand>" % args[0])

    pifs = oechem.oemolistream()
    if not pifs.open(args[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading protein." %
                             args[1])

    prot = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(pifs, prot):
        oechem.OEThrow.Fatal("Unable to read protein")

    oechem.OEAddExplicitHydrogens(prot)
    oechem.OEAssignBondiVdWRadii(prot)

    lifs = oechem.oemolistream()
    if not lifs.open(args[2]):
        oechem.OEThrow.Fatal("Unable to open %s for reading ligand." % args[2])

    lig = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(lifs, lig):
        oechem.OEThrow.Fatal("Unable to read ligand")

    oechem.OEAddExplicitHydrogens(lig)
    oechem.OEAssignBondiVdWRadii(lig)

    comp = oechem.OEGraphMol(prot)
    oechem.OEAddMols(comp, lig)

    compSurf = oespicoli.OESurface()
    oespicoli.OEMakeMolecularSurface(compSurf, comp)

    protSurf = oespicoli.OESurface()
    oespicoli.OEMakeMolecularSurface(protSurf, prot)

    ligSurf = oespicoli.OESurface()
    oespicoli.OEMakeMolecularSurface(ligSurf, lig)

    compVol = oespicoli.OESurfaceVolume(compSurf)
    protVol = oespicoli.OESurfaceVolume(protSurf)
    ligVol = oespicoli.OESurfaceVolume(ligSurf)
    oespicoli.OEWriteSurface("comp.oesrf", compSurf)
    oespicoli.OEWriteSurface("prot.oesrf", protSurf)
    oespicoli.OEWriteSurface("lig.oesrf", ligSurf)

    oechem.OEThrow.Info(
        "%s-%s: dV(C-P) = %.1f V(L) = %.1f V(C) = %.1f V(P) = %.1f" %
        (prot.GetTitle(), lig.GetTitle(), compVol - protVol, ligVol, compVol,
         protVol))

    return 0
def main(args):

    if len(args) != 4:
        oechem.OEThrow.Usage("%s <protein> <ligand> <surface>" % args[0])

    pfs = oechem.oemolistream(args[1])
    prot = oechem.OEGraphMol()
    oechem.OEReadMolecule(pfs, prot)
    oechem.OEAssignBondiVdWRadii(prot)

    lfs = oechem.oemolistream(args[2])
    lig = oechem.OEGraphMol()
    oechem.OEReadMolecule(lfs, lig)

    surf = oespicoli.OESurface()
    oespicoli.OEMakeMolecularSurface(surf, prot)

    oespicoli.OESurfaceToMoleculeDistance(surf, lig)

    # Mark the vertices to keep
    for i in range(surf.GetNumVertices()):
        if surf.GetDistanceElement(i) < MAX_DIST:
            surf.SetVertexCliqueElement(i, 1)

    # Crop to the binding site and output
    oespicoli.OESurfaceCropToClique(surf, 1)
    oespicoli.OEWriteSurface(args[3], surf)

    return 0
def main(args):

    if len(args) != 4:
        oechem.OEThrow.Usage("%s <protein> <ligand> <surface>" % args[0])

    pfs = oechem.oemolistream(args[1])
    prot = oechem.OEGraphMol()
    oechem.OEReadMolecule(pfs, prot)
    oechem.OEAssignBondiVdWRadii(prot)

    lfs = oechem.oemolistream(args[2])
    lig = oechem.OEGraphMol()
    oechem.OEReadMolecule(lfs, lig)

    surf = oespicoli.OESurface()
    oespicoli.OEMakeMolecularSurface(surf, prot)

    # Iterate through all the protein surface vertices
    for i in range(surf.GetNumVertices()):
        vert = surf.GetVertex(i)

        # Check the distance to each atom
        for atom in lig.GetAtoms():
            dist2 = GetDist2(lig.GetCoords(atom), vert)
            if dist2 < MAX_DIST * MAX_DIST:
                surf.SetVertexCliqueElement(i, 1)

    # Crop to the binding site and output
    oespicoli.OESurfaceCropToClique(surf, 1)
    oespicoli.OEWriteSurface(args[3], surf)

    return 0
Beispiel #4
0
def AverageSurfaceArea(mcmol):
    area = 0.0
    parea = 0.0
    for conf in mcmol.GetConfs():
        surf = oespicoli.OESurface()
        oespicoli.OEMakeMolecularSurface(surf, conf, 0.5)
        MakeCliques(surf, conf)
        area += oespicoli.OESurfaceArea(surf)
        parea += oespicoli.OESurfaceCliqueArea(surf, 1)
    area /= mcmol.NumConfs()
    parea /= mcmol.NumConfs()
    return area, parea
Beispiel #5
0
def main(args):
    if len(args) != 3:
        oechem.OEThrow.Usage("%s <protein> <surface>" % args[0])

    ifs = oechem.oemolistream()
    if not ifs.open(args[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1])

    mol = oechem.OEGraphMol()
    oechem.OEReadMolecule(ifs, mol)
    oechem.OEPerceiveResidues(mol)
    oechem.OEAssignBondiVdWRadii(mol)

    # Generate the molecular surface
    surf = oespicoli.OESurface()
    oespicoli.OEMakeMolecularSurface(surf, mol, 0.5)

    # Mark all the vertices associated with hydrophobic atoms
    for i in range(surf.GetNumVertices()):
        atom = mol.GetAtom(oechem.OEHasAtomIdx(surf.GetAtomsElement(i)))
        if (AtomInHydrophobicResidue(atom)):
            surf.SetVertexCliqueElement(i, 1)

    # Crop to only those triangles
    oespicoli.OESurfaceCropToClique(surf, 1)

    # nlqs is the number of different connected components
    nclqs = oespicoli.OEMakeConnectedSurfaceCliques(surf)

    # Find the largest component
    maxclq = 0
    maxarea = 0.0
    for i in range(nclqs):
        area = oespicoli.OESurfaceCliqueArea(surf, i+1)
        print("clique: %d  area: %f" % (i+1, area))
        if (area > maxarea):
            maxclq = i+1
            maxarea = area

    # Crop to it
    oespicoli.OESurfaceCropToClique(surf, maxclq)

    oespicoli.OEWriteSurface(args[2], surf)

    return 0
Beispiel #6
0
def main(args):
    if len(args) != 3:
        oechem.OEThrow.Usage("%s <molecules> <oebfile>" % args[0])

    ifs = oechem.oemolistream()
    if not ifs.open(args[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1])

    ofs = oechem.oemolostream()
    if not ofs.open(args[2]):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % args[2])

    for mol in ifs.GetOEGraphMols():
        oechem.OEAssignBondiVdWRadii(mol)

        surf = oespicoli.OESurface()
        oespicoli.OEMakeMolecularSurface(surf, mol, 0.5)
        ColorSurface(surf, mol)
        mol.SetData("psasurf", surf)

        oechem.OEWriteMolecule(ofs, mol)

    return 0
from openeye import oespicoli

if len(sys.argv) != 2:
    oechem.OEThrow.Usage("%s <input>" % sys.argv[0])

ims = oechem.oemolistream()
if not ims.open(sys.argv[1]):
    oechem.OEThrow.Fatal("Unable to open %s" % sys.argv[1])

mol = oechem.OEGraphMol()
if not oechem.OEReadMolecule(ims, mol):
    oechem.OEThrow.Fatal("Unable to read a molecule")
oechem.OEAssignBondiVdWRadii(mol)

# @ <SNIPPET-SetData>
surf = oespicoli.OESurface()
oespicoli.OEMakeMolecularSurface(surf, mol)
mol.SetData("surface", surf)

ofs = oechem.oemolostream("foo.oeb")
oechem.OEWriteMolecule(ofs, mol)
# @ </SNIPPET-SetData>
ofs.close()

# @ <SNIPPET-GetData>
ifs = oechem.oemolistream("foo.oeb")
oechem.OEReadMolecule(ifs, mol)

msrf = mol.GetData("surface")
# @ </SNIPPET-GetData>
Beispiel #8
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()