/* (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 System.IO; using OpenEye.OEChem; using OpenEye.OEGrid; using OpenEye.OEShape; public class NxNShape { private static StreamWriter csv; private void OneConf(OEConfBase conf, OEOverlapPrep prep, String filename) { csv.Write("{0}_{1}", conf.GetTitle(), conf.GetIdx()); OEMol refmol = new OEMol(conf); OEOverlayOptions options = new OEOverlayOptions(); options.SetOverlapFunc(new OEGridShapeFunc()); OEOverlay overlay = new OEOverlay(); overlay.SetupRef(refmol); oemolistream bfs = new oemolistream(filename); foreach (OEMol fitmol in bfs.GetOEMols()) { prep.Prep(fitmol); OEBestOverlayResultsIter resiter = overlay.Overlay(fitmol); OEBestOverlayScoreIter scoreiter = new OEBestOverlayScoreIter(); OEShape.OESortOverlayScores(scoreiter, resiter, new OEHighestTanimoto(), 1, true); foreach (OEBestOverlayScore score in scoreiter) csv.Write(",{0:0.00}", score.GetTanimoto()); } bfs.close(); csv.WriteLine(); } private void GenHeader(String filename) { csv.Write("name"); oemolistream ifs = new oemolistream(filename); foreach (OEMol mol in ifs.GetOEMols()) { Console.WriteLine(mol.GetTitle()); foreach (OEConfBase conf in mol.GetConfs()) { csv.Write(",{0}_{1}", conf.GetTitle(), conf.GetIdx()); } } ifs.close(); csv.WriteLine(); } private void OpenCSV(String csvfilename) { try { csv = File.CreateText(csvfilename); } catch (Exception) { Console.WriteLine("Unable to open output file {0}", csvfilename); } } public void NxN(String filename, String csvfilename) { OpenCSV(csvfilename); GenHeader(filename); oemolistream afs = new oemolistream(filename); OEOverlapPrep prep = new OEOverlapPrep(); prep.SetAssignColor(false); foreach (OEMol molA in afs.GetOEMols()) { prep.Prep(molA); foreach (OEConfBase conf in molA.GetConfs()) { OneConf(conf, prep, filename); } } csv.Close(); } public static void Main(string [] args) { if (args.Length != 2) { OEChem.OEThrow.Usage("NxNShape "); } NxNShape app = new NxNShape(); app.NxN(args[0], args[1]); } }