Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing old SMSD classes.

  • Loading branch information...
commit 46fe28a66b88fec824c80d1b35e187a376913c07 1 parent 4efb2ff
John May authored
Showing with 0 additions and 18,492 deletions.
  1. +0 −973 src/main/org/openscience/cdk/smsd/Isomorphism.java
  2. +0 −39 src/main/org/openscience/cdk/smsd/algorithm/matchers/AtomMatcher.java
  3. +0 −39 src/main/org/openscience/cdk/smsd/algorithm/matchers/BondMatcher.java
  4. +0 −177 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultBondMatcher.java
  5. +0 −188 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultMCSPlusAtomMatcher.java
  6. +0 −93 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultMatcher.java
  7. +0 −177 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultRGraphAtomMatcher.java
  8. +0 −333 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultVFAtomMatcher.java
  9. +0 −188 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultVFBondMatcher.java
  10. +0 −39 src/main/org/openscience/cdk/smsd/algorithm/matchers/VFAtomMatcher.java
  11. +0 −39 src/main/org/openscience/cdk/smsd/algorithm/matchers/VFBondMatcher.java
  12. +0 −1,014 src/main/org/openscience/cdk/smsd/algorithm/mcgregor/McGregor.java
  13. +0 −664 src/main/org/openscience/cdk/smsd/algorithm/mcgregor/McGregorChecks.java
  14. +0 −210 src/main/org/openscience/cdk/smsd/algorithm/mcgregor/McgregorHelper.java
  15. +0 −491 src/main/org/openscience/cdk/smsd/algorithm/mcgregor/QueryProcessor.java
  16. +0 −417 src/main/org/openscience/cdk/smsd/algorithm/mcgregor/TargetProcessor.java
  17. +0 −482 src/main/org/openscience/cdk/smsd/algorithm/mcsplus/BKKCKCF.java
  18. +0 −86 src/main/org/openscience/cdk/smsd/algorithm/mcsplus/ExactMapping.java
  19. +0 −438 src/main/org/openscience/cdk/smsd/algorithm/mcsplus/GenerateCompatibilityGraph.java
  20. +0 −139 src/main/org/openscience/cdk/smsd/algorithm/mcsplus/MCSPlus.java
  21. +0 −210 src/main/org/openscience/cdk/smsd/algorithm/mcsplus/MCSPlusHandler.java
  22. +0 −1,186 src/main/org/openscience/cdk/smsd/algorithm/rgraph/CDKMCS.java
  23. +0 −267 src/main/org/openscience/cdk/smsd/algorithm/rgraph/CDKMCSHandler.java
  24. +0 −688 src/main/org/openscience/cdk/smsd/algorithm/rgraph/CDKRGraph.java
  25. +0 −125 src/main/org/openscience/cdk/smsd/algorithm/rgraph/CDKRMap.java
  26. +0 −662 src/main/org/openscience/cdk/smsd/algorithm/rgraph/CDKRMapHandler.java
  27. +0 −151 src/main/org/openscience/cdk/smsd/algorithm/rgraph/CDKRNode.java
  28. +0 −269 src/main/org/openscience/cdk/smsd/algorithm/rgraph/CDKSubGraphHandler.java
  29. +0 −237 src/main/org/openscience/cdk/smsd/algorithm/single/SingleMapping.java
  30. +0 −204 src/main/org/openscience/cdk/smsd/algorithm/single/SingleMappingHandler.java
  31. +0 −410 src/main/org/openscience/cdk/smsd/algorithm/vflib/VFlibMCSHandler.java
  32. +0 −314 src/main/org/openscience/cdk/smsd/algorithm/vflib/VFlibSubStructureHandler.java
  33. +0 −372 src/main/org/openscience/cdk/smsd/algorithm/vflib/VFlibTurboHandler.java
  34. +0 −70 src/main/org/openscience/cdk/smsd/algorithm/vflib/builder/EdgeBuilder.java
  35. +0 −87 src/main/org/openscience/cdk/smsd/algorithm/vflib/builder/NodeBuilder.java
  36. +0 −119 src/main/org/openscience/cdk/smsd/algorithm/vflib/builder/TargetProperties.java
  37. +0 −191 src/main/org/openscience/cdk/smsd/algorithm/vflib/builder/VFQueryBuilder.java
  38. +0 −79 src/main/org/openscience/cdk/smsd/algorithm/vflib/interfaces/IEdge.java
  39. +0 −120 src/main/org/openscience/cdk/smsd/algorithm/vflib/interfaces/IMapper.java
  40. +0 −101 src/main/org/openscience/cdk/smsd/algorithm/vflib/interfaces/INode.java
  41. +0 −116 src/main/org/openscience/cdk/smsd/algorithm/vflib/interfaces/IQuery.java
  42. +0 −67 src/main/org/openscience/cdk/smsd/algorithm/vflib/interfaces/IQueryCompiler.java
  43. +0 −128 src/main/org/openscience/cdk/smsd/algorithm/vflib/interfaces/IState.java
  44. +0 −90 src/main/org/openscience/cdk/smsd/algorithm/vflib/map/Match.java
  45. +0 −279 src/main/org/openscience/cdk/smsd/algorithm/vflib/map/VFMCSMapper.java
  46. +0 −281 src/main/org/openscience/cdk/smsd/algorithm/vflib/map/VFMapper.java
  47. +0 −279 src/main/org/openscience/cdk/smsd/algorithm/vflib/map/VFState.java
  48. +0 −188 src/main/org/openscience/cdk/smsd/algorithm/vflib/query/QueryCompiler.java
  49. +0 −975 src/main/org/openscience/cdk/smsd/filters/ChemicalFilters.java
  50. +0 −103 src/main/org/openscience/cdk/smsd/filters/PostFilter.java
  51. +0 −95 src/main/org/openscience/cdk/smsd/global/TimeOut.java
  52. +0 −100 src/main/org/openscience/cdk/smsd/helper/BinaryTree.java
  53. +0 −118 src/main/org/openscience/cdk/smsd/helper/BondEnergy.java
  54. +0 −118 src/main/org/openscience/cdk/smsd/helper/FinalMappings.java
  55. +0 −106 src/main/org/openscience/cdk/smsd/helper/LabelContainer.java
  56. +0 −215 src/main/org/openscience/cdk/smsd/interfaces/AbstractMCS.java
  57. +0 −44 src/main/org/openscience/cdk/smsd/interfaces/AbstractMCSAlgorithm.java
  58. +0 −43 src/main/org/openscience/cdk/smsd/interfaces/AbstractSubGraph.java
  59. +0 −105 src/main/org/openscience/cdk/smsd/interfaces/Algorithm.java
  60. +0 −77 src/main/org/openscience/cdk/smsd/interfaces/IFinalMapping.java
  61. +0 −92 src/main/org/openscience/cdk/smsd/interfaces/IMCSBase.java
  62. +0 −190 src/main/org/openscience/cdk/smsd/labelling/AbstractReactionLabeller.java
  63. +0 −100 src/main/org/openscience/cdk/smsd/labelling/AtomContainerAtomPermutor.java
  64. +0 −75 src/main/org/openscience/cdk/smsd/labelling/AtomContainerPrinter.java
  65. +0 −38 src/main/org/openscience/cdk/smsd/labelling/CanonicalLabellingAdaptor.java
  66. +0 −15 src/main/org/openscience/cdk/smsd/labelling/ICanonicalMoleculeLabeller.java
  67. +0 −20 src/main/org/openscience/cdk/smsd/labelling/ICanonicalReactionLabeller.java
  68. +0 −28 src/main/org/openscience/cdk/smsd/labelling/MoleculeSignatureLabellingAdaptor.java
  69. +0 −203 src/main/org/openscience/cdk/smsd/labelling/Permutor.java
  70. +0 −22 src/main/org/openscience/cdk/smsd/labelling/SignatureReactionCanoniser.java
  71. +0 −21 src/main/org/openscience/cdk/smsd/labelling/SmilesReactionCanoniser.java
  72. +0 −143 src/main/org/openscience/cdk/smsd/ring/HanserRingFinder.java
  73. +0 −139 src/main/org/openscience/cdk/smsd/ring/PathEdge.java
  74. +0 −162 src/main/org/openscience/cdk/smsd/ring/PathGraph.java
  75. +0 −131 src/main/org/openscience/cdk/smsd/ring/RingFilter.java
  76. +0 −80 src/main/org/openscience/cdk/smsd/ring/RingFinder.java
  77. +0 −472 src/main/org/openscience/cdk/smsd/tools/BondEnergies.java
  78. +0 −513 src/main/org/openscience/cdk/smsd/tools/ExtAtomContainerManipulator.java
  79. +0 −184 src/main/org/openscience/cdk/smsd/tools/MolHandler.java
  80. +0 −143 src/main/org/openscience/cdk/smsd/tools/MoleculeSanityCheck.java
  81. +0 −106 src/main/org/openscience/cdk/smsd/tools/TimeManager.java
