Exemple #1
0
def main(argv=[__name__]):
    if len(argv) != 3:
        oechem.OEThrow.Usage("%s <reffile> <fitfile>" % argv[0])

    reffs = oechem.oemolistream(argv[1])
    fitfs = oechem.oemolistream(argv[2])

    refmol = oechem.OEMol()
    oechem.OEReadMolecule(reffs, refmol)
    print("Ref. Title:", refmol.GetTitle(), "Num Confs:", refmol.NumConfs())

    # Prepare reference molecule for calculation
    # With default options this will remove any explicit
    # hydrogens present and add color atoms
    prep = oeshape.OEOverlapPrep()
    prep.Prep(refmol)

    overlay = oeshape.OEMultiRefOverlay()
    overlay.SetupRef(refmol)

    for fitmol in fitfs.GetOEMols():
        prep.Prep(fitmol)
        score = oeshape.OEBestOverlayScore()
        overlay.BestOverlay(score, fitmol, oeshape.OEHighestTanimoto())
        print(
            "Fit Title: %-4s FitConfIdx: %-4d RefConfIdx: %-4d tanimoto combo: %.2f"
            % (fitmol.GetTitle(), score.GetFitConfIdx(), score.GetRefConfIdx(),
               score.GetTanimotoCombo()))
Exemple #2
0
 def run(self):
     for fitmol in self._ifs.GetOEMols():
         self._prep.Prep(fitmol)
         score = oeshape.OEBestOverlayScore()
         self._overlay.BestOverlay(score, fitmol,
                                   oeshape.OEHighestTanimoto())
         print(
             "Fit Title: %-4s FitConfIdx: %-4d RefConfIdx: %-4d tanimoto combo: %.2f"
             % (fitmol.GetTitle(), score.GetFitConfIdx(),
                score.GetRefConfIdx(), score.GetTanimotoCombo()))
Exemple #3
0
def overlay_molecules(
    reference_molecule: oechem.OEGraphMol,
    fit_molecule: oechem.OEMol,
    return_overlay: bool = True,
) -> (int, List[oechem.OEGraphMol]):
    """
    Overlay two molecules and calculate TanimotoCombo score.
    Parameters
    ----------
    reference_molecule: oechem.OEGraphMol
        An OpenEye molecule holding the reference molecule for overlay.
    fit_molecule: oechem.OEMol
        An OpenEye multi-conformer molecule holding the fit molecule for overlay.
    return_overlay: bool
        If the best scored overlay of molecules should be returned.
    Returns
    -------
        : int or int and list of oechem.OEGraphMol
        The TanimotoCombo score of the best overlay and the overlay if score_only is set False.
    """
    from openeye import oechem, oeshape

    prep = oeshape.OEOverlapPrep()
    prep.Prep(reference_molecule)

    overlay = oeshape.OEOverlay()
    overlay.SetupRef(reference_molecule)

    prep.Prep(fit_molecule)
    score = oeshape.OEBestOverlayScore()
    overlay.BestOverlay(score, fit_molecule, oeshape.OEHighestTanimoto())
    if not return_overlay:
        return score.GetTanimotoCombo()
    else:
        overlay = [reference_molecule]
        fit_molecule = oechem.OEGraphMol(
            fit_molecule.GetConf(oechem.OEHasConfIdx(score.GetFitConfIdx())))
        score.Transform(fit_molecule)
        overlay.append(fit_molecule)
        return score.GetTanimotoCombo(), overlay
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData, argv)

    NPolyMax_MAX = itf.GetInt("-NPolyMax_MAX")

    ifrefname = itf.GetString("-inputreffile")
    iffitname = itf.GetString("-inputfitfile")
    ofname = itf.GetString("-outputfile")

    ifsref = oechem.oemolistream()
    if not ifsref.open(ifrefname):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % ifrefname)

    ifsfit = oechem.oemolistream()
    if not ifsfit.open(iffitname):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % iffitname)

    refmol = oechem.OEMol()

    if not oechem.OEReadMolecule(ifsref, refmol):
        oechem.OEThrow.Fatal("Unable to read molecule in %s" % ifrefname)

    prep = oeshape.OEOverlapPrep()
    prep.SetAssignColor(False)
    prep.Prep(refmol)
    reftransfm = oechem.OETrans()
    oeshape.OEOrientByMomentsOfInertia(refmol, reftransfm)

    hermiteoptionsref = oeshape.OEHermiteOptions()
    hermiteoptionsref.SetNPolyMax(NPolyMax_MAX)
    hermiteoptionsref.SetUseOptimalLambdas(True)

    hermiteoptionsfit = oeshape.OEHermiteOptions()
    hermiteoptionsfit.SetNPolyMax(NPolyMax_MAX)
    hermiteoptionsfit.SetUseOptimalLambdas(True)

    hermitefunc = oeshape.OEHermiteShapeFunc(hermiteoptionsref,
                                             hermiteoptionsfit)

    options = oeshape.OEOverlayOptions()
    options.SetOverlapFunc(hermitefunc)
    overlay = oeshape.OEOverlay(options)
    overlay.SetupRef(refmol)

    ofs = oechem.oemolostream()
    if not ofs.open(ofname):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % ofname)

    transfm = oechem.OETrans()
    fitmol = oechem.OEMol()
    while oechem.OEReadMolecule(ifsfit, fitmol):
        prep.Prep(fitmol)
        oeshape.OEOrientByMomentsOfInertia(fitmol, transfm)

        score = oeshape.OEBestOverlayScore()
        overlay.BestOverlay(score, fitmol)
        print("Hermite Tanimoto = ", score.GetTanimoto())

        oechem.OESetSDData(fitmol, "HermiteTanimoto_" + str(NPolyMax_MAX),
                           str(score.GetTanimoto()))
        score.Transform(fitmol)

        # Transform from the inertial frame to the original reference mol frame
        reftransfm.Transform(fitmol)

        oechem.OEWriteMolecule(ofs, fitmol)