Class Isomorphism

  • All Implemented Interfaces:
    Serializable

    @Deprecated
    public final class Isomorphism
    extends AbstractMCS
    implements Serializable
    Deprecated.
    A more recent version of SMSD is available at http://github.com/asad/smsd

    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.

    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

    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.

    If you are using Isomorphism, please cite Rahman et.al. 2009 [Rahman, S.A. et. al.. Journal of Cheminformatics. 2009. 1]. The Isomorphism algorithm is described in this paper.

    An example for Substructure search:

    
      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("");
      }
      

    An example for MCS search:

    
      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("");
      
    Author:
    Syed Asad Rahman <asad@ebi.ac.uk>
    See Also:
    Serialized Form
    Source code:
    main
    Belongs to CDK module:
    smsd
    Requires:
    java1.5+
    • Constructor Detail

      • Isomorphism

        public Isomorphism​(Algorithm algorithmType,
                           boolean bondTypeFlag)
        Deprecated.
        This is the algorithm factory and entry port for all the MCS algorithm in the Isomorphism supported algorithm Algorithm types:
        1. 0: Default,
        2. 1: MCSPlus,
        3. 2: VFLibMCS,
        4. 3: CDKMCS,
        5. 4: SubStructure
        Parameters:
        algorithmType - Algorithm
        bondTypeFlag -
    • Method Detail

      • makeBondMapsOfAtomMaps

        public static List<Map<IBond,​IBond>> makeBondMapsOfAtomMaps​(IAtomContainer ac1,
                                                                          IAtomContainer ac2,
                                                                          List<Map<IAtom,​IAtom>> mappings)
        Deprecated.
        Returns bond maps between source and target molecules based on the atoms
        Parameters:
        ac1 - source molecule
        ac2 - target molecule
        mappings - mappings between source and target molecule atoms
        Returns:
        bond maps between source and target molecules based on the atoms
      • makeBondMapOfAtomMap

        public static Map<IBond,​IBond> makeBondMapOfAtomMap​(IAtomContainer ac1,
                                                                  IAtomContainer ac2,
                                                                  Map<IAtom,​IAtom> mapping)
        Deprecated.
        Returns bond map between source and target molecules based on the atoms
        Parameters:
        ac1 - source molecule
        ac2 - target molecule
        mapping - mappings between source and target molecule atoms
        Returns:
        bond map between source and target molecules based on the atoms
      • isTimeOut

        public boolean isTimeOut()
        Deprecated.
      • resetTimeOut

        public void resetTimeOut()
        Deprecated.
      • init

        public void init​(IQueryAtomContainer reactant,
                         IAtomContainer product)
                  throws CDKException
        Deprecated.
        Description copied from class: AbstractMCS
        initialize query and target molecules. Note: Here its assumed that hydrogens are implicit and user has called these two methods percieveAtomTypesAndConfigureAtoms and CDKAromicityDetector before initializing calling this method.
        Specified by:
        init in class AbstractMCS
        Parameters:
        reactant -
        product -
        Throws:
        CDKException
      • init

        public void init​(IAtomContainer reactant,
                         IAtomContainer product,
                         boolean removeHydrogen,
                         boolean cleanAndConfigureMolecule)
                  throws CDKException
        Deprecated.
        initialize query and target molecules.
        Specified by:
        init in class AbstractMCS
        Parameters:
        reactant -
        product -
        removeHydrogen - true if remove H (implicit) before mapping
        cleanAndConfigureMolecule - eg: percieveAtomTypesAndConfigureAtoms, detect aromaticity etc
        Throws:
        CDKException
      • init

        public void init​(String sourceMolFileName,
                         String targetMolFileName,
                         boolean removeHydrogen,
                         boolean cleanAndConfigureMolecule)
                  throws CDKException
        Deprecated.
        Initialize the query and targetAtomCount mol via mol files
        Parameters:
        sourceMolFileName - source mol file name
        targetMolFileName - target mol file name
        removeHydrogen - set true to make hydrogens implicit before search
        cleanAndConfigureMolecule - eg: percieveAtomTypesAndConfigureAtoms, detect aromaticity etc
        Throws:
        CDKException
      • setChemFilters

        public void setChemFilters​(boolean stereoFilter,
                                   boolean fragmentFilter,
                                   boolean energyFilter)
        Deprecated.
        initialize query and target molecules.
        Specified by:
        setChemFilters in class AbstractMCS
        Parameters:
        stereoFilter - set true to rank the solutions as per stereo matches
        fragmentFilter - set true to return matches with minimum fragments
        energyFilter - set true to return matches with minimum bond changes based on the bond breaking energy
      • getFragmentSize

        public Integer getFragmentSize​(int key)
        Deprecated.
        Returns number of fragment generated in the solution space, if the MCS is removed from the target and query graph. Amongst the solutions, a solution with lowest fragment size is preferred.
        Specified by:
        getFragmentSize in class AbstractMCS
        Parameters:
        key - Index of the mapping solution
        Returns:
        Fragment count(s) generated after removing the mapped parts
      • getStereoScore

        public Integer getStereoScore​(int key)
        Deprecated.
        Returns a number which denotes the quality of the mcs. A solution with highest stereo score is preferred over other scores.
        Specified by:
        getStereoScore in class AbstractMCS
        Parameters:
        key - Index of the mapping solution
        Returns:
        true if no stereo mismatch occurs else false if stereo mismatch occurs
      • getEnergyScore

        public Double getEnergyScore​(int key)
        Deprecated.
        Returns summation energy score of the disorder if the MCS is removed from the target and query graph. Amongst the solutions, a solution with lowest energy score is preferred.
        Specified by:
        getEnergyScore in class AbstractMCS
        Parameters:
        key - Index of the mapping solution
        Returns:
        Total bond breaking energy required to remove the mapped part
      • getFirstMapping

        public Map<Integer,​Integer> getFirstMapping()
        Deprecated.
        Returns one of the best matches with atom indexes mapped.
        Specified by:
        getFirstMapping in class AbstractMCS
        Returns:
        Best Mapping Index
      • getAllMapping

        public List<Map<Integer,​Integer>> getAllMapping()
        Deprecated.
        Returns all plausible mappings between query and target molecules Each map in the list has atom-atom equivalence index of the mappings between query and target molecule i.e. map.getKey() for the query and map.getValue() for the target molecule.
        Specified by:
        getAllMapping in class AbstractMCS
        Returns:
        All possible MCS Mapping Index
      • getFirstAtomMapping

        public Map<IAtom,​IAtom> getFirstAtomMapping()
        Deprecated.
        Returns one of the best matches with atoms mapped.
        Specified by:
        getFirstAtomMapping in class AbstractMCS
        Returns:
        Best Atom Mapping
      • getAllAtomMapping

        public List<Map<IAtom,​IAtom>> getAllAtomMapping()
        Deprecated.
        Returns all plausible mappings between query and target molecules Each map in the list has atom-atom equivalence of the mappings between query and target molecule i.e. map.getKey() for the query and map.getValue() for the target molecule.
        Specified by:
        getAllAtomMapping in class AbstractMCS
        Returns:
        All possible MCS atom Mappings
      • getReactantMolecule

        public IAtomContainer getReactantMolecule()
        Deprecated.
        Returns modified query molecule on which mapping was performed.
        Specified by:
        getReactantMolecule in class AbstractMCS
        Returns:
        return modified reactant Molecule
      • getProductMolecule

        public IAtomContainer getProductMolecule()
        Deprecated.
        Returns modified target molecule on which mapping was performed.
        Specified by:
        getProductMolecule in class AbstractMCS
        Returns:
        return modified product Molecule
      • getTanimotoSimilarity

        public double getTanimotoSimilarity()
                                     throws IOException
        Deprecated.
        Returns Tanimoto similarity between query and target molecules (Score is between 0-min and 1-max).
        Specified by:
        getTanimotoSimilarity in class AbstractMCS
        Returns:
        Tanimoto Similarity between 0 and 1
        Throws:
        IOException
      • getTanimotoAtomSimilarity

        public double getTanimotoAtomSimilarity()
                                         throws IOException
        Deprecated.
        Throws:
        IOException
      • getTanimotoBondSimilarity

        public double getTanimotoBondSimilarity()
                                         throws IOException
        Deprecated.
        Throws:
        IOException
      • isStereoMisMatch

        public boolean isStereoMisMatch()
        Deprecated.
        Returns true if mols have different stereo chemistry else false if no stereo mismatch.
        Specified by:
        isStereoMisMatch in class AbstractMCS
        Returns:
        true if mols have different stereo chemistry else false if no stereo mismatch. true if stereo mismatch occurs else true if stereo mismatch occurs.
      • isSubgraph

        public boolean isSubgraph()
        Deprecated.
        Checks if query is a subgraph of the target. Returns true if query is a subgraph of target else false
        Specified by:
        isSubgraph in class AbstractMCS
        Returns:
        true if query molecule is a subgraph of the target molecule
      • getEuclideanDistance

        public double getEuclideanDistance()
                                    throws IOException
        Deprecated.
        Returns Euclidean Distance between query and target molecule.
        Specified by:
        getEuclideanDistance in class AbstractMCS
        Returns:
        Euclidean Distance (lower the score, better the match)
        Throws:
        IOException
      • getBondSensitiveTimeOut

        public double getBondSensitiveTimeOut()
        Deprecated.
        get timeout in mins for bond sensitive searches
        Specified by:
        getBondSensitiveTimeOut in class AbstractMCS
        Returns:
        the bondSensitiveTimeOut
      • setBondSensitiveTimeOut

        public void setBondSensitiveTimeOut​(double bondSensitiveTimeOut)
        Deprecated.
        set timeout in mins (default 0.10 min) for bond sensitive searches
        Specified by:
        setBondSensitiveTimeOut in class AbstractMCS
        Parameters:
        bondSensitiveTimeOut - the bond Sensitive Timeout in mins (default 0.10 min)
      • getBondInSensitiveTimeOut

        public double getBondInSensitiveTimeOut()
        Deprecated.
        get timeout in mins for bond insensitive searches
        Specified by:
        getBondInSensitiveTimeOut in class AbstractMCS
        Returns:
        the bondInSensitiveTimeOut
      • setBondInSensitiveTimeOut

        public void setBondInSensitiveTimeOut​(double bondInSensitiveTimeOut)
        Deprecated.
        set timeout in mins (default 1.00 min) for bond insensitive searches
        Specified by:
        setBondInSensitiveTimeOut in class AbstractMCS
        Parameters:
        bondInSensitiveTimeOut - the bond insensitive Timeout in mins (default 0.15 min)
      • isMatchBonds

        public boolean isMatchBonds()
        Deprecated.
        Returns:
        the matchBonds
      • setMatchBonds

        public void setMatchBonds​(boolean matchBonds)
        Deprecated.
        Parameters:
        matchBonds - the matchBonds to set
      • getAllBondMaps

        public List<Map<IBond,​IBond>> getAllBondMaps()
        Deprecated.
        Returns:
        the allBondMCS
      • getFirstBondMap

        public Map<IBond,​IBond> getFirstBondMap()
        Deprecated.
        Returns:
        the firstBondMCS