/* (C) 2022 Cadence Design Systems, Inc. (Cadence) All rights reserved. TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is provided to current licensees or subscribers of Cadence products or SaaS offerings (each a "Customer"). Customer is hereby permitted to use, copy, and modify the Sample Code, subject to these terms. Cadence 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 Cadence 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 Cadence be liable for any damages or liability in connection with the Sample Code or its use. */ using System; using OpenEye.OEChem; using OpenEye.OEBio; using OpenEye.OEDocking; public class MyOptions : OEPositOptions { public MyOptions() : base() { OEUIntParameter param1 = new OEUIntParameter("-numPoses", 1); param1.AddLegalRange("1", "20"); param1.SetBrief("Number of poses to generate"); _param1 = AddParameter(param1); } public uint GetNumPoses() { if (_param1.GetHasValue()) return (uint.Parse(_param1.GetStringValue())); return (uint.Parse(_param1.GetStringDefault())); } OEParameter _param1; } public class PoseMolecules { public static void Main(string[] argv) { MyOptions positOpts = new MyOptions(); OERefInputAppOptions opts = new OERefInputAppOptions(positOpts, "PoseMolecules", OEFileStringType.Mol3D, OEFileStringType.DU, OEFileStringType.DU, "-receptor"); if (OEChem.OEConfigureOpts(opts, argv, false) == OEOptsConfigureStatus.Help) Environment.Exit(1); positOpts.UpdateValues(opts); oemolistream ifs = new oemolistream(); if (!ifs.open(opts.GetInFile())) OEChem.OEThrow.Fatal("Unable to open " + opts.GetInFile() + " for reading"); oeifstream rfs = new oeifstream(); if (!rfs.open(opts.GetRefFile())) OEChem.OEThrow.Fatal("Unable to open " + opts.GetRefFile() + " for reading"); oeofstream ofs = new oeofstream(); if (!ofs.open(opts.GetOutFile())) OEChem.OEThrow.Fatal("Unable to open " + opts.GetOutFile() + " for writing"); OEPosit poser = new OEPosit(positOpts); OEDesignUnit du = new OEDesignUnit(); uint count = 0; while (OEBio.OEReadDesignUnit(rfs, du)) { if (!du.HasReceptor()) OEChem.OEThrow.Fatal("Design unit " + du.GetTitle() + " does not contain a receptor"); poser.AddReceptor(du); count += 1; } if (count == 0) OEChem.OEThrow.Fatal("Input design unit does not contain any receptor"); OEChem.OEThrow.Info("Number of conformers: " + positOpts.GetNumPoses()); OEChem.OEThrow.Info("Best receptor pose flag: " + positOpts.GetBestReceptorPoseOnly()); foreach (OEMol mcmol in ifs.GetOEMols()) { OEChem.OEThrow.Info("posing " + mcmol.GetTitle()); OEPositResults results = new OEPositResults(); uint returnCode = poser.Dock(results, mcmol, positOpts.GetNumPoses()); if (returnCode == OEDockingReturnCode.Success) { foreach (OESinglePoseResult result in results.GetSinglePoseResults()) { OEDesignUnit posedDU = new OEDesignUnit(result.GetDesignUnit()); posedDU.SetDoubleData(poser.GetName(), result.GetProbability()); OEChem.OEThrow.Info("Receptor used: " + posedDU.GetTitle() + " pose probability: " + result.GetProbability()); OEBio.OEWriteDesignUnit(ofs, posedDU); } } else { string errMsg = OEDocking.OEDockingReturnCodeGetName(returnCode); OEChem.OEThrow.Warning(mcmol.GetTitle() + " : " + errMsg); } } ofs.close(); ifs.close(); rfs.close(); } }