Esempio n. 1
0
  private synchronized void GenerateIsoMorphismMapping() throws Exception {

    winner.searchWinners(educts, products, mh);

    if (winner.getFlag()) {

      //            System.out.println("**********Updated Mapping**************");
      UpdateMapping();
      //            System.out.println("**********Updated Matrix**************");
      UpdateMatrix(mh, removeHydrogen);
      //            System.out.println("**********Generate Mapping**************");
      GenerateMapping(false);
    }
  }
Esempio n. 2
0
  private synchronized void UpdateMapping() throws Exception {
    boolean[][] FlagMatrix = winner.getFlagMatrix();

    ReactionContainer reactionStructureInformationContainer = mh.getReactionContainer();

    for (int iIndex = 0; iIndex < reactionStructureInformationContainer.getEductCount(); iIndex++) {
      for (int jIndex = 0;
          jIndex < reactionStructureInformationContainer.getProductCount();
          jIndex++) {
        int substrateIndex = iIndex;
        int productIndex = jIndex;
        IAtomContainer ac1 = reactionStructureInformationContainer.getEduct(substrateIndex);
        IAtomContainer ac2 = reactionStructureInformationContainer.getProduct(productIndex);

        if (FlagMatrix[substrateIndex][productIndex]) {

          // updateFlag=true;
          BitSet a_BitSet =
              reactionStructureInformationContainer.getFingerPrintofEduct(
                  substrateIndex); // a_BitSet=EDUCT
          BitSet b_BitSet =
              reactionStructureInformationContainer.getFingerPrintofProduct(
                  productIndex); // b_BitSet=PRODUCT

          /*
           * Choose this function if you want JMCS to run
           */
          ac1.setID(this.eductList.get(substrateIndex));
          ac2.setID(this.productList.get(productIndex));

          IGraphMatching graphMatching =
              new GraphMatching(reactionName, ac1, ac2, _dirSuffix, removeHydrogen);
          boolean mcsMatch =
              graphMatching.mcsMatch(
                  mh, removeHydrogen, substrateIndex, productIndex, a_BitSet, b_BitSet);
          if (DEBUG) {
            out.println(
                "Mol Size E: " + ac1.getAtomCount() + " , Mol Size P: " + ac2.getAtomCount());
          }
          if (mcsMatch) {
            if (DEBUG) {
              out.println(eductList.get(substrateIndex) + " <=> " + productList.get(productIndex));
            }
            delta += graphMatching.removeMatchedAtomsAndUpdateAAM(reaction);
            List<MolMapping> rMap =
                getReactionMolMapping()
                    .getMapping(
                        reactionName,
                        this.eductList.get(substrateIndex),
                        this.productList.get(productIndex));
            for (MolMapping map : rMap) {
              map.setReactionMapping(true);
              IAtomContainer mol = graphMatching.getMatchedPart();
              mol = canonLabeler.getCanonicalMolecule(mol);
              CDKSMILES cdkSmiles = new CDKSMILES(mol, true, false);
              map.setMatchedSMILES(cdkSmiles.getCanonicalSMILES(), ++stepIndex);
            }
          }
          IAtomContainer remainingEduct = graphMatching.getRemainingEduct();
          IAtomContainer remainingProduct = graphMatching.getRemainingProduct();

          reactionStructureInformationContainer.putEduct(substrateIndex, remainingEduct);
          reactionStructureInformationContainer.putProduct(productIndex, remainingProduct);
          reactionStructureInformationContainer.setEductModified(substrateIndex, true);
          reactionStructureInformationContainer.setProductModified(productIndex, true);
        }
      }
    }
  }
Esempio n. 3
0
  private synchronized void GenerateMapping(boolean flag) throws Exception {
    boolean ruleMatchingFlag = flag;
    if (DEBUG) {
      //            System.out.println("**********Orignal Matrix**************");
      printMatrixAtomContainer(mh, eductList, productList);
      printSimMatrix(mh, eductList, productList);
      printCliqueMatrix(mh, eductList, productList);
      //            printStereoMatrix(mh, eductList, productList);
      //            printFragmentMatrix(mh, eductList, productList);
      //            printEnergyMatrix(mh, eductList, productList);
    }
    boolean conditionmet = false;
    if (!ruleMatchingFlag) {
      RuleBasedMappingHandler ruleBasedMappingHandler =
          new RuleBasedMappingHandler(mh, eductList, productList);
      if (ruleBasedMappingHandler.isMatchFound()) {
        if (DEBUG) {
          out.println("Rule Based Mapping Handler Match Found");
        }
        mh = Selector.modifyMatrix(ruleBasedMappingHandler.getMatrixHolder());
        conditionmet = true;
      }
      ruleMatchingFlag = true;
    }

    if (!conditionmet) {
      if (DEBUG) {
        out.println("Subgraph/Exact Match Test");
      }
      IsomorphismMin omorphismMin = new IsomorphismMin(mh, eductList, productList);
      if (omorphismMin.isSubAndCompleteMatchFlag()) {
        if (DEBUG) {
          out.println("Subgraph/Exact Match");
        }
        mh = omorphismMin.getUpdatedHolder();
      }
    }
    if (DEBUG) {
      out.println("**********Modified Matrix**************");
      //            printMatrixAtomContainer(mh, eductList, productList);
      printSimMatrix(mh, eductList, productList);
      printCliqueMatrix(mh, eductList, productList);
      //            printStereoMatrix(mh, eductList, productList);
      //            printFragmentMatrix(mh, eductList, productList);
      //            printEnergyMatrix(mh, eductList, productList);
    }
    winner.searchWinners(educts, products, mh);
    if (DEBUG) {
      printFlagMatrix(winner, eductList, productList);
    }
    if (winner.getFlag()) {
      if (DEBUG) {
        out.println("**********Updated Mapping**************");
      }
      UpdateMapping();
      if (DEBUG) {
        out.println("**********Updated Matrix**************");
      }
      UpdateMatrix(mh, removeHydrogen);
      if (DEBUG) {
        out.println("**********Generate Mapping**************");
      }
      GenerateMapping(ruleMatchingFlag);
    }
  }