/** * Creates a new instance of SmiLibRunner that can be conveniently used in other Java projects * when SmiLib is employed as a Java library.<br> * <br> * Example to enumerate a complete SmiLib library: * * <pre> * String[] scaffolds = new String[] {"CCC[R1]"}; * String[] linkers = new String[] {"[R][A]"}; * String[] bBlocks = new String[] {"[A]Br", "[A]Cl"}; * SmilesListWriter smiWri = new SmilesListWriter(); * SmiLibRunner runner = new SmiLibRunner(scaffolds, linkers, bBlocks, null, true, smiWri); * runner.run(); // Run SmiLib * List<String[]> library = smiWri.getSmilesList(); // Retrieve results * // String id = library.get(0)[0]; * // String smiles = library.get(0)[1]; * </pre> * * <br> * Example to enumerate a SmiLib library according to a reaction scheme: * * <pre> * String[] scaffolds = new String[] {"CCC[R1]"}; * String[] linkers = new String[] {"[R][A]"}; * String[] bBlocks = new String[] {"[A]Br", "[A]Cl"}; * String[] reactionScheme = new String[] {"1\t1\t2"}; // The reaction scheme * SmilesListWriter smiWri = new SmilesListWriter(); * SmiLibRunner runner = new SmiLibRunner(scaffolds, linkers, bBlocks, reactionScheme, true, smiWri); * runner.run(); // Run SmiLib * List<String[]> library = smiWri.getSmilesList(); // Retrieve results * // String id = library.get(0)[0]; * // String smiles = library.get(0)[1]; * </pre> * * <br> * * @param scaffolds array of source scaffolds, optionally with ID * @param linkers array of source linkers, optionally with ID * @param bBlocks array of source building blocks, optionally with ID * @param reactionScheme reactionScheme as an array. If null, complete enumeration is performed * @param checkSmiles check smiles for SmiLib conformity true/false * @param smiWri output smiles writer * @since 2.0 rc4 */ public SmiLibRunner( String[] scaffolds, String[] linkers, String[] bBlocks, String[] reactionScheme, boolean checkSmiles, SmilesWriter smiWri) { this.printToCommandLine = true; // Set true to avoid sending messages to stdout try { compAdmin = new ComponentAdministrator(scaffolds, linkers, bBlocks, checkSmiles); if (reactionScheme == null) { this.iterator = new FullCombinationIterator( compAdmin.getNumbersOfRGroups(), compAdmin.getNumberOfLinkers(), compAdmin.getNumberOfBuildingBlocks()); } else { this.iterator = new PartialCombinationIterator( reactionScheme, compAdmin.getNumbersOfRGroups(), compAdmin.getNumberOfLinkers(), compAdmin.getNumberOfBuildingBlocks()); } this.smiWri = smiWri; } catch (Exception exc) { handleException(exc); } }
/** * Creates a new instance of SmiLibRunner using a FullCombinationIterator (without reaction * scheme) for enumerating the virtual library. * * @param scaffoldsPath path/name of the file that contains scaffolds as SMILES * @param linkersPath path/name of the file that contains linkers as SMILES * @param buildingBlocksPath path/name of the file that contains building blocks as SMILES * @param printToCommandLine combinatorial library shall be printed to the command line true/false * @param saveFilePath path/name of the file where the combinatorial library will be stored if it * shall be saved in a file * @param addHydrogens add hydrogens when save as SD file * @param checkSmiles check SMILES for conformity with SMiLib rules true/false */ public SmiLibRunner( String scaffoldsPath, String linkersPath, String buildingBlocksPath, boolean printToCommandLine, String saveFilePath, boolean addHydrogens, boolean checkSmiles) { this.printToCommandLine = printToCommandLine; try { compAdmin = new ComponentAdministrator(scaffoldsPath, linkersPath, buildingBlocksPath, checkSmiles); this.iterator = new FullCombinationIterator( compAdmin.getNumbersOfRGroups(), compAdmin.getNumberOfLinkers(), compAdmin.getNumberOfBuildingBlocks()); if (printToCommandLine) smiWri = new SmilesLineWriter(); else if (saveFilePath.endsWith(".sdf")) smiWri = new SmilesToSDFWriter(saveFilePath, addHydrogens); else smiWri = new SmilesFileWriter(saveFilePath); } catch (Exception ex) { handleException(ex); } }
/** * Creates a new instance of SmiLibRunner, used when programm is started in GUI mode. * * @param scaffolds array of source scaffold (with ID) * @param linkers array of source linkers (with ID) * @param bBlocks array of source building block (with ID) * @param useReactionScheme use reaction scheme true/false * @param reactionScheme reactionScheme as array * @param targetTextArea text area where library will be written in * @param showLibrary show library in GUI true/false * @param saveAsFile save library as file true/false * @param saveAsSDF save file as SD file true/false * @param addHydrogens add implicit hydrogens when building the SD file true/false * @param path path/name of file where library will be saved * @param frame main frame of GUI * @param checkSmiles check smiles for SmiLib conformity true/false */ public SmiLibRunner( String[] scaffolds, String[] linkers, String[] bBlocks, boolean useReactionScheme, String[] reactionScheme, JTextArea targetTextArea, boolean showLibrary, boolean saveAsFile, boolean saveAsSDF, boolean addHydrogens, String path, SmiLibFrame frame, boolean checkSmiles) { this.smiFrame = frame; this.useGui = true; // load source SMILES try { compAdmin = new ComponentAdministrator(scaffolds, linkers, bBlocks, checkSmiles); if (!useReactionScheme) { this.iterator = new FullCombinationIterator( compAdmin.getNumbersOfRGroups(), compAdmin.getNumberOfLinkers(), compAdmin.getNumberOfBuildingBlocks()); } else { this.iterator = new PartialCombinationIterator( reactionScheme, compAdmin.getNumbersOfRGroups(), compAdmin.getNumberOfLinkers(), compAdmin.getNumberOfBuildingBlocks()); } smiFrame.setIterator(iterator); smiWri = new SmilesGuiWriter( targetTextArea, showLibrary, saveAsFile, saveAsSDF, addHydrogens, path, smiFrame); } catch (Exception exc) { handleException(exc); } }