def main(argv=[__name__]): if len(argv) != 3: oechem.OEThrow.Usage("%s <input> <output>" % argv[0]) # input - preserve rotor-offset-compression ifs = oechem.oemolistream() ihand = ifs.GetBinaryIOHandler() ihand.Clear() oechem.OEInitHandler(ihand, oechem.OEBRotCompressOpts(), oechem.OEBRotCompressOpts()) ifname = argv[1] if not ifs.open(ifname): oechem.OEThrow.Fatal("Unable to open %s for reading" % argv[1]) # output ofname = argv[2] oformt = oechem.OEGetFileType(oechem.OEGetFileExtension(ofname)) if oformt != oechem.OEFormat_OEB: oechem.OEThrow.Fatal("Output file format much be OEB") ofs = oechem.oemolostream() if not ofs.open(ofname): oechem.OEThrow.Fatal("Unable to open %s for writing" % ofname) iss = oechem.oeisstream(COLOR_FORCE_FIELD) cff = oeshape.OEColorForceField() if not cff.Init(iss): oechem.OEThrow.Fatal("Unable to initialize OEColorForceField") dots = oechem.OEDots(10000, 200, "molecules") for mol in ifs.GetOEMols(): oefastrocs.OEPrepareFastROCSMol(mol, cff) oechem.OEWriteMolecule(ofs, mol) dots.Update() dots.Total() ofs.close() print("Indexing %s" % ofname) if not oechem.OECreateMolDatabaseIdx(ofname): oechem.OEThrow.Fatal("Failed to index %s" % argv[2]) return 0
def GetShapeDatabaseArgs(itf): shapeOnly = itf.GetBool("-shapeOnly") if shapeOnly and itf.GetParameter("-chemff").GetHasValue(): oechem.OEThrow.Fatal( "Unable to specify -shapeOnly and -chemff at the same time!") chemff = itf.GetString("-chemff") if not chemff.endswith(".cff"): return (GetDatabaseType(shapeOnly), OECOLOR_FORCEFIELDS[chemff]) # given a .cff file, use that to construct a OEColorForceField assert not shapeOnly cff = oeshape.OEColorForceField() if not cff.Init(chemff): oechem.OEThrow.Fatal("Unable to read color force field from '%s'" % chemff) return (cff, )
def main(argv=[__name__]): if len(argv) != 3: oechem.OEThrow.Usage("%s <reffile> <overlayfile>" % argv[0]) reffs = oechem.oemolistream(argv[1]) fitfs = oechem.oemolistream(argv[2]) refmol = oechem.OEGraphMol() oechem.OEReadMolecule(reffs, refmol) # Modify ImplicitMillsDean color force field by # adding user defined color interactions cff = oeshape.OEColorForceField() cff.Init(oeshape.OEColorFFType_ImplicitMillsDean) cff.ClearInteractions() donorType = cff.GetType("donor") accepType = cff.GetType("acceptor") cff.AddInteraction(donorType, donorType, "gaussian", -1.0, 1.0) cff.AddInteraction(accepType, accepType, "gaussian", -1.0, 1.0) # Prepare reference molecule for calculation # With default options this will add required color atoms # Set the modified color force field for addignment prep = oeshape.OEOverlapPrep() prep.SetColorForceField(cff) prep.Prep(refmol) # Get appropriate function to calculate exact color # Set appropriate options to use the user defined color options = oeshape.OEColorOptions() options.SetColorForceField(cff) colorFunc = oeshape.OEExactColorFunc(options) colorFunc.SetupRef(refmol) res = oeshape.OEOverlapResults() for fitmol in fitfs.GetOEGraphMols(): prep.Prep(fitmol) colorFunc.Overlap(fitmol, res) print("Fit Title: %s Color Tanimoto: %.2f" % (fitmol.GetTitle(), res.GetColorTanimoto()))
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)