示例#1
0
  /**
   * 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);
    }
  }
示例#2
0
  /** Starts enumeration of the combinatorial library. */
  public void run() {
    // enumeration starts
    if (startEnumeration) {

      // start time
      long start = System.nanoTime();

      // if GUI mode is used, some statistics are shown
      if (useGui) {
        smiFrame.setStatistics(
            compAdmin.getNumberOfScaffolds(),
            compAdmin.getNumberOfLinkers(),
            compAdmin.getNumberOfBuildingBlocks());
      }

      // start enumeration
      try {
        this.enumerateLibrary();
      } catch (Throwable thr) {
        handleException(thr);
      }

      // end time
      long end = System.nanoTime();

      // formats time
      DecimalFormat df = new DecimalFormat("###,###,###,##0.000000000###");

      // message of end of enumeration is shown in command line/GUI - NOT if library is printed to
      // command line
      if (useGui) {
        smiFrame.setTime(start, end);
        smiFrame.showEndMessage(start, end);
      } else if (!printToCommandLine) {
        // total time is printed out
        if (compoundCounter == 1) {
          System.out.println(
              compoundCounter
                  + " compound synthesized in "
                  + df.format((double) (end - start) / 1000000000)
                  + " seconds");
        } else {
          System.out.println(
              compoundCounter
                  + " compounds synthesized in "
                  + df.format((double) (end - start) / 1000000000)
                  + " seconds");
        }
      }
    }
  }
示例#3
0
  /**
   * 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&lt;String[]&gt; 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&lt;String[]&gt; 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);
    }
  }
示例#4
0
  /**
   * 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);
    }
  }
示例#5
0
  /** Enumerates the combinatorial library. */
  private void enumerateLibrary() throws Exception {
    boolean linkerEmpty;
    int numRGroups;
    int ringNumber;
    int[] currentCombination;

    StringBuilder intermediateProduct = new StringBuilder();
    StringBuilder currentMolecule = new StringBuilder();
    StringBuilder moleculeID = new StringBuilder();

    // as long as new combination are available and thread shall not be stopped
    while (iterator.hasNext() & !stop) {
      // gets next combination
      currentCombination = iterator.next();

      // StringBuilder with the currentMolecule gets a reset - so you can use one Object for all
      // molecules
      currentMolecule
          .delete(0, currentMolecule.length())
          .append(compAdmin.getScaffoldString(currentCombination[0]));

      // StringBuilder with molecule ID gets a reset
      moleculeID
          .delete(0, moleculeID.length())
          .append(compAdmin.getScaffoldID(currentCombination[0]));

      // gets number of variable side chains in the current scaffold
      numRGroups = compAdmin.getNumberOfRGroups(currentCombination[0]);
      ringNumber = 10;

      // for each variable side chain
      for (int i = 1; i <= numRGroups; i++) {
        linkerEmpty = compAdmin.getLinker(currentCombination[i]).isEmpty();

        // ringnumber is checked, so that conflicts with existing ringnumbers in scaffold-, linker-
        // or buildingblock-SMILES can not occur
        while (compAdmin.numberBlacklisted(
            ringNumber,
            currentCombination[0],
            currentCombination[i],
            currentCombination[i + numRGroups])) ringNumber++;

        // if linker is not the empty linker
        if (!linkerEmpty) {
          // StringBuilder with the current intermediate gets a reset - so you can use one Object
          // for all intermediates
          intermediateProduct
              .delete(0, intermediateProduct.length())
              .append(compAdmin.getLinker(currentCombination[i]).getLinkerForConcat(ringNumber));

          // current intermediate is created
          smiConcat.concatenate(
              intermediateProduct,
              '.',
              compAdmin
                  .getBuildingBlock(currentCombination[i + numRGroups])
                  .getBlockForConcat(ringNumber));
          ringNumber++;

          // current intermediate gets attached to the scaffold
          smiConcat.concatenate(
              currentMolecule,
              intermediateProduct,
              '.',
              compAdmin.getScaffold(currentCombination[0]).getStringOfGroupWithIndex(i - 1),
              ringNumber);
          ringNumber++;

          // if linker is the empty linker
        } else {
          // building block gets directly attached to the scaffold
          smiConcat.concatenate(
              currentMolecule,
              compAdmin
                  .getBuildingBlock(currentCombination[i + numRGroups])
                  .getBlockForConcat(ringNumber),
              '.',
              compAdmin.getScaffold(currentCombination[0]).getStringOfGroupWithIndex(i - 1),
              ringNumber);
          ringNumber++;
        }

        // molecule ID gets an update
        moleculeID
            .append('.')
            .append(compAdmin.getLinkerID(currentCombination[i]))
            .append('_')
            .append(compAdmin.getBuildingBlockID(currentCombination[i + numRGroups]));
      }
      // created molecule is written
      smiWri.writeSMILES(currentMolecule, moleculeID);
      compoundCounter++;
    }
    smiWri.close();
  }