Class MMPAlignment


  • @PublicAPI
    public final class MMPAlignment
    extends Object
    3D Molecular alignment that uses the maximum common substructure to align a pair of structures. The name MMP comes from the expression of matched molecule pairs, as this kind of alignment is an extension of the traditional shape based approach for MMP cases. The coordinates of the atoms in the MCS of the "toAlign" structure will be exactly the same as in the MCS atoms of the reference structure. While the non-MCS parts of the "toAlign" are flexibly aligned to the non-MCS parts reference, to maximize the overall shape score. If multiple MCSes were found, the first 10 are examined as above and the overlay returning the best shape score is returned. If the MCS Tanimoto similarity McsSearchResult.getSimilarity() does not reach a predefined limit, shape based Alignment is applied on the molecule pair.
      Example usage:  
     
      final Molecule reference = MolImporter.importMol("CCCCOC");
      final Molecule toAlign = MolImporter.importMol("CCCCNCC");
    
      // Either you can generate 3D coordinates :
      // Cleaner.clean(reference, 3, "");
      // Cleaner.clean(toAlign, 3, "");
      // Molecule referenceP = reference;
      // Molecule toAlignP = toAlign;
      
      // or alternatively:
       boolean beautify = true;
       final Molecule referenceP = MMPAlignment.preprocess(reference, beautify);
       final Molecule toAlignP = MMPAlignment.preprocess(toAlign, beautify);
       
      // In this latter case the following actions are performed on Molecules:
      // 1. keep largest fragment, 2. generate 3D coordinates, if the structure is not in 3D, 
      // 3. Additionally, if the "beautify" parameter is true:
      //   - remove atom aliases
      //   - remove lone pairs
      //   - remove explicit Hydrogen atoms
      //   - fix valence errors (needs Checker license)
    
    
      final MMPAlignment mmp = new MMPAlignment(referenceP, toAlignP);
      final MMPAlignmentResult result = mmp.calculate();
      final Molecule aligned = result.getMolecule2Aligned();
    
      System.err.println("3D Tanimoto score: " + result.getShapeScore());
      System.err.println("Coordinate RMSD of the MCS after the alignment: " + result.getRmsd());
      
      // Call a simple utility to write Molecule object into mrv format
      MolGeom.writeMol(result.toMolecule(), "alignedResult.mrv");
     }
     
    Since:
    Marvin 6.0.0
    • Method Detail

      • cancel

        public void cancel()
        Cancel the ongoing calculation
      • calculate

        public MMPAlignmentResult calculate()
        Runs the MCS alignment calculation on the two structures of the constructor.
        Returns:
        the calculation result object.
      • clean3d

        public static Molecule clean3d​(Molecule m)
        Utility for preprocessing structure for alignment. Generates 3D coordinates for a 2D structure. The lowest energy conformer will be selected from maximum 50 diverse conformations.
        Parameters:
        m - The 2D input structure.
        Returns:
        the lowest energy conformer found
      • clean3d

        public static Molecule clean3d​(Molecule m,
                                       int conformerCount)
        Utility for preprocessing structure for alignment. Generates 3D coordinates for a 2D structure.
        Parameters:
        m - The 2D input structure
        conformerCount - The lowest energy conformer will be selected from maximum conformerCount diverse conformations.
        Returns:
        the lowest energy conformer found
      • removeAtomAliases

        public static void removeAtomAliases​(Molecule m)
        Utility for preprocessing structure for alignment. Removes atom aliases that usually exist on molecules if read from pdb.
        Parameters:
        m - removes aliases on this instance.
      • removeLonePairs

        public static void removeLonePairs​(Molecule m)
        Utility for preprocessing structure for alignment. Removes lone pair atoms that usually exist on molecules if read from pdb.
        Parameters:
        m - removes LP atoms on this instance.
      • keepLargestFragment

        public static Molecule keepLargestFragment​(Molecule m)
        Utility for preprocessing structure for alignment. Keeps the largest fragment of the moleculegraph.
        Parameters:
        m - finds the largest fragment of this Molecule
        Returns:
        a new clone of the largest fragment.
      • fixValence

        public static void fixValence​(Molecule mol)
        Utility for preprocessing structure for alignment. Fix valence errors if there is any. Launches ValenceErrorChecker.
        Parameters:
        mol - modifies this reference molecule
      • preprocess

        public static Molecule preprocess​(Molecule m,
                                          boolean beautify)
        Utility for preprocessing structure for alignment. Performs the following actions on the Molecule required by the alignment:
        1. keepLargestFragment(Molecule)
        2. Generates 3D coordinates, if the structure is not in 3D
        Optionally performs the following actions if boolean parameter is set.
        1. removeAtomAliases(Molecule)
        2. removeLonePairs(Molecule)
        3. remove explicit Hydrogen atoms
        4. Fix valence errors
        Parameters:
        m -
        Returns:
        the clone of the input molecule preprocessed.