/* (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. */ /**************************************************************************** * Extract ring templates for 2D coordinate generation ****************************************************************************/ using System; using OpenEye.OEChem; public class ExtractRingTemplates { public static void Main(string[] args) { OEInterface itf = new OEInterface(interfaceData, "ExtractRingTemplates", args); String ifname = itf.GetString("-in"); String ofname = itf.GetString("-out"); oemolistream ifs = new oemolistream(); if (!ifs.open(ifname)) OEChem.OEThrow.Fatal("Unable to open " + ifname + " for reading"); if (!OEChem.OEIs2DFormat(ifs.GetFormat())) OEChem.OEThrow.Fatal("Invalid input format: need 2D coordinates"); oemolostream ofs = new oemolostream(); if (!ofs.open(ofname)) OEChem.OEThrow.Fatal("Unable to open " + ofname + " for writing"); if (!OEChem.OEIs2DFormat(ofs.GetFormat())) OEChem.OEThrow.Fatal("Invalid output format: unable to write 2D coordinates"); uint nrrings = 0; OEGraphMol mol = new OEGraphMol(); while (OEChem.OEReadMolecule(ifs, mol)) { foreach (OEMolBase ring in OEChem.OEExtractRingTemplates(mol)) { nrrings += 1; OEChem.OEWriteMolecule(ofs, ring); } } OEChem.OEThrow.Info(nrrings + " number of ring templates extracted"); } private static string interfaceData=@" !BRIEF [-i] [-o] !PARAMETER -i !ALIAS -in !TYPE string !REQUIRED true !BRIEF input file name !KEYLESS 1 !END !PARAMETER -o !ALIAS -out !TYPE string !REQUIRED true !BRIEF output file name !KEYLESS 2 !END "; }