Beispiel #1
0
 public static int[][] getMcsAsAtomIndexMapping(IAtomContainer mol1, IAtomContainer mol2)
     throws CDKException {
   Isomorphism mcs = new Isomorphism(org.openscience.cdk.smsd.interfaces.Algorithm.DEFAULT, true);
   mcs.init(mol1, mol2, true, true);
   mcs.setChemFilters(true, true, true);
   int mcsSize = mcs.getFirstMapping().size();
   int[][] mapping = new int[mcsSize][2];
   int i = 0;
   for (Map.Entry map : mcs.getFirstMapping().entrySet()) {
     mapping[i][0] = (Integer) map.getKey();
     mapping[i][1] = (Integer) map.getValue();
     i++;
   }
   return mapping;
 }
Beispiel #2
0
  public static IAtomContainer getMcsAsNewContainer(IAtomContainer mol1, IAtomContainer mol2)
      throws CDKException, CloneNotSupportedException {
    Isomorphism mcs = new Isomorphism(org.openscience.cdk.smsd.interfaces.Algorithm.DEFAULT, true);
    mcs.init(mol1, mol2, true, true);
    mcs.setChemFilters(true, true, true);

    mol1 = mcs.getReactantMolecule();
    mol2 = mcs.getProductMolecule();

    IAtomContainer mcsmolecule =
        DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class, mol1);

    List<IAtom> atomsToBeRemoved = new ArrayList<IAtom>();
    for (IAtom atom : mcsmolecule.atoms()) {
      int index = mcsmolecule.getAtomNumber(atom);
      if (!mcs.getFirstMapping().containsKey(index)) {
        atomsToBeRemoved.add(atom);
      }
    }

    for (IAtom atom : atomsToBeRemoved) {
      mcsmolecule.removeAtomAndConnectedElectronContainers(atom);
    }

    return mcsmolecule;
  }