コード例 #1
0
def Draw2DSurfacePartialCharge(image, mol):

    oedepict.OEPrepareDepiction(mol)

    oechem.OEMMFFAtomTypes(mol)
    oechem.OEMMFF94PartialCharges(mol)

    opts = oedepict.OE2DMolDisplayOptions(image.GetWidth(), image.GetHeight(),
                                          oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
    opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(mol, opts))

    coloranion = oechem.OEColorStop(-1.0, oechem.OEColor(oechem.OEDarkRed))
    colorcation = oechem.OEColorStop(+1.0, oechem.OEColor(oechem.OEDarkBlue))
    colorg = oechem.OELinearColorGradient(coloranion, colorcation)
    colorg.AddStop(oechem.OEColorStop(0.0, oechem.OEColor(oechem.OEWhite)))

    arcfxn = AtomPartialChargeArcFxn(colorg)

    for atom in mol.GetAtoms():
        oegrapheme.OESetSurfaceArcFxn(mol, atom, arcfxn)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    oegrapheme.OEDraw2DSurface(disp)
    oedepict.OERenderMolecule(image, disp)
コード例 #2
0
def Draw2DSurface(image, mol):

    oedepict.OEPrepareDepiction(mol)

    opts = oedepict.OE2DMolDisplayOptions(image.GetWidth(), image.GetHeight(),
                                          oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
    opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(mol, opts))

    arcfxn = AtomColorArcFxn()
    for atom in mol.GetAtoms():
        oegrapheme.OESetSurfaceArcFxn(mol, atom, arcfxn)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    oegrapheme.OEDraw2DSurface(disp)
    oedepict.OERenderMolecule(image, disp)
コード例 #3
0
def Draw2DSurfaces(image, mol):

    oedepict.OEPrepareDepiction(mol)

    opts = oedepict.OE2DMolDisplayOptions(image.GetWidth(), image.GetHeight(),
                                          oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
    opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(mol, opts, 1.50))

    disp = oedepict.OE2DMolDisplay(mol, opts)

    Draw2DSurface(disp, oechem.OEHasAtomicNum(oechem.OEElemNo_C), 1.00,
                  oechem.OEBlack)
    Draw2DSurface(disp, oechem.OEHasAtomicNum(oechem.OEElemNo_N), 1.25,
                  oechem.OEDarkBlue)
    Draw2DSurface(disp, oechem.OEHasAtomicNum(oechem.OEElemNo_O), 1.50,
                  oechem.OEDarkRed)

    oedepict.OERenderMolecule(image, disp)
コード例 #4
0
def DrawSurfaces(image, mol):

    oechem.OEAssignCovalentRadii(mol)
    minradius = oechem.OEGetCovalentRadius(oechem.OEElemNo_H)

    radiusScales = oechem.OEDoubleVector(mol.GetMaxAtomIdx(), 0.0)
    maxrscale = float("-inf")

    for atom in mol.GetAtoms():
        rscale = (atom.GetRadius() -
                  minradius) + oegrapheme.OESurfaceArcScale_Minimum
        radiusScales[atom.GetIdx()] = rscale
        maxrscale = max(maxrscale, rscale)

    opts = oedepict.OE2DMolDisplayOptions(image.GetWidth(), image.GetHeight(),
                                          oedepict.OEScale_AutoScale)
    opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
    opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(mol, opts, maxrscale))

    disp = oedepict.OE2DMolDisplay(mol, opts)

    layer = disp.GetLayer(oedepict.OELayerPosition_Below)

    penA = oedepict.OEPen(oechem.OELightGrey, oechem.OELightGrey,
                          oedepict.OEFill_Off, 2.0,
                          oedepict.OEStipple_ShortDash)
    arcfxnA = oegrapheme.OEDefaultArcFxn(penA)

    for arc in oegrapheme.OEGet2DSurfaceArcs(
            disp, oegrapheme.OESurfaceArcScale_Minimum):
        arcfxnA(layer, arc)

    penB = oedepict.OEPen(oechem.OEGrey, oechem.OEGrey, oedepict.OEFill_Off,
                          2.0)
    arcfxnB = oegrapheme.OEDefaultArcFxn(penB)

    for arc in oegrapheme.OEGet2DSurfaceArcs(disp, radiusScales):
        arcfxnB(layer, arc)

    oedepict.OERenderMolecule(image, disp)
コード例 #5
0
    if not oechem.OEReadMolecule(ifs, mol):
        oechem.OEThrow.Fatal("Unable to read molecule in %s" % filename)

    oechem.OEAssignBondiVdWRadii(mol)
    oechem.OESuppressHydrogens(mol)

    return mol


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

receptor = ImportMolecule(sys.argv[1])
ligand = ImportMolecule(sys.argv[2])

oegrapheme.OEAddComplexSurfaceArcs(ligand, receptor)

oegrapheme.OEPrepareDepictionFrom3D(ligand)

width, height = 450, 350
opts = oedepict.OE2DMolDisplayOptions(width, height,
                                      oedepict.OEScale_AutoScale)
opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(ligand, opts))

disp = oedepict.OE2DMolDisplay(ligand, opts)
oegrapheme.OEDraw2DSurface(disp)

oedepict.OERenderMolecule("DrawComplexSurface.png", disp)
# @ </SNIPPET-DRAW-COMPLEX-SURFACE>
oedepict.OERenderMolecule("DrawComplexSurface.pdf", disp)
コード例 #6
0
def main(argv=[__name__]):

    itf = oechem.OEInterface()
    oechem.OEConfigure(itf, InterfaceData)
    oedepict.OEConfigureImageWidth(itf, 600.0)
    oedepict.OEConfigureImageHeight(itf, 600.0)
    oedepict.OEConfigure2DMolDisplayOptions(itf, oedepict.OE2DMolDisplaySetup_AromaticStyle)
    oechem.OEConfigureSplitMolComplexOptions(itf, oechem.OESplitMolComplexSetup_LigName)

    if not oechem.OEParseCommandLine(itf, argv):
        return 1

    iname = itf.GetString("-complex")
    oname = itf.GetString("-out")

    ifs = oechem.oemolistream()
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    ext = oechem.OEGetFileExtension(oname)
    if not oedepict.OEIsRegisteredImageFile(ext):
        oechem.OEThrow.Fatal("Unknown image type!")

    ofs = oechem.oeofstream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    complexmol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(ifs, complexmol):
        oechem.OEThrow.Fatal("Unable to read molecule from %s" % iname)

    if not oechem.OEHasResidues(complexmol):
        oechem.OEPerceiveResidues(complexmol, oechem.OEPreserveResInfo_All)

    # Separate ligand and protein

    sopts = oechem.OESplitMolComplexOptions()
    oechem.OESetupSplitMolComplexOptions(sopts, itf)

    ligand = oechem.OEGraphMol()
    protein = oechem.OEGraphMol()
    water = oechem.OEGraphMol()
    other = oechem.OEGraphMol()

    oechem.OESplitMolComplex(ligand, protein, water, other, complexmol, sopts)

    if ligand.NumAtoms() == 0:
        oechem.OEThrow.Fatal("Cannot separate complex!")

    # Calculate average BFactor of the whole complex

    avgbfactor = GetAverageBFactor(complexmol)

    # Calculate minimum and maximum BFactor of the ligand and its environment

    minbfactor, maxbfactor = GetMinAndMaxBFactor(ligand, protein)

    # Attach to each ligand atom the average BFactor of the nearby protein atoms

    stag = "avg residue BFfactor"
    itag = oechem.OEGetTag(stag)
    SetAverageBFactorOfNearbyProteinAtoms(ligand, protein, itag)

    oechem.OEThrow.Info("Average BFactor of the complex = %+.3f" % avgbfactor)
    oechem.OEThrow.Info("Minimum BFactor of the ligand and its environment = %+.3f" % minbfactor)
    oechem.OEThrow.Info("Maximum BFactor of the ligand and its environment = %+.3f" % maxbfactor)

    # Create image

    imagewidth, imageheight = oedepict.OEGetImageWidth(itf), oedepict.OEGetImageHeight(itf)
    image = oedepict.OEImage(imagewidth, imageheight)

    mframe = oedepict.OEImageFrame(image, imagewidth,
                                   imageheight * 0.90, oedepict.OE2DPoint(0.0, 0.0))
    lframe = oedepict.OEImageFrame(image, imagewidth, imageheight * 0.10,
                                   oedepict.OE2DPoint(0.0, imageheight * 0.90))

    opts = oedepict.OE2DMolDisplayOptions(mframe.GetWidth(), mframe.GetHeight(),
                                          oedepict.OEScale_AutoScale)
    oedepict.OESetup2DMolDisplayOptions(opts, itf)
    opts.SetAtomColorStyle(oedepict.OEAtomColorStyle_WhiteMonochrome)

    # Create BFactor color gradient

    colorg = oechem.OELinearColorGradient()
    colorg.AddStop(oechem.OEColorStop(0.0, oechem.OEDarkBlue))
    colorg.AddStop(oechem.OEColorStop(10.0, oechem.OELightBlue))
    colorg.AddStop(oechem.OEColorStop(25.0, oechem.OEYellowTint))
    colorg.AddStop(oechem.OEColorStop(50.0, oechem.OERed))
    colorg.AddStop(oechem.OEColorStop(100.0, oechem.OEDarkRose))

    # Prepare ligand for depiction

    oegrapheme.OEPrepareDepictionFrom3D(ligand)
    arcfxn = BFactorArcFxn(colorg, itag)
    for atom in ligand.GetAtoms():
        oegrapheme.OESetSurfaceArcFxn(ligand, atom, arcfxn)
    opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(ligand, opts))

    # Render ligand and visualize BFactor

    disp = oedepict.OE2DMolDisplay(ligand, opts)
    colorbfactor = ColorLigandAtomByBFactor(colorg)
    oegrapheme.OEAddGlyph(disp, colorbfactor, oechem.OEIsTrueAtom())
    oegrapheme.OEDraw2DSurface(disp)
    oedepict.OERenderMolecule(mframe, disp)

    # Draw color gradient

    opts = oegrapheme.OEColorGradientDisplayOptions()
    opts.SetColorStopPrecision(1)
    opts.AddMarkedValue(avgbfactor)
    opts.SetBoxRange(minbfactor, maxbfactor)

    oegrapheme.OEDrawColorGradient(lframe, colorg, opts)

    oedepict.OEWriteImage(oname, image)

    return 0
コード例 #7
0
# or its use.

from openeye import oechem
from openeye import oedepict
from openeye import oegrapheme

mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "OC(=O)c1cnc(c(Cl)c1)-c2ccccc2")
oedepict.OEPrepareDepiction(mol)

imagewidth, imageheight = 350, 250

# @ <SNIPPET-DRAW-2D-SURFACE>
opts = oedepict.OE2DMolDisplayOptions(imagewidth, imageheight,
                                      oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Hidden)
opts.SetScale(oegrapheme.OEGetMoleculeSurfaceScale(mol, opts))

arcfxn = oegrapheme.OEEyelashArcFxn(
    oedepict.OEPen(oechem.OEGrey, oechem.OEGrey))

for atom in mol.GetAtoms():
    oegrapheme.OESetSurfaceArcFxn(mol, atom, arcfxn)

disp = oedepict.OE2DMolDisplay(mol, opts)
oegrapheme.OEDraw2DSurface(disp)
# @ </SNIPPET-DRAW-2D-SURFACE>

oedepict.OERenderMolecule("Draw2DSurface.png", disp)
oedepict.OERenderMolecule("Draw2DSurface.pdf", disp)