973 src/main/org/openscience/cdk/smsd/Isomorphism.java
View
@@ -1,973 +0,0 @@
-/**
- *
- * Copyright (C) 2006-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your sourceAtomCount code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received rBondCount copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-package org.openscience.cdk.smsd;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.logging.Level;
-
-import org.openscience.cdk.annotations.TestClass;
-import org.openscience.cdk.annotations.TestMethod;
-import org.openscience.cdk.exception.CDKException;
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.interfaces.IBond;
-import org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer;
-import org.openscience.cdk.smsd.algorithm.mcsplus.MCSPlusHandler;
-import org.openscience.cdk.smsd.algorithm.rgraph.CDKMCSHandler;
-import org.openscience.cdk.smsd.algorithm.rgraph.CDKSubGraphHandler;
-import org.openscience.cdk.smsd.algorithm.single.SingleMappingHandler;
-import org.openscience.cdk.smsd.algorithm.vflib.VFlibMCSHandler;
-import org.openscience.cdk.smsd.algorithm.vflib.VFlibSubStructureHandler;
-import org.openscience.cdk.smsd.algorithm.vflib.VFlibTurboHandler;
-import org.openscience.cdk.smsd.filters.ChemicalFilters;
-import org.openscience.cdk.smsd.global.TimeOut;
-import org.openscience.cdk.smsd.interfaces.AbstractMCS;
-import org.openscience.cdk.smsd.interfaces.Algorithm;
-import org.openscience.cdk.smsd.tools.MolHandler;
-import org.openscience.cdk.tools.ILoggingTool;
-import org.openscience.cdk.tools.LoggingToolFactory;
-
-/**
- * <p>This class implements the Isomorphism- a multipurpose structure comparison tool.
- * It allows users to, i) find the maximal common substructure(s) (MCS);
- * ii) perform the mapping of a substructure in another structure, and;
- * iii) map two isomorphic structures.</p>
- *
- * <p>It also comes with various published algorithms. The user is free to
- * choose his favorite algorithm to perform MCS or substructure search.
- * For example 0: Isomorphism algorithm, 1: MCSPlus, 2: VFLibMCS, 3: CDKMCS, 4:
- * Substructure</p>
- *
- * <p>It also has a set of robust chemical filters (i.e. bond energy, fragment
- * count, stereo & bond match) to sort the reported MCS solutions in a chemically
- * relevant manner. Each comparison can be made with or without using the bond
- * sensitive mode and with implicit or explicit hydrogens.</p>
- *
- * <p>If you are using <font color="#FF0000">Isomorphism, please cite Rahman <i>et.al. 2009</i></font>
- * {@cdk.cite SMSD2009}. The Isomorphism algorithm is described in this paper.
- * </p>
- *
- *
- * <p>An example for <b>Substructure search</b>:</p>
- * <font color="#003366">
- * <pre>
- * SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
- * // Benzene
- * IAtomContainer A1 = sp.parseSmiles("C1=CC=CC=C1");
- * // Napthalene
- * IAtomContainer A2 = sp.parseSmiles("C1=CC2=C(C=C1)C=CC=C2");
- * //Turbo mode search
- * //Bond Sensitive is set true
- * Isomorphism comparison = new Isomorphism(Algorithm.SubStructure, true);
- * // set molecules, remove hydrogens, clean and configure molecule
- * comparison.init(A1, A2, true, true);
- * // set chemical filter true
- * comparison.setChemFilters(false, false, false);
- * if (comparison.isSubgraph()) {
- * //Get similarity score
- * System.out.println("Tanimoto coefficient: " + comparison.getTanimotoSimilarity());
- * System.out.println("A1 is a subgraph of A2: " + comparison.isSubgraph());
- * //Get Modified AtomContainer
- * IAtomContainer Mol1 = comparison.getReactantMolecule();
- * IAtomContainer Mol2 = comparison.getProductMolecule();
- * // Print the mapping between molecules
- * System.out.println(" Mappings: ");
- * for (Map.Entry <Integer, Integer> mapping : comparison.getFirstMapping().entrySet()) {
- * System.out.println((mapping.getKey() + 1) + " " + (mapping.getValue() + 1));
- *
- * IAtom eAtom = Mol1.getAtom(mapping.getKey());
- * IAtom pAtom = Mol2.getAtom(mapping.getValue());
- * System.out.println(eAtom.getSymbol() + " " + pAtom.getSymbol());
- * }
- * System.out.println("");
- * }
- *
- * </pre>
- * </font>
- *
- * <p>An example for <b>MCS search</b>:</p>
- * <font color="#003366">
- * <pre>
- * SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
- * // Benzene
- * IAtomContainer A1 = sp.parseSmiles("C1=CC=CC=C1");
- * // Napthalene
- * IAtomContainer A2 = sp.parseSmiles("C1=CC2=C(C=C1)C=CC=C2");
- * //{ 0: Default Isomorphism Algorithm, 1: MCSPlus Algorithm, 2: VFLibMCS Algorithm, 3: CDKMCS Algorithm}
- * //Bond Sensitive is set true
- * Isomorphism comparison = new Isomorphism(Algorithm.DEFAULT, true);
- * // set molecules, remove hydrogens, clean and configure molecule
- * comparison.init(A1, A2, true, true);
- * // set chemical filter true
- * comparison.setChemFilters(true, true, true);
- *
- * //Get similarity score
- * System.out.println("Tanimoto coefficient: " + comparison.getTanimotoSimilarity());
- * System.out.println("A1 is a subgraph of A2: " + comparison.isSubgraph());
- * //Get Modified AtomContainer
- * IAtomContainer Mol1 = comparison.getReactantMolecule();
- * IAtomContainer Mol2 = comparison.getProductMolecule();
- * // Print the mapping between molecules
- * System.out.println(" Mappings: ");
- * for (Map.Entry <Integer, Integer> mapping : comparison.getFirstMapping().entrySet()) {
- * System.out.println((mapping.getKey() + 1) + " " + (mapping.getValue() + 1));
- *
- * IAtom eAtom = Mol1.getAtom(mapping.getKey());
- * IAtom pAtom = Mol2.getAtom(mapping.getValue());
- * System.out.println(eAtom.getSymbol() + " " + pAtom.getSymbol());
- * }
- * System.out.println("");
- *
- * </pre>
- * </font>
- *
- * @cdk.require java1.5+
- *
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- *
- */
-@TestClass("org.openscience.cdk.smsd.factory.SubStructureSearchAlgorithmsTest")
-public final class Isomorphism extends AbstractMCS implements Serializable {
-
- static final long serialVersionUID = 10278639972837495L;
- private List<Map<Integer, Integer>> allMCS = null;
- private Map<Integer, Integer> firstSolution = null;
- private List<Map<IAtom, IAtom>> allAtomMCS = null;
- private Map<IAtom, IAtom> firstAtomMCS = null;
- private List<Map<IBond, IBond>> allBondMCS = null;
- private Map<IBond, IBond> firstBondMCS = null;
- private MolHandler rMol = null;
- private IQueryAtomContainer queryMol = null;
- private MolHandler pMol = null;
- private IAtomContainer pAC = null;
- private List<Double> stereoScore = null;
- private List<Integer> fragmentSize = null;
- private List<Double> bEnergies = null;
- private Algorithm algorithmType;
- private boolean removeHydrogen = false;
- private final static ILoggingTool Logger =
- LoggingToolFactory.createLoggingTool(Isomorphism.class);
- private double bondSensitiveTimeOut = 0.15;//mins
- private double bondInSensitiveTimeOut = 1.00;//mins
- private boolean subGraph = false;
- private boolean matchBonds = false;
-
- /**
- * This is the algorithm factory and entry port for all the MCS algorithm in the Isomorphism
- * supported algorithm {@link org.openscience.cdk.smsd.interfaces.Algorithm} types:
- * <OL>
- * <lI>0: Default,
- * <lI>1: MCSPlus,
- * <lI>2: VFLibMCS,
- * <lI>3: CDKMCS,
- * <lI>4: SubStructure
- * </OL>
- * @param algorithmType {@link org.openscience.cdk.smsd.interfaces.Algorithm}
- * @param bondTypeFlag
- */
- @TestMethod("testSubStructureSearchAlgorithms")
- public Isomorphism(Algorithm algorithmType, boolean bondTypeFlag) {
- this.algorithmType = algorithmType;
- firstSolution = new TreeMap<Integer, Integer>();
- allMCS = new ArrayList<Map<Integer, Integer>>();
- allAtomMCS = new ArrayList<Map<IAtom, IAtom>>();
- firstAtomMCS = new HashMap<IAtom, IAtom>();
- allBondMCS = new ArrayList<Map<IBond, IBond>>();
- firstBondMCS = new HashMap<IBond, IBond>();
-
- setTime(bondTypeFlag);
- setMatchBonds(bondTypeFlag);
- }
-
- private synchronized void mcsBuilder(MolHandler mol1, MolHandler mol2) {
-
- int rBondCount = mol1.getMolecule().getBondCount();
- int pBondCount = mol2.getMolecule().getBondCount();
-
- int rAtomCount = mol1.getMolecule().getAtomCount();
- int pAtomCount = mol2.getMolecule().getAtomCount();
-
- if ((rBondCount == 0 && rAtomCount > 0) || (pBondCount == 0 && pAtomCount > 0)) {
- singleMapping();
- } else {
- chooseAlgorithm(rBondCount, pBondCount);
- }
-
- if (!allAtomMCS.isEmpty() && !firstAtomMCS.isEmpty() && firstAtomMCS.size() > 1) {
- setAllBondMaps(makeBondMapsOfAtomMaps(mol1.getMolecule(), mol2.getMolecule(), allAtomMCS));
- if (getAllBondMaps().iterator().hasNext()) {
- setFirstBondMap(getAllBondMaps().iterator().next());
- }
- }
- }
-
- private synchronized void mcsBuilder(IQueryAtomContainer mol1, IAtomContainer mol2) {
-
- int rBondCount = mol1.getBondCount();
- int pBondCount = mol2.getBondCount();
-
- int rAtomCount = mol1.getAtomCount();
- int pAtomCount = mol2.getAtomCount();
-
- if ((rBondCount == 0 && rAtomCount > 0) || (pBondCount == 0 && pAtomCount > 0)) {
- singleMapping();
- } else {
- chooseAlgorithm(rBondCount, pBondCount);
- }
-
- if (!allAtomMCS.isEmpty() && !firstAtomMCS.isEmpty() && firstAtomMCS.size() > 1) {
- setAllBondMaps(makeBondMapsOfAtomMaps(mol1, mol2, allAtomMCS));
- if (getAllBondMaps().iterator().hasNext()) {
- setFirstBondMap(getAllBondMaps().iterator().next());
- }
- }
- }
-
- /**
- * Returns bond maps between source and target molecules based on the atoms
- * @param ac1 source molecule
- * @param ac2 target molecule
- * @param mappings mappings between source and target molecule atoms
- * @return bond maps between source and target molecules based on the atoms
- */
- public static List<Map<IBond, IBond>> makeBondMapsOfAtomMaps(IAtomContainer ac1, IAtomContainer ac2, List<Map<IAtom, IAtom>> mappings) {
- List<Map<IBond, IBond>> bondMaps = new ArrayList<Map<IBond, IBond>>();
- for (Map<IAtom, IAtom> mapping : mappings) {
- bondMaps.add(makeBondMapOfAtomMap(ac1, ac2, mapping));
- }
- return bondMaps;
- }
-
- /**
- *
- * Returns bond map between source and target molecules based on the atoms
- * @param ac1 source molecule
- * @param ac2 target molecule
- * @param mapping mappings between source and target molecule atoms
- * @return bond map between source and target molecules based on the atoms
- */
- public static Map<IBond, IBond> makeBondMapOfAtomMap(IAtomContainer ac1, IAtomContainer ac2, Map<IAtom, IAtom> mapping) {
- Map<IBond, IBond> maps = new HashMap<IBond, IBond>();
-
- for (Map.Entry<IAtom, IAtom> mapS : mapping.entrySet()) {
- IAtom indexI = mapS.getKey();
- IAtom indexJ = mapS.getValue();
-
- for (Map.Entry<IAtom, IAtom> mapD : mapping.entrySet()) {
- IAtom indexIPlus = mapD.getKey();
- IAtom indexJPlus = mapD.getValue();
-
- if (!indexI.equals(indexIPlus) && !indexJ.equals(indexJPlus)) {
- IBond ac1Bond = ac1.getBond(indexI, indexIPlus);
- if (ac1Bond != null) {
- IBond ac2Bond = ac2.getBond(indexJ, indexJPlus);
- if (ac2Bond != null) {
- maps.put(ac1Bond, ac2Bond);
- }
- }
- }
- }
- }
-
-// System.out.println("bond Map size:" + maps.size());
-
- return maps;
-
- }
-
- private void chooseAlgorithm(int rBondCount, int pBondCount) {
-
- switch (algorithmType) {
- case CDKMCS:
- cdkMCSAlgorithm();
- break;
- case DEFAULT:
- defaultMCSAlgorithm();
- break;
- case MCSPlus:
- mcsPlusAlgorithm();
- break;
- case SubStructure:
- subStructureAlgorithm(rBondCount, pBondCount);
- break;
- case VFLibMCS:
- vfLibMCSAlgorithm();
- break;
- case TurboSubStructure:
- turboSubStructureAlgorithm(rBondCount, pBondCount);
- }
- }
-
- private synchronized void cdkMCSAlgorithm() {
- CDKMCSHandler mcs = null;
- mcs = new CDKMCSHandler();
-
- if (queryMol == null) {
- mcs.set(rMol, pMol);
- } else {
- mcs.set(queryMol, pAC);
- }
- mcs.searchMCS(isMatchBonds());
-
- clearMaps();
-
- firstSolution.putAll(mcs.getFirstMapping());
- allMCS.addAll(mcs.getAllMapping());
-
- firstAtomMCS.putAll(mcs.getFirstAtomMapping());
- allAtomMCS.addAll(mcs.getAllAtomMapping());
-
- }
-
- private synchronized void cdkSubgraphAlgorithm() {
- CDKSubGraphHandler mcs = null;
- mcs = new CDKSubGraphHandler();
-
- if (queryMol == null) {
- mcs.set(rMol, pMol);
- } else {
- mcs.set(queryMol, pAC);
- }
-
- clearMaps();
-
- if (mcs.isSubgraph(isMatchBonds())) {
- firstSolution.putAll(mcs.getFirstMapping());
- allMCS.addAll(mcs.getAllMapping());
-
- firstAtomMCS.putAll(mcs.getFirstAtomMapping());
- allAtomMCS.addAll(mcs.getAllAtomMapping());
- }
-
- }
-
- private synchronized void mcsPlusAlgorithm() {
- MCSPlusHandler mcs = null;
- mcs = new MCSPlusHandler();
-
- if (queryMol == null) {
- mcs.set(rMol, pMol);
- } else {
- mcs.set(queryMol, pAC);
- }
- mcs.searchMCS(isMatchBonds());
-
- clearMaps();
-
- firstSolution.putAll(mcs.getFirstMapping());
- allMCS.addAll(mcs.getAllMapping());
-
- firstAtomMCS.putAll(mcs.getFirstAtomMapping());
- allAtomMCS.addAll(mcs.getAllAtomMapping());
- }
-
- private void vfLibMCS() {
- VFlibMCSHandler mcs = null;
- mcs = new VFlibMCSHandler();
- if (queryMol == null) {
- mcs.set(rMol, pMol);
- } else {
- mcs.set(queryMol, pAC);
- }
- mcs.searchMCS(isMatchBonds());
-
- clearMaps();
- firstSolution.putAll(mcs.getFirstMapping());
- allMCS.addAll(mcs.getAllMapping());
-
- firstAtomMCS.putAll(mcs.getFirstAtomMapping());
- allAtomMCS.addAll(mcs.getAllAtomMapping());
- }
-
- private void subStructureHandler() {
- VFlibSubStructureHandler subGraphTurboSearch = null;
- subGraphTurboSearch = new VFlibSubStructureHandler();
- if (queryMol == null) {
- subGraphTurboSearch.set(rMol, pMol);
- } else {
- subGraphTurboSearch.set(queryMol, pAC);
- }
- clearMaps();
- subGraph = subGraphTurboSearch.isSubgraph(isMatchBonds());
- if (subGraph) {
- firstSolution.putAll(subGraphTurboSearch.getFirstMapping());
- allMCS.addAll(subGraphTurboSearch.getAllMapping());
- firstAtomMCS.putAll(subGraphTurboSearch.getFirstAtomMapping());
- allAtomMCS.addAll(subGraphTurboSearch.getAllAtomMapping());
- }
- }
-
- private void turboSubStructureHandler() {
- VFlibTurboHandler subGraphTurboSearch = null;
- subGraphTurboSearch = new VFlibTurboHandler();
- if (queryMol == null) {
- subGraphTurboSearch.set(rMol, pMol);
- } else {
- subGraphTurboSearch.set(queryMol, pAC);
- }
- clearMaps();
- subGraph = subGraphTurboSearch.isSubgraph(isMatchBonds());
- if (subGraph) {
- firstSolution.putAll(subGraphTurboSearch.getFirstMapping());
- allMCS.addAll(subGraphTurboSearch.getAllMapping());
- firstAtomMCS.putAll(subGraphTurboSearch.getFirstAtomMapping());
- allAtomMCS.addAll(subGraphTurboSearch.getAllAtomMapping());
- }
- }
-
- private void singleMapping() {
- SingleMappingHandler mcs = null;
-
- mcs = new SingleMappingHandler(removeHydrogen);
- if (queryMol == null) {
- mcs.set(rMol, pMol);
- } else {
- mcs.set(queryMol, pAC);
- }
- mcs.searchMCS(isMatchBonds());
-
- clearMaps();
- firstSolution.putAll(mcs.getFirstMapping());
- allMCS.addAll(mcs.getAllMapping());
-
- firstAtomMCS.putAll(mcs.getFirstAtomMapping());
- allAtomMCS.addAll(mcs.getAllAtomMapping());
- }
-
- private int getHCount(IAtomContainer molecule) {
- int count = 0;
- for (IAtom atom : molecule.atoms()) {
- if (atom.getSymbol().equalsIgnoreCase("H")) {
- ++count;
- }
- }
- return count;
- }
-
- private boolean isBondMatch(IAtomContainer reactant, IAtomContainer product) {
- int counter = 0;
- Object[] ketSet = firstAtomMCS.keySet().toArray();
- for (int i = 0; i < ketSet.length; i++) {
- for (int j = i + 1; j < ketSet.length; j++) {
- IAtom indexI = (IAtom) ketSet[i];
- IAtom indexJ = (IAtom) ketSet[j];
- IBond rBond = reactant.getBond(indexI, indexJ);
- if (rBond != null) {
- counter++;
- }
- }
- }
-
- Object[] valueSet = firstAtomMCS.values().toArray();
- for (int i = 0; i < valueSet.length; i++) {
- for (int j = i + 1; j < valueSet.length; j++) {
- IAtom indexI = (IAtom) valueSet[i];
- IAtom indexJ = (IAtom) valueSet[j];
- IBond pBond = product.getBond(indexI, indexJ);
- if (pBond != null) {
- counter--;
- }
- }
- }
- return counter == 0 ? true : false;
- }
-
- private void defaultMCSAlgorithm() {
- try {
- if (isMatchBonds()) {
- cdkMCSAlgorithm();
- if (getFirstMapping() == null || isTimeOut()) {
- vfLibMCS();
- }
- } else {
- mcsPlusAlgorithm();
- if (getFirstMapping() == null || isTimeOut()) {
- vfLibMCS();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void subStructureAlgorithm(int rBondCount, int pBondCount) {
- try {
- if (rBondCount > 0 && pBondCount > 0) {
- cdkSubgraphAlgorithm();
- if (getFirstMapping() == null || isTimeOut()) {
- subStructureHandler();
- }
- } else {
- singleMapping();
- }
- } catch (Exception e) {
- e.getMessage();
- }
- }
-
- private void turboSubStructureAlgorithm(int rBondCount, int pBondCount) {
- try {
- if (rBondCount > 0 && pBondCount > 0) {
- turboSubStructureHandler();
- } else {
- singleMapping();
- }
- } catch (Exception e) {
- e.getMessage();
- }
- }
-
- private void vfLibMCSAlgorithm() {
- vfLibMCS();
- }
-
- private void setTime(boolean bondTypeFlag) {
- if (bondTypeFlag) {
- TimeOut tmo = TimeOut.getInstance();
- tmo.setTimeOut(getBondSensitiveTimeOut());
- } else {
- TimeOut tmo = TimeOut.getInstance();
- tmo.setTimeOut(getBondInSensitiveTimeOut());
- }
- }
-
- public boolean isTimeOut() {
- return TimeOut.getInstance().isTimeOutFlag();
- }
-
- public void resetTimeOut() {
- TimeOut.getInstance().setTimeOutFlag(false);
- }
-
- private void clearMaps() {
- this.firstSolution.clear();
- this.allMCS.clear();
- this.allAtomMCS.clear();
- this.firstAtomMCS.clear();
- }
-
- /**
- *
- * @param reactant
- * @param product
- * @param removeHydrogen
- *
- */
- private void init(MolHandler reactant, MolHandler product) throws CDKException {
- this.rMol = reactant;
- this.pMol = product;
- mcsBuilder(reactant, product);
- }
-
- /**
- *
- * @param reactant
- * @param product
- *
- */
- @Override
- public void init(IQueryAtomContainer reactant, IAtomContainer product) throws CDKException {
- this.queryMol = reactant;
- this.pAC = product;
- mcsBuilder(queryMol, pAC);
- }
-
- /**
- * {@inheritDoc}
- * @param reactant
- * @param product
- */
- @Override
- @TestMethod("testInit_3args_2")
- public void init(IAtomContainer reactant, IAtomContainer product, boolean removeHydrogen, boolean cleanAndConfigureMolecule) throws CDKException {
- this.removeHydrogen = removeHydrogen;
- init(new MolHandler(reactant, removeHydrogen, cleanAndConfigureMolecule),
- new MolHandler(product, removeHydrogen, cleanAndConfigureMolecule));
- }
-
- /**
- * Initialize the query and targetAtomCount mol via mol files
- * @param sourceMolFileName source mol file name
- * @param targetMolFileName target mol file name
- * @param removeHydrogen set true to make hydrogens implicit before search
- * @param cleanAndConfigureMolecule eg: percieveAtomTypesAndConfigureAtoms, detect aromaticity etc
- * @throws CDKException
- */
- @TestMethod("testInit_3args_3")
- public void init(String sourceMolFileName, String targetMolFileName, boolean removeHydrogen, boolean cleanAndConfigureMolecule) throws CDKException {
- this.removeHydrogen = removeHydrogen;
- init(new MolHandler(sourceMolFileName, cleanAndConfigureMolecule, removeHydrogen),
- new MolHandler(targetMolFileName, cleanAndConfigureMolecule, removeHydrogen));
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testSetChemFilters")
- public void setChemFilters(boolean stereoFilter, boolean fragmentFilter, boolean energyFilter) {
-
- if (firstAtomMCS != null) {
- ChemicalFilters chemFilter = new ChemicalFilters(allMCS, allAtomMCS, firstSolution, firstAtomMCS, getReactantMolecule(), getProductMolecule());
-
- if (stereoFilter && firstAtomMCS.size() > 1) {
- try {
- chemFilter.sortResultsByStereoAndBondMatch();
- this.stereoScore = chemFilter.getStereoMatches();
- } catch (CDKException ex) {
- Logger.error(Level.SEVERE, null, ex);
- }
- }
- if (fragmentFilter) {
- chemFilter.sortResultsByFragments();
- this.fragmentSize = chemFilter.getSortedFragment();
- }
- if (energyFilter) {
- try {
- chemFilter.sortResultsByEnergies();
- this.bEnergies = chemFilter.getSortedEnergy();
- } catch (CDKException ex) {
- Logger.error(Level.SEVERE, null, ex);
- }
- }
- }
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetFragmentSize")
- public synchronized Integer getFragmentSize(int Key) {
- return (fragmentSize != null && !fragmentSize.isEmpty())
- ? fragmentSize.get(Key) : null;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetStereoScore")
- public synchronized Integer getStereoScore(int Key) {
- return (stereoScore != null && !stereoScore.isEmpty()) ? stereoScore.get(Key).intValue() : null;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetEnergyScore")
- public synchronized Double getEnergyScore(int Key) {
- return (bEnergies != null && !bEnergies.isEmpty()) ? bEnergies.get(Key) : null;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetFirstMapping")
- public synchronized Map<Integer, Integer> getFirstMapping() {
- return firstSolution.isEmpty() ? null : firstSolution;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetAllMapping")
- public synchronized List<Map<Integer, Integer>> getAllMapping() {
- return allMCS.isEmpty() ? null : allMCS;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetFirstAtomMapping")
- public synchronized Map<IAtom, IAtom> getFirstAtomMapping() {
- return firstAtomMCS.isEmpty() ? null : firstAtomMCS;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetAllAtomMapping")
- public synchronized List<Map<IAtom, IAtom>> getAllAtomMapping() {
- return allAtomMCS.isEmpty() ? null : allAtomMCS;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetreactantMolecule")
- public IAtomContainer getReactantMolecule() {
- return queryMol == null ? rMol.getMolecule() : queryMol;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetproductMolecule")
- public IAtomContainer getProductMolecule() {
- return pAC == null ? pMol.getMolecule() : pAC;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetTanimotoSimilarity")
- public double getTanimotoSimilarity() throws IOException {
- double tanimoto = getTanimotoAtomSimilarity() + getTanimotoBondSimilarity();
- if (tanimoto > 0 && getReactantMolecule().getBondCount() > 0
- && getProductMolecule().getBondCount() > 0) {
- tanimoto /= 2;
- }
- return tanimoto;
- }
-
- public double getTanimotoAtomSimilarity() throws IOException {
- int decimalPlaces = 4;
- int rAtomCount = 0;
- int pAtomCount = 0;
- double tanimotoAtom = 0.0;
-
- if (getFirstMapping() != null && !getFirstMapping().isEmpty()) {
- if (!removeHydrogen) {
- rAtomCount = getReactantMolecule().getAtomCount();
- pAtomCount = getProductMolecule().getAtomCount();
- } else {
- rAtomCount = getReactantMolecule().getAtomCount() - getHCount(getReactantMolecule());
- pAtomCount = getProductMolecule().getAtomCount() - getHCount(getProductMolecule());
- }
- double matchCount = getFirstMapping().size();
- tanimotoAtom = (matchCount) / (rAtomCount + pAtomCount - matchCount);
- BigDecimal tan = new BigDecimal(tanimotoAtom);
- tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);
- tanimotoAtom = tan.doubleValue();
- }
- return tanimotoAtom;
- }
-
- public double getTanimotoBondSimilarity() throws IOException {
- int decimalPlaces = 4;
- int rBondCount = 0;
- int pBondCount = 0;
- double tanimotoAtom = 0.0;
-
- if (getFirstBondMap() != null && !getFirstBondMap().isEmpty()) {
- rBondCount = getReactantMolecule().getBondCount();
- pBondCount = getProductMolecule().getBondCount();
-
- double matchCount = getFirstBondMap().size();
- tanimotoAtom = (matchCount) / (rBondCount + pBondCount - matchCount);
- BigDecimal tan = new BigDecimal(tanimotoAtom);
- tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);
- tanimotoAtom = tan.doubleValue();
- }
- return tanimotoAtom;
- }
-
- /** {@inheritDoc}
- *
- */
- @Override
- @TestMethod("testIsStereoMisMatch")
- public boolean isStereoMisMatch() {
- boolean flag = false;
- IAtomContainer reactant = getReactantMolecule();
- IAtomContainer product = getProductMolecule();
- int Score = 0;
-
- for (Map.Entry<IAtom, IAtom> mappingI : firstAtomMCS.entrySet()) {
- IAtom indexI = mappingI.getKey();
- IAtom indexJ = mappingI.getValue();
- for (Map.Entry<IAtom, IAtom> mappingJ : firstAtomMCS.entrySet()) {
-
- IAtom indexIPlus = mappingJ.getKey();
- IAtom indexJPlus = mappingJ.getValue();
- if (!indexI.equals(indexIPlus) && !indexJ.equals(indexJPlus)) {
-
- IAtom sourceAtom1 = indexI;
- IAtom sourceAtom2 = indexIPlus;
-
- IBond rBond = reactant.getBond(sourceAtom1, sourceAtom2);
-
- IAtom targetAtom1 = indexJ;
- IAtom targetAtom2 = indexJPlus;
- IBond pBond = product.getBond(targetAtom1, targetAtom2);
-
- if ((rBond != null && pBond != null) && (rBond.getStereo() != pBond.getStereo())) {
- Score++;
- }
- }
- }
- }
- if (Score > 0) {
- flag = true;
- }
- return flag;
- }
-
- /** {@inheritDoc}
- *
- */
- @Override
- @TestMethod("testIsSubgraph")
- public boolean isSubgraph() {
-
- IAtomContainer reactant = getReactantMolecule();
- IAtomContainer product = getProductMolecule();
-
- float mappingSize = 0;
- if (firstSolution != null && !firstSolution.isEmpty()) {
- mappingSize = firstSolution.size();
- } else {
- return false;
- }
- int sourceAtomCount = reactant.getAtomCount();
- int targetAtomCount = product.getAtomCount();
- if (removeHydrogen) {
- sourceAtomCount -= getHCount(reactant);
- targetAtomCount -= getHCount(product);
- }
- if (mappingSize == sourceAtomCount && mappingSize <= targetAtomCount) {
- if (!getFirstBondMap().isEmpty()
- && getFirstBondMap().size() == reactant.getBondCount()) {
- return true;
- } else if (mappingSize == 1) {
- return true;
- }
- }
- return false;
- }
-
- /** {@inheritDoc}
- */
- @Override
- @TestMethod("testGetEuclideanDistance")
- public double getEuclideanDistance() throws IOException {
- int decimalPlaces = 4;
- double source = 0;
- double target = 0;
- double euclidean = -1;
-
-
- if (getFirstMapping() != null || !getFirstMapping().isEmpty()) {
- if (!removeHydrogen) {
- source = getReactantMolecule().getAtomCount();
- target = getProductMolecule().getAtomCount();
- } else {
- source = getReactantMolecule().getAtomCount() - getHCount(getReactantMolecule());
- target = getProductMolecule().getAtomCount() - getHCount(getProductMolecule());
- }
- double common = getFirstMapping().size();
- euclidean = Math.sqrt(source + target - 2 * common);
- BigDecimal dist = new BigDecimal(euclidean);
- dist = dist.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);
- euclidean = dist.doubleValue();
- }
- return euclidean;
- }
-
- /**
- * {@inheritDoc}
- * @return the bondSensitiveTimeOut
- */
- @Override
- public double getBondSensitiveTimeOut() {
- return bondSensitiveTimeOut;
- }
-
- /**
- * {@inheritDoc}
- * @param bondSensitiveTimeOut the bond Sensitive Timeout in mins (default 0.10 min)
- */
- @Override
- public void setBondSensitiveTimeOut(double bondSensitiveTimeOut) {
- this.bondSensitiveTimeOut = bondSensitiveTimeOut;
- }
-
- /**
- * {@inheritDoc}
- * @return the bondInSensitiveTimeOut
- */
- @Override
- public double getBondInSensitiveTimeOut() {
- return bondInSensitiveTimeOut;
- }
-
- /**
- * {@inheritDoc}
- * @param bondInSensitiveTimeOut the bond insensitive Timeout in mins (default 0.15 min)
- */
- @Override
- public void setBondInSensitiveTimeOut(double bondInSensitiveTimeOut) {
- this.bondInSensitiveTimeOut = bondInSensitiveTimeOut;
- }
-
- /**
- * @return the matchBonds
- */
- public boolean isMatchBonds() {
- return matchBonds;
- }
-
- /**
- * @param matchBonds the matchBonds to set
- */
- public void setMatchBonds(boolean matchBonds) {
- this.matchBonds = matchBonds;
- }
-
- /**
- * @return the allBondMCS
- */
- public List<Map<IBond, IBond>> getAllBondMaps() {
- return allBondMCS;
- }
-
- /**
- * @param allBondMCS the allBondMCS to set
- */
- private void setAllBondMaps(List<Map<IBond, IBond>> allBondMCS) {
- this.allBondMCS = allBondMCS;
- }
-
- /**
- * @return the firstBondMCS
- */
- public Map<IBond, IBond> getFirstBondMap() {
- return firstBondMCS;
- }
-
- /**
- * @param firstBondMCS the firstBondMCS to set
- */
- private void setFirstBondMap(Map<IBond, IBond> firstBondMCS) {
- this.firstBondMCS = firstBondMCS;
- }
-}
39 src/main/org/openscience/cdk/smsd/algorithm/matchers/AtomMatcher.java
View
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-
-/**
- * Interface for the AtomMatcher (atoms) in graph.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-
-public interface AtomMatcher {
-
- boolean matches(IAtomContainer container, IAtom atom);
-}
39 src/main/org/openscience/cdk/smsd/algorithm/matchers/BondMatcher.java
View
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.interfaces.IBond;
-
-/**
- * Interface for the BondMatcher (bonds) in graph.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-
-public interface BondMatcher {
-
- boolean matches(IAtomContainer container, IBond atom);
-}
177 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultBondMatcher.java
View
@@ -1,177 +0,0 @@
-/* Copyright (C) 2009-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * MX Cheminformatics Tools for Java
- *
- * Copyright (c) 2007-2009 Metamolecular, LLC
- *
- * http://metamolecular.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.CDKConstants;
-import org.openscience.cdk.annotations.TestClass;
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.interfaces.IBond;
-import org.openscience.cdk.isomorphism.matchers.IQueryBond;
-
-/**
- * Checks if a bond is matching between query and target molecules.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-@TestClass("org.openscience.cdk.smsd.algorithm.vflib.VFLibTest")
-public class DefaultBondMatcher implements BondMatcher {
-
- static final long serialVersionUID = -7861469841127328812L;
- private IBond queryBond = null;
- private IQueryBond smartQueryBond = null;
- private int unsaturation = 0;
- private boolean shouldMatchBonds = false;
-
- /**
- * Constructor
- */
- public DefaultBondMatcher() {
- this.queryBond = null;
- this.smartQueryBond = null;
- this.unsaturation = -1;
- shouldMatchBonds = false;
- }
-
- /**
- * Constructor
- * @param queryMol query Molecule
- * @param queryBond query Molecule
- * @param shouldMatchBonds bond match flag
- */
- public DefaultBondMatcher(IAtomContainer queryMol, IBond queryBond, boolean shouldMatchBonds) {
- super();
- this.queryBond = queryBond;
- this.unsaturation = getUnsaturation(queryMol, this.queryBond);
- setBondMatchFlag(shouldMatchBonds);
- }
-
- /**
- * Constructor
- * @param queryBond query Molecule
- */
- public DefaultBondMatcher(IQueryBond queryBond) {
- super();
- this.smartQueryBond = queryBond;
- }
-
- /** {@inheritDoc}
- *
- * @param targetContainer target container
- * @param targetBond target bond
- * @return true if bonds match
- */
- public boolean matches(IAtomContainer targetContainer, IBond targetBond) {
- if (this.smartQueryBond != null && queryBond == null) {
- return smartQueryBond.matches(targetBond);
- } else {
- if (!isBondMatchFlag()) {
- return true;
- }
- if (isBondMatchFlag() && isBondTypeMatch(targetBond)) {
- return true;
- }
- if (isBondMatchFlag() && this.unsaturation == getUnsaturation(targetContainer, targetBond)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if a bond is matched between query and target
- * @param targetBond
- * @return
- */
- private boolean isBondTypeMatch(IBond targetBond) {
- int reactantBondType = queryBond.getOrder().numeric();
- int productBondType = targetBond.getOrder().numeric();
- if ((queryBond.getFlag(CDKConstants.ISAROMATIC) == targetBond.getFlag(CDKConstants.ISAROMATIC))
- && (reactantBondType == productBondType)) {
- return true;
- } else if (queryBond.getFlag(CDKConstants.ISAROMATIC) && targetBond.getFlag(CDKConstants.ISAROMATIC)) {
- return true;
- }
- return false;
- }
-
- private int getValency(IAtom atom) {
- return (atom.getValency() == null) ? 0 : atom.getValency().intValue();
- }
-
- private int getUnsaturation(IAtomContainer container, IBond bond) {
- return getUnsaturation(container, bond.getAtom(0)) + getUnsaturation(container, bond.getAtom(1));
- }
-
- private int getUnsaturation(IAtomContainer container, IAtom atom) {
- return getValency(atom) - (countNeighbors(container, atom) + countImplicitHydrogens(atom));
- }
-
- private int countNeighbors(IAtomContainer container, IAtom atom) {
- return container.getConnectedAtomsCount(atom);
- }
-
- private int countImplicitHydrogens(IAtom atom) {
- return (atom.getImplicitHydrogenCount() == null)
- ? 0 : atom.getImplicitHydrogenCount();
- }
-
- /**
- * @return the shouldMatchBonds
- */
- public boolean isBondMatchFlag() {
- return shouldMatchBonds;
- }
-
- /**
- * @param shouldMatchBonds the shouldMatchBonds to set
- */
- public final void setBondMatchFlag(boolean shouldMatchBonds) {
- this.shouldMatchBonds = shouldMatchBonds;
- }
-}
188 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultMCSPlusAtomMatcher.java
View
@@ -1,188 +0,0 @@
-/* Copyright (C) 2009-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * MX Cheminformatics Tools for Java
- *
- * Copyright (c) 2007-2009 Metamolecular, LLC
- *
- * http://metamolecular.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.annotations.TestClass;
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
-import org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer;
-
-/**
- * Checks if atom is matching between query and target molecules.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-@TestClass("org.openscience.cdk.smsd.algorithm.vflib.VFLibTest")
-public class DefaultMCSPlusAtomMatcher implements AtomMatcher {
-
- static final long serialVersionUID = -7861469841127327812L;
- private int maximumNeighbors;
- private String symbol = null;
- private IAtom qAtom = null;
- private IQueryAtom smartQueryAtom = null;
- private boolean shouldMatchBonds = false;
-
- /**
- * @return the shouldMatchBonds
- */
- public boolean isBondMatchFlag() {
- return shouldMatchBonds;
- }
-
- /**
- * @param shouldMatchBonds the shouldMatchBonds to set
- */
- public final void setBondMatchFlag(boolean shouldMatchBonds) {
- this.shouldMatchBonds = shouldMatchBonds;
- }
-
- /**
- * Constructor
- */
- public DefaultMCSPlusAtomMatcher() {
- this.qAtom = null;
- symbol = null;
- maximumNeighbors = -1;
- }
-
- /**
- * Constructor
- * @param queryContainer query atom container
- * @param atom query atom
- * @param shouldMatchBonds bond matching flag
- */
- public DefaultMCSPlusAtomMatcher(IAtomContainer queryContainer, IAtom atom, boolean shouldMatchBonds) {
- this();
- this.qAtom = atom;
- this.symbol = atom.getSymbol();
- setBondMatchFlag(shouldMatchBonds);
-
-// System.out.println("Atom " + atom.getSymbol());
-// System.out.println("MAX allowed " + maximumNeighbors);
- }
-
- /**
- * Constructor
- * @param smartQueryAtom query atom
- * @param container
- */
- public DefaultMCSPlusAtomMatcher(IQueryAtom smartQueryAtom, IQueryAtomContainer container) {
- this();
- this.smartQueryAtom = smartQueryAtom;
- this.symbol = smartQueryAtom.getSymbol();
- }
-
- /**
- * Constructor
- * @param queryContainer query atom container
- * @param template query atom
- * @param blockedPositions
- * @param shouldMatchBonds bond matching flag
- */
- public DefaultMCSPlusAtomMatcher(IAtomContainer queryContainer, IAtom template, int blockedPositions, boolean shouldMatchBonds) {
- this(queryContainer, template, shouldMatchBonds);
- this.maximumNeighbors = countImplicitHydrogens(template)
- + queryContainer.getConnectedAtomsCount(template)
- - blockedPositions;
- }
-
- /**
- *
- * @param maximum numbers of connected atoms allowed
- */
- public void setMaximumNeighbors(int maximum) {
- this.maximumNeighbors = maximum;
- }
-
- /**
- * @param symbol
- */
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- private boolean matchSymbol(IAtom atom) {
- if (symbol == null) {
- return false;
- }
- return symbol.equals(atom.getSymbol());
- }
-
- private boolean matchMaximumNeighbors(IAtomContainer targetContainer, IAtom targetAtom) {
- if (maximumNeighbors == -1 || !isBondMatchFlag()) {
- return true;
- }
-
- int maximumTargetNeighbors = targetContainer.getConnectedAtomsCount(targetAtom);
- return maximumTargetNeighbors >= maximumNeighbors;
- }
-
- private int countImplicitHydrogens(IAtom atom) {
- return (atom.getImplicitHydrogenCount() == null)
- ? 0 : atom.getImplicitHydrogenCount();
- }
-
- /** {@inheritDoc}
- */
- public boolean matches(IAtomContainer targetContainer, IAtom targetAtom) {
- if (smartQueryAtom != null && qAtom == null) {
- if (!smartQueryAtom.matches(targetAtom)) {
- return false;
- }
- } else {
- if (!matchSymbol(targetAtom)) {
- return false;
- }
- if (!matchMaximumNeighbors(targetContainer, targetAtom)) {
- return false;
- }
- }
- return true;
- }
-}
93 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultMatcher.java
View
@@ -1,93 +0,0 @@
-/* Copyright (C) 2009-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * MX Cheminformatics Tools for Java
- *
- * Copyright (c) 2007-2009 Metamolecular, LLC
- *
- * http://metamolecular.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.interfaces.IBond;
-
-/**
- * Checks if atom is matching between query and target molecules.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-public class DefaultMatcher {
-
- public static boolean isBondMatch(BondMatcher bondMatcher,
- IAtomContainer ac2,
- IBond bondA2,
- boolean shouldMatchBonds) {
-
- // ok, bonds match
- if (bondMatcher.matches(ac2, bondA2)) {
-// System.out.println("Bond Matched");
- return true;
- }
- return false;
-
- }
-
- public static boolean isAtomMatch(AtomMatcher atomMatcher1,
- AtomMatcher atomMatcher2,
- IAtomContainer ac2,
- IBond bondA2,
- boolean shouldMatchBonds) {
-
- // ok, atoms match
- if (atomMatcher1.matches(ac2, bondA2.getAtom(0)) && atomMatcher2.matches(ac2, bondA2.getAtom(1))) {
-// System.out.println("Atom Matched");
- return true;
- }
- // ok, atoms match
- if (atomMatcher1.matches(ac2, bondA2.getAtom(1)) && atomMatcher2.matches(ac2, bondA2.getAtom(0))) {
-// System.out.println("Atom Matched");
- return true;
- }
- return false;
- }
-
-}
177 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultRGraphAtomMatcher.java
View
@@ -1,177 +0,0 @@
-/* Copyright (C) 2009-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * MX Cheminformatics Tools for Java
- *
- * Copyright (c) 2007-2009 Metamolecular, LLC
- *
- * http://metamolecular.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.annotations.TestClass;
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
-
-/**
- * Checks if atom is matching between query and target molecules.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-@TestClass("org.openscience.cdk.smsd.algorithm.vflib.VFLibTest")
-public class DefaultRGraphAtomMatcher implements AtomMatcher {
-
- static final long serialVersionUID = -7861469841127327812L;
- private int maximumNeighbors;
- private String symbol = null;
- private IAtom qAtom = null;
- private boolean shouldMatchBonds = false;
-
- /**
- * @return the shouldMatchBonds
- */
- public boolean isBondMatchFlag() {
- return shouldMatchBonds;
- }
-
- /**
- * @param shouldMatchBonds the shouldMatchBonds to set
- */
- public final void setBondMatchFlag(boolean shouldMatchBonds) {
- this.shouldMatchBonds = shouldMatchBonds;
- }
-
- /**
- * Constructor
- */
- public DefaultRGraphAtomMatcher() {
- this.qAtom = null;
- symbol = null;
- maximumNeighbors = -1;
- }
-
- /**
- * Constructor
- * @param queryContainer query atom container
- * @param atom query atom
- * @param shouldMatchBonds bond matching flag
- */
- public DefaultRGraphAtomMatcher(IAtomContainer queryContainer, IAtom atom, boolean shouldMatchBonds) {
- this();
- this.qAtom = atom;
- this.symbol = atom.getSymbol();
- setBondMatchFlag(shouldMatchBonds);
- }
-
- /**
- * Constructor
- * @param queryContainer query atom container
- * @param template query atom
- * @param blockedPositions
- * @param shouldMatchBonds bond matching flag
- */
- public DefaultRGraphAtomMatcher(IAtomContainer queryContainer, IAtom template, int blockedPositions, boolean shouldMatchBonds) {
- this(queryContainer, template, shouldMatchBonds);
- this.maximumNeighbors = countSaturation(queryContainer, template) - blockedPositions;
- }
-
- /** {@inheritDoc}
- */
- public boolean matches(IAtomContainer targetContainer, IAtom targetAtom) {
- if (qAtom instanceof IQueryAtom) {
- if (!((IQueryAtom) qAtom).matches(targetAtom)) {
- return false;
- }
- } else if (!matchSymbol(targetAtom)) {
- return false;
- }
- if (!matchMaximumNeighbors(targetContainer, targetAtom)) {
- return false;
- }
- return true;
- }
-
- /**
- *
- * @param maximum numbers of connected atoms allowed
- */
- public void setMaximumNeighbors(int maximum) {
- this.maximumNeighbors = maximum;
- }
-
- /**
- * @param symbol
- */
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- private boolean matchSymbol(IAtom atom) {
- if (symbol == null) {
- return false;
- }
- return symbol.equals(atom.getSymbol());
- }
-
- private boolean matchMaximumNeighbors(IAtomContainer targetContainer, IAtom targetAtom) {
- if (maximumNeighbors == -1 || !isBondMatchFlag()) {
- return true;
- }
-
- int maximumTargetNeighbors = countSaturation(targetContainer, targetAtom);
- return maximumTargetNeighbors >= maximumNeighbors;
- }
-
- private int countImplicitHydrogens(IAtom atom) {
- return (atom.getImplicitHydrogenCount() == null)
- ? 0 : atom.getImplicitHydrogenCount();
- }
-
- private int countSaturation(IAtomContainer container, IAtom atom) {
- return countNeighbors(container, atom) + countImplicitHydrogens(atom);
- }
-
- private int countNeighbors(IAtomContainer container, IAtom atom) {
- return container.getConnectedAtomsCount(atom);
- }
-}
-
333 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultVFAtomMatcher.java
View
@@ -1,333 +0,0 @@
- /* Copyright (C) 2009-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * MX Cheminformatics Tools for Java
- *
- * Copyright (c) 2007-2009 Metamolecular, LLC
- *
- * http://metamolecular.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.annotations.TestClass;
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
-import org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer;
-import org.openscience.cdk.smsd.algorithm.vflib.builder.TargetProperties;
-
-/**
- * Checks if atom is matching between query and target molecules.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-@TestClass("org.openscience.cdk.smsd.algorithm.vflib.VFLibTest")
-public class DefaultVFAtomMatcher implements VFAtomMatcher {
-
- static final long serialVersionUID = -7861469841127327812L;
- private int maximumNeighbors;
- private String symbol = null;
- private IAtom qAtom = null;
- private IQueryAtom smartQueryAtom = null;
- private boolean shouldMatchBonds = false;
-
- /**
- * @return the shouldMatchBonds
- */
- public boolean isBondMatchFlag() {
- return shouldMatchBonds;
- }
-
- /**
- * @param shouldMatchBonds the shouldMatchBonds to set
- */
- public final void setBondMatchFlag(boolean shouldMatchBonds) {
- this.shouldMatchBonds = shouldMatchBonds;
- }
-
- /**
- * Constructor
- */
- public DefaultVFAtomMatcher() {
- this.qAtom = null;
- symbol = null;
- maximumNeighbors = -1;
- }
-
- /**
- * Constructor
- * @param queryContainer query atom container
- * @param atom query atom
- * @param shouldMatchBonds bond matching flag
- */
- public DefaultVFAtomMatcher(IAtomContainer queryContainer, IAtom atom, boolean shouldMatchBonds) {
- this();
- this.qAtom = atom;
- this.symbol = atom.getSymbol();
- setBondMatchFlag(shouldMatchBonds);
-
-// System.out.println("Atom " + atom.getSymbol());
-// System.out.println("MAX allowed " + maximumNeighbors);
- }
-
- /**
- * Constructor
- * @param smartQueryAtom query atom
- * @param container
- */
- public DefaultVFAtomMatcher(IQueryAtom smartQueryAtom, IQueryAtomContainer container) {
- this();
- this.smartQueryAtom = smartQueryAtom;
- this.symbol = smartQueryAtom.getSymbol();
- }
-
- /**
- * Constructor
- * @param queryContainer query atom container
- * @param template query atom
- * @param blockedPositions
- * @param shouldMatchBonds bond matching flag
- */
- public DefaultVFAtomMatcher(IAtomContainer queryContainer, IAtom template, int blockedPositions, boolean shouldMatchBonds) {
- this(queryContainer, template, shouldMatchBonds);
- this.maximumNeighbors = countImplicitHydrogens(template)
- + queryContainer.getConnectedAtomsCount(template)
- - blockedPositions;
- }
-
- /**
- *
- * @param maximum numbers of connected atoms allowed
- */
- public void setMaximumNeighbors(int maximum) {
- this.maximumNeighbors = maximum;
- }
-
- /**
- * @param symbol
- */
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- private boolean matchSymbol(IAtom atom) {
- if (symbol == null) {
- return false;
- }
- return symbol.equals(atom.getSymbol());
- }
-
- private boolean matchMaximumNeighbors(TargetProperties targetContainer, IAtom targetAtom) {
- if (maximumNeighbors == -1 || !isBondMatchFlag()) {
- return true;
- }
-
- int maximumTargetNeighbors = targetContainer.countNeighbors(targetAtom);
- return maximumTargetNeighbors <= maximumNeighbors;
- }
-
- private int countImplicitHydrogens(IAtom atom) {
- return (atom.getImplicitHydrogenCount() == null)
- ? 0 : atom.getImplicitHydrogenCount();
- }
-
- /** {@inheritDoc}
- */
- public boolean matches(TargetProperties targetContainer, IAtom targetAtom) {
- if (smartQueryAtom != null && qAtom == null) {
- if (!smartQueryAtom.matches(targetAtom)) {
- return false;
- }
- } else {
- if (!matchSymbol(targetAtom)) {
- return false;
- }
- if (!matchMaximumNeighbors(targetContainer, targetAtom)) {
- return false;
- }
- }
- return true;
- }
-}
-//
-// private String symbol;
-// private int maximumNeighbors;
-// private int minimumNeighbors;
-// private int minimumValence;
-// private int maximumValence;
-//
-// public AtomMatcher() {
-// symbol = null;
-// maximumNeighbors = -1;
-// minimumNeighbors = -1;
-// minimumValence = -1;
-// maximumValence = -1;
-// }
-//
-// public AtomMatcher(IAtom atom) {
-// this();
-//
-// this.symbol = atom.getSymbol();
-// this.minimumNeighbors = atom.getFormalNeighbourCount();
-// Integer hCount = atom.getImplicitHydrogenCount();
-// if (hCount != null) {
-// this.minimumValence = atom.getFormalNeighbourCount() + atom.getImplicitHydrogenCount();
-// } else {
-// this.minimumValence = atom.getFormalNeighbourCount();
-// }
-//
-//// System.out.println("symbol:" + symbol);
-//// System.out.println("minimumNeighbors:" + minimumNeighbors);
-//// System.out.println("minimumValence:" + minimumValence);
-// }
-//
-// /**
-// *
-// * @param atom
-// * @return
-// */
-//
-// public boolean matches(IAtom atom) {
-// if (!matchSymbol(atom)) {
-// return false;
-// }
-//
-// if (!matchMaximumNeighbors(atom)) {
-// return false;
-// }
-//
-// if (!matchMinimumNeighbors(atom)) {
-// return false;
-// }
-//
-// if (!matchMinimumValence(atom)) {
-// return false;
-// }
-//
-// if (!matchMaximumValence(atom)) {
-// return false;
-// }
-//
-// return true;
-// }
-//
-// public void setMinimumValence(int minimum) {
-// if (minimum > maximumValence && maximumValence != -1) {
-// throw new IllegalStateException("Minimum " + minimum + " exceeds maximum");
-// }
-// this.minimumValence = minimum;
-// }
-//
-// public void setMaximumValence(int maximum) {
-// if (maximum < minimumValence) {
-// throw new IllegalStateException("Maximum " + maximum + " less than minimum");
-// }
-// this.maximumValence = maximum;
-// }
-//
-// public void setMaximumNeighbors(int maximum) {
-// if (maximum < minimumNeighbors) {
-// throw new IllegalStateException("Maximum " + maximum + " exceeds minimum " + minimumNeighbors);
-// }
-//
-// this.maximumNeighbors = maximum;
-// }
-//
-// public void setMinimumNeighbors(int minimum) {
-// if (minimum > maximumNeighbors && maximumNeighbors != -1) {
-// throw new IllegalStateException("Minimum " + minimum + " exceeds maximum " + maximumNeighbors);
-// }
-//
-// this.minimumNeighbors = minimum;
-// }
-//
-// public void setSymbol(String symbol) {
-// this.symbol = symbol;
-// }
-//
-// private boolean matchSymbol(IAtom atom) {
-// if (symbol == null) {
-// return true;
-// }
-//
-// return symbol.equalsIgnoreCase(atom.getSymbol());
-// }
-//
-// private boolean matchMaximumNeighbors(IAtom atom) {
-// if (maximumNeighbors == -1) {
-// return true;
-// }
-//
-// return atom.getFormalNeighbourCount() <= maximumNeighbors;
-// }
-//
-// private boolean matchMinimumNeighbors(IAtom atom) {
-// if (minimumNeighbors == -1) {
-// return true;
-// }
-//
-// return atom.getFormalNeighbourCount() >= minimumNeighbors;
-// }
-//
-// private boolean matchMinimumValence(IAtom atom) {
-// if (minimumValence == -1) {
-// return true;
-// }
-//
-// Integer hCount = atom.getImplicitHydrogenCount();
-// if (hCount != null) {
-// return atom.getFormalNeighbourCount() + hCount >= minimumValence;
-// } else {
-// return atom.getFormalNeighbourCount() >= minimumValence;
-// }
-//
-// }
-//
-// private boolean matchMaximumValence(IAtom atom) {
-// if (maximumValence == -1) {
-// return true;
-// }
-//
-// return atom.getFormalNeighbourCount() + atom.getImplicitHydrogenCount() <= maximumValence;
-// }
-//}
-//
-
188 src/main/org/openscience/cdk/smsd/algorithm/matchers/DefaultVFBondMatcher.java
View
@@ -1,188 +0,0 @@
-/* Copyright (C) 2009-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * MX Cheminformatics Tools for Java
- *
- * Copyright (c) 2007-2009 Metamolecular, LLC
- *
- * http://metamolecular.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.CDKConstants;
-import org.openscience.cdk.annotations.TestClass;
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.interfaces.IBond;
-import org.openscience.cdk.isomorphism.matchers.IQueryBond;
-import org.openscience.cdk.smsd.algorithm.vflib.builder.TargetProperties;
-
-/**
- * Checks if a bond is matching between query and target molecules.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-@TestClass("org.openscience.cdk.smsd.algorithm.vflib.VFLibTest")
-public class DefaultVFBondMatcher implements VFBondMatcher {
-
- static final long serialVersionUID = -7861469841127328812L;
- private IBond queryBond = null;
- private int unsaturation = 0;
- private boolean shouldMatchBonds;
- private IQueryBond smartQueryBond = null;
-
- /**
- * Bond type flag
- */
- /**
- * Constructor
- */
- public DefaultVFBondMatcher() {
- this.queryBond = null;
- this.unsaturation = -1;
- shouldMatchBonds = false;
- }
-
- /**
- * Constructor
- * @param queryMol query Molecule
- * @param queryBond query Molecule
- * @param shouldMatchBonds bond match flag
- */
- public DefaultVFBondMatcher(IAtomContainer queryMol, IBond queryBond, boolean shouldMatchBonds) {
- super();
- this.queryBond = queryBond;
- this.unsaturation = getUnsaturation(queryMol, this.queryBond);
- setBondMatchFlag(shouldMatchBonds);
- }
-
- /**
- * Constructor
- * @param queryBond query Molecule
- */
- public DefaultVFBondMatcher(IQueryBond queryBond) {
- super();
- this.smartQueryBond = queryBond;
- }
-
- /** {@inheritDoc}
- *
- * @param targetConatiner target container
- * @param targetBond target bond
- * @return true if bonds match
- */
- public boolean matches(TargetProperties targetConatiner, IBond targetBond) {
- if (this.smartQueryBond != null) {
- return smartQueryBond.matches(targetBond);
- } else {
- if (!isBondMatchFlag()) {
- return true;
- }
- if (isBondMatchFlag() && isBondTypeMatch(targetBond)) {
- return true;
- }
- if (isBondMatchFlag() && this.unsaturation == getUnsaturation(targetConatiner, targetBond)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if a bond is matched between query and target
- * @param targetBond
- * @return
- */
- private boolean isBondTypeMatch(IBond targetBond) {
- int reactantBondType = queryBond.getOrder().numeric();
- int productBondType = targetBond.getOrder().numeric();
- if ((queryBond.getFlag(CDKConstants.ISAROMATIC) == targetBond.getFlag(CDKConstants.ISAROMATIC))
- && (reactantBondType == productBondType)) {
- return true;
- } else if (queryBond.getFlag(CDKConstants.ISAROMATIC) && targetBond.getFlag(CDKConstants.ISAROMATIC)) {
- return true;
- }
- return false;
- }
-
- private int getUnsaturation(TargetProperties container, IBond bond) {
- return getUnsaturation(container, bond.getAtom(0)) + getUnsaturation(container, bond.getAtom(1));
- }
-
- private int getUnsaturation(TargetProperties container, IAtom atom) {
- return getValency(atom) - container.countNeighbors(atom);
- }
-
- private int getValency(IAtom atom) {
- return (atom.getValency() == null) ? 0 : atom.getValency().intValue();
- }
-
- private int getUnsaturation(IAtomContainer container, IBond bond) {
- return getUnsaturation(container, bond.getAtom(0)) + getUnsaturation(container, bond.getAtom(1));
- }
-
- private int getUnsaturation(IAtomContainer container, IAtom atom) {
- return getValency(atom) - (countNeighbors(container, atom) + countImplicitHydrogens(atom));
- }
-
- private int countNeighbors(IAtomContainer container, IAtom atom) {
- return container.getConnectedAtomsCount(atom);
- }
-
- private int countImplicitHydrogens(IAtom atom) {
- return (atom.getImplicitHydrogenCount() == null)
- ? 0 : atom.getImplicitHydrogenCount();
- }
-
- /**
- * @return the shouldMatchBonds
- */
- public boolean isBondMatchFlag() {
- return shouldMatchBonds;
- }
-
- /**
- * @param shouldMatchBonds the shouldMatchBonds to set
- */
- public final void setBondMatchFlag(boolean shouldMatchBonds) {
- this.shouldMatchBonds = shouldMatchBonds;
- }
-}
39 src/main/org/openscience/cdk/smsd/algorithm/matchers/VFAtomMatcher.java
View
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.smsd.algorithm.vflib.builder.TargetProperties;
-
-/**
- * Interface for the AtomMatcher (atoms) in graph.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-
-public interface VFAtomMatcher {
-
- boolean matches(TargetProperties container, IAtom atom);
-}
39 src/main/org/openscience/cdk/smsd/algorithm/matchers/VFBondMatcher.java
View
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006-2010 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-package org.openscience.cdk.smsd.algorithm.matchers;
-
-import org.openscience.cdk.interfaces.IBond;
-import org.openscience.cdk.smsd.algorithm.vflib.builder.TargetProperties;
-
-/**
- * Interface for the BondMatcher (bonds) in graph.
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-
-public interface VFBondMatcher {
-
- boolean matches(TargetProperties container, IBond atom);
-}
1,014 src/main/org/openscience/cdk/smsd/algorithm/mcgregor/McGregor.java
View
@@ -1,1014 +0,0 @@
-
-/* Copyright (C) 2005-2006 Markus Leber
- * 2006-2009 Syed Asad Rahman <asad@ebi.ac.uk>
- *
- * Contact: cdk-devel@lists.sourceforge.net
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- * All we ask is that proper credit is given for our work, which includes
- * - but is not limited to - adding the above copyright notice to the beginning
- * of your source code files, and to any copyright notice that you may distribute
- * with programs based on this work.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-package org.openscience.cdk.smsd.algorithm.mcgregor;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import org.openscience.cdk.annotations.TestClass;
-import org.openscience.cdk.interfaces.IAtom;
-import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.interfaces.IBond;
-import org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer;
-import org.openscience.cdk.smsd.helper.BinaryTree;
-
-/**
- * Class which reports MCS solutions based on the McGregor algorithm
- * published in 1982.
- *
- * <p>The SMSD algorithm is described in this paper.
- * <font color="#FF0000">please refer Rahman <i>et.al. 2009</i></font>
- * {@cdk.cite SMSD2009}.
- * </p>
- *
- * @cdk.module smsd
- * @cdk.githash
- * @author Syed Asad Rahman <asad@ebi.ac.uk>
- */
-@TestClass("org.openscience.cdk.smsd.algorithm.mcgregor.McGregorTest")
-public final class McGregor {
-
- private IAtomContainer source = null;
- private IAtomContainer target = null;
- private BinaryTree last = null;
- private BinaryTree first = null;
- private Stack<List<Integer>> bestARCS = null;
- private List<Integer> modifiedARCS = null;
- private int bestarcsleft = 0;
- private int globalMCSSize = 0;
- private List<List<Integer>> mappings = null;
- /*This should be more or equal to all the atom types*/
- private static final String[] SIGNS = {
- "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12",
- "$13", "$15", "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", "$24",
- "$25", "$26", "$27", "$28", "$29", "$30", "$31", "$32", "$33", "$34", "$35",
- "$36", "$37", "$38", "$39", "$40", "$41", "$42", "$43", "$44", "$45", "$46",
- "$47", "$48", "$49", "$50", "$51", "$52", "$53", "$54", "$55"
- };
- private boolean newMatrix = false;
- private boolean bondMatch = false;
-
- /**
- * Constructor for the McGregor algorithm.
- * @param source
- * @param target
- * @param _mappings
- * @param shouldMatchBonds
- */
- public McGregor(IAtomContainer source, IAtomContainer target, List<List<Integer>> _mappings, boolean shouldMatchBonds) {
-
- setBondMatch(shouldMatchBonds);
- this.source = source;
- this.target = target;
- this.mappings = _mappings;
- this.bestarcsleft = 0;
-
- if (!_mappings.isEmpty()) {
- this.globalMCSSize = _mappings.get(0).size();
- } else {
- this.globalMCSSize = 0;
- }
- this.modifiedARCS = new ArrayList<Integer>();
- this.bestARCS = new Stack<List<Integer>>();
- this.newMatrix = false;
- }
-
- /**
- * Constructor for the McGregor algorithm.
- * @param source
- * @param target
- * @param _mappings
- */
- public McGregor(IQueryAtomContainer source, IAtomContainer target, List<List<Integer>> _mappings) {
-
- setBondMatch(true);
- this.source = source;
- this.target = target;
- this.mappings = _mappings;
- this.bestarcsleft = 0;
-
- if (!_mappings.isEmpty()) {
- this.globalMCSSize = _mappings.get(0).size();
- } else {
- this.globalMCSSize = 0;
- }
- this.modifiedARCS = new ArrayList<Integer>();
- this.bestARCS = new Stack<List<Integer>>();
- this.newMatrix = false;
- }
-
- /**
- * Start McGregor search and extend the mappings if possible.
- * @param largestMappingSize
- * @param present_Mapping
- * @throws IOException
- */
- public void startMcGregorIteration(int largestMappingSize, Map<Integer, Integer> present_Mapping) throws IOException {
-
- this.globalMCSSize = (largestMappingSize / 2);
- List<String> c_tab1_copy = McGregorChecks.generateCTabCopy(source);
- List<String> c_tab2_copy = McGregorChecks.generateCTabCopy(target);
-
-
- //find mapped atoms of both molecules and store these in mappedAtoms
- List<Integer> mapped_atoms = new ArrayList<Integer>();
-// System.out.println("\nMapped Atoms");
- for (Map.Entry<Integer, Integer> map : present_Mapping.entrySet()) {
-// System.out.println("i:" + map.getKey() + " j:" + map.getValue());
- mapped_atoms.add(map.getKey());
- mapped_atoms.add(map.getValue());
- }
- int mapping_size = present_Mapping.size();
-
-
- List<Integer> i_bond_neighborsA = new ArrayList<Integer>();
- List<String> c_bond_neighborsA = new ArrayList<String>();
-
- List<Integer> i_bond_setA = new ArrayList<Integer>();
- List<String> c_bond_setA = new ArrayList<String>();
-
- List<Integer> i_bond_neighborsB = new ArrayList<Integer>();
- List<Integer> i_bond_setB = new ArrayList<Integer>();
- List<String> c_bond_neighborsB = new ArrayList<String>();
- List<String> c_bond_setB = new ArrayList<String>();
-
- //find unmapped atoms of molecule A