/* (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. */ // Split a mol complex (a PDB structure, for example) into basic categories using System; using OpenEye.OEChem; using OpenEye.OEBio; public class SplitMolComplex { public static int Main(string[] argv) { OEInterface itf = new OEInterface(interfaceData); OEBio.OEConfigureSplitMolComplexOptions(itf); if (!OEChem.OEParseCommandLine(itf, argv, "SplitMolComplex")) OEChem.OEThrow.Fatal("Unable to interpret command line!"); string iname = itf.GetString("-in"); string oname = itf.GetString("-out"); oemolistream ims = new oemolistream(); if (itf.GetUnsignedInt("-modelnum") != 1) ims.SetFlavor(OEFormat.PDB, OEChem.OEGetDefaultIFlavor(OEFormat.PDB) & ~OEIFlavor.PDB.ENDM); if (!ims.open(iname)) OEChem.OEThrow.Fatal("Cannot open input file!"); oemolostream oms = new oemolostream(); if (!oms.open(oname)) OEChem.OEThrow.Fatal("Cannot open output file!"); OEGraphMol inmol = new OEGraphMol(); if (!OEChem.OEReadMolecule(ims, inmol)) OEChem.OEThrow.Fatal("Unable to read molecule from " + iname); ims.close(); OESplitMolComplexOptions opts = new OESplitMolComplexOptions(); OEBio.OESetupSplitMolComplexOptions(opts, itf); if (itf.GetBool("-verbose")) { // don't bother counting sites unless we're going to print them uint numSites = OEBio.OECountMolComplexSites(inmol, opts); OEChem.OEThrow.SetLevel(OEErrorLevel.Verbose); OEChem.OEThrow.Verbose("sites " + numSites); } OEGraphMol lig = new OEGraphMol(); OEGraphMol prot = new OEGraphMol(); OEGraphMol wat = new OEGraphMol(); OEGraphMol other = new OEGraphMol(); if (! OEBio.OESplitMolComplex(lig, prot, wat, other, inmol, opts)) OEChem.OEThrow.Fatal("Unable to split mol complex from " + iname); if (! (lig.NumAtoms() == 0)) { OEChem.OEThrow.Verbose(" lig " + lig.GetTitle()); OEChem.OEWriteMolecule(oms, lig); } if (! (prot.NumAtoms() == 0)) { OEChem.OEThrow.Verbose(" prot " + prot.GetTitle()); OEChem.OEWriteMolecule(oms, prot); } if (! (wat.NumAtoms() == 0)) { OEChem.OEThrow.Verbose(" wat " + wat.GetTitle()); OEChem.OEWriteMolecule(oms, wat); } if (! (other.NumAtoms() == 0)) { OEChem.OEThrow.Verbose("other " + other.GetTitle()); OEChem.OEWriteMolecule(oms, other); } oms.close(); return 0; } private static string interfaceData = @" !BRIEF [] !CATEGORY ""input/output options :"" !PARAMETER -in !ALIAS -i !TYPE string !BRIEF Input molecule (usually a pdb file) !VISIBILITY simple !REQUIRED true !KEYLESS 1 !END !PARAMETER -out !ALIAS -o !TYPE string !DEFAULT splitmolcomplex.oeb.gz !BRIEF Output molecule (usually an oeb) !VISIBILITY simple !REQUIRED false !KEYLESS 2 !END !END !CATEGORY ""Display options :"" !PARAMETER -verbose !ALIAS -v !TYPE bool !DEFAULT false !BRIEF If true, return show molecule titles and number of binding sites !VISIBILITY simple !REQUIRED false !END !END "; }