/* (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.OEQuacPac; public class AssignCharges { static bool AssignChargesByName(OEMol mol, string name) { bool optimize = true; bool symmetrize = true; if (name.Equals( "noop")) return OEQuacPac.OEAssignCharges(mol, new OEChargeEngineNoOp()); else if (name.Equals( "mmff") || name.Equals( "mmff94")) return OEQuacPac.OEAssignCharges(mol, new OEMMFF94Charges()); else if (name.Equals( "am1bcc")) return OEQuacPac.OEAssignCharges(mol, new OEAM1BCCCharges()); else if (name.Equals( "am1bccnosymspt")) return OEQuacPac.OEAssignCharges(mol, new OEAM1BCCCharges(!optimize, !symmetrize)); else if (name.Equals( "amber") || name.Equals( "amberff94")) return OEQuacPac.OEAssignCharges(mol, new OEAmberFF94Charges()); else if (name.Equals( "am1bccelf10")) return OEQuacPac.OEAssignCharges(mol, new OEAM1BCCELF10Charges()); return false; } public static void Main(string[] argv) { OEInterface itf = new OEInterface(interfaceData); if (! OEChem.OEParseCommandLine(itf, argv, "AssignCharges")) OEChem.OEThrow.Fatal("Unable to interpret command line!"); oemolistream ifs = new oemolistream(); string inputFile = itf.GetString("-in"); if (! ifs.open(inputFile)) OEChem.OEThrow.Fatal("Unable to open " + inputFile + " for reading"); oemolostream ofs = new oemolostream(); string outFile = itf.GetString("-out"); if (! ofs.open(outFile)) OEChem.OEThrow.Fatal("Unable to open " + outFile + " for writing"); string chargeName = itf.GetString("-method"); OEMol mol = new OEMol(); while (OEChem.OEReadMolecule(ifs, mol)) { if (! AssignChargesByName(mol, chargeName)) OEChem.OEThrow.Warning("Unable to assign " + chargeName + " charges to mol " + mol.GetTitle()); OEChem.OEWriteMolecule(ofs, mol); } ifs.close(); ofs.close(); } private static string interfaceData = @" !BRIEF [-options] [] !CATEGORY ""input/output options :"" !PARAMETER -in !ALIAS -i !TYPE string !BRIEF Input molecule !VISIBILITY simple !REQUIRED true !KEYLESS 1 !END !PARAMETER -out !ALIAS -o !TYPE string !DEFAULT oeassigncharges.oeb.gz !BRIEF Output molecule (usually an oeb) !VISIBILITY simple !REQUIRED false !KEYLESS 2 !END !END !CATEGORY ""Charging options :"" !PARAMETER -method !TYPE string !LEGAL_VALUE noop !LEGAL_VALUE mmff !LEGAL_VALUE mmff94 !LEGAL_VALUE am1bcc !LEGAL_VALUE am1bccnosymspt !LEGAL_VALUE amber !LEGAL_VALUE amberff94 !LEGAL_VALUE am1bccelf10 !DEFAULT mmff94 !BRIEF which set of charges to apply !SIMPLE true !REQUIRED false !END !END "; }