def Draw2DSurface(disp, atompred, radius, color): penA = oedepict.OEPen(color, color, oedepict.OEFill_Off, 2.0) arcfxnA = oegrapheme.OEDefaultArcFxn(penA) penB = oedepict.OEPen(oechem.OELightGrey, oechem.OELightGrey, oedepict.OEFill_Off, 2.0, oedepict.OEStipple_ShortDash) arcfxnB = oegrapheme.OEDefaultArcFxn(penB) layer = disp.GetLayer(oedepict.OELayerPosition_Below) for adisp in disp.GetAtomDisplays(): for arc in oegrapheme.OEGet2DSurfaceArcs(disp, adisp, radius): if atompred(adisp.GetAtom()): arcfxnA(layer, arc) else: arcfxnB(layer, arc)
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)
from openeye import oegrapheme from openeye import oeshape ############################################################### # USED TO GENERATE CODE SNIPPETS FOR THE GRAPHEME DOCUMENTATION ############################################################### if len(sys.argv) != 2: oechem.OEThrow.Usage("%s <mol file>" % sys.argv[0]) ifs = oechem.oemolistream(sys.argv[1]) refmol = oechem.OEGraphMol() oechem.OEReadMolecule(ifs, refmol) # @ <SNIPPET-RENDER-SHAPE-QUERY> opts = oegrapheme.OEShapeQueryDisplayOptions() opts.SetTitleLocation(oedepict.OETitleLocation_Hidden) arcpen = oedepict.OEPen(oechem.OEWhite, oechem.OELightGrey, oedepict.OEFill_On, 2.0) opts.SetSurfaceArcFxn(oegrapheme.OEDefaultArcFxn(arcpen)) cff = oeshape.OEColorForceField() cff.Init(oeshape.OEColorFFType_ImplicitMillsDean) disp = oegrapheme.OEShapeQueryDisplay(refmol, cff, opts) image = oedepict.OEImage(420.0, 280.0) oegrapheme.OERenderShapeQuery(image, disp) # @ </SNIPPET-RENDER-SHAPE-QUERY> oedepict.OEWriteImage("RenderShapeQuery.png", image) oedepict.OEWriteImage("RenderShapeQuery.pdf", image)