Пример #1
0
def main(args):
    if len(args) != 3:
        oechem.OEThrow.Usage("%s <input> <output>" % args[0])

    ifs = oechem.oemolistream()
    if not ifs.open(args[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1])

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

    mol = oechem.OEMol()
    oechem.OEReadMolecule(ifs, mol)

    opts = oeszybki.OEFreeFormConfOptions()
    ffconf = oeszybki.OEFreeFormConf(opts)

    omol = oechem.OEMol(mol)
    if not (ffconf.EstimateFreeEnergies(omol) == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Failed to estimate conformational free energies")

    res = oeszybki.OEFreeFormConfResults(omol)
    oechem.OEThrow.Info("Number of unique conformations: %d" % res.GetNumUniqueConfs())
    oechem.OEThrow.Info("Conf.  Delta_G   Vibrational_Entropy")
    oechem.OEThrow.Info("      [kcal/mol]     [J/(mol K)]")
    for r in res.GetResultsForConformations():
        oechem.OEThrow.Info("%2d %10.2f %14.2f" % (r.GetConfIdx(), r.GetDeltaG(),
                                                   r.GetVibrationalEntropy()))

    oechem.OEWriteMolecule(ofs, omol)

    return 0
Пример #2
0
def main(args):
    if len(args) != 3:
        oechem.OEThrow.Usage("%s <input> <output>" % args[0])

    ifs = oechem.oemolistream()
    if not ifs.open(args[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1])

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

    mol = oechem.OEMol()
    oechem.OEReadMolecule(ifs, mol)

    opts = oeszybki.OEFreeFormConfOptions()
    ffconf = oeszybki.OEFreeFormConf(opts)

    # Estimate free energies to ontain the minimum energy conformers
    omol = oechem.OEMol(mol)
    if not (ffconf.EstimateFreeEnergies(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Failed to estimate conformational free energies")

    # Find similar conformers to the ones we started with, from the
    # pool of minimum energy conformers
    fmol = oechem.OEMol(mol)
    for conf in mol.GetConfs():
        ffconf.FindSimilarConfs(fmol, omol, conf, oechem.OESimilarByRMSD(0.05))

    oechem.OEWriteMolecule(ofs, fmol)

    return 0
def main(args):
    if len(args) != 3:
        oechem.OEThrow.Usage("%s <input> <output>" % args[0])

    ifs = oechem.oemolistream()
    if not ifs.open(args[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1])

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

    mol = oechem.OEMol()
    oechem.OEReadMolecule(ifs, mol)

    opts = oeszybki.OEFreeFormConfOptions()
    ffconf = oeszybki.OEFreeFormConfAdvanced(opts)

    # Make a copy of our MCMol.  We will execute the FreeFormConf commands on
    # the copied molecule so that our original molecule stays intact.
    omol = oechem.OEMol(mol)

    # Prepare a comprehensive ensemble of molecule conformers. This will
    # generate a comprehensive set of conformers, assign solvent charges on the molecule
    # and check that the ensemble is otherwise ready for FreeFormConf calculations.
    if not (ffconf.PrepareEnsemble(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error(
            "Failed to prepare ensemble for FreeFormConf calculations")

    # Perform loose optimization of the ensemble conformers.  We will remove
    # duplicates based on the loose optimization, to reduce the time needed for
    # tighter, more stricter optimization
    if not (ffconf.PreOptimizeEnsemble(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Pre-optimization of the ensembles failed")

    # Remove duplicates from the pre-optimized ensemble
    if not (ffconf.RemoveDuplicates(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Duplicate removal from the ensembles failed")

    # Perform the desired optimization.  This uses a stricter convergence
    # criteria in the default settings.
    if not (ffconf.Optimize(omol) == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Optimization of the ensembles failed")

    # Remove duplicates to obtain the set of minimum energy conformers
    if not (ffconf.RemoveDuplicates(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Duplicate removal from the ensembles failed")

    # Perform FreeFormConf free energy calculations.  When all the above steps
    # have already been performed on the ensemble, this energy calculation
    # step is fast.
    if not (ffconf.EstimateEnergies(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Estimation of FreeFormConf energies failed")

    # Gather results of calculation into a results object for ease of viewing, etc.
    res = oeszybki.OEFreeFormConfResults(omol)
    oechem.OEThrow.Info("Number of unique conformations: %d" %
                        res.GetNumUniqueConfs())
    oechem.OEThrow.Info("Conf.  Delta_G   Vibrational_Entropy")
    oechem.OEThrow.Info("      [kcal/mol]     [J/(mol K)]")
    for r in res.GetResultsForConformations():
        oechem.OEThrow.Info(
            "%2d %10.2f %14.2f" %
            (r.GetConfIdx(), r.GetDeltaG(), r.GetVibrationalEntropy()))

    oechem.OEWriteMolecule(ofs, omol)

    return 0
def main(args):
    if len(args) != 3:
        oechem.OEThrow.Usage("%s <input> <output>" % args[0])

    ifs = oechem.oemolistream()
    if not ifs.open(args[1]):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1])

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

    mol = oechem.OEMol()
    oechem.OEReadMolecule(ifs, mol)

    opts = oeszybki.OEFreeFormConfOptions()
    ffconf = oeszybki.OEFreeFormConfAdvanced(opts)

    # Make a copy of our MCMol.  We will execute the FreeFormConf commands on
    # the copied molecule so that our original molecule stays intact.
    omol = oechem.OEMol(mol)

    # Make further copies of our original molecule.  The copied molecule(s) would be used
    # as source on which retriction energies would be calculated
    rmol = oechem.OEMol(mol)
    fmol = oechem.OEMol(mol)

    # Prepare a comprehensive ensemble of molecule conformers.  For calculation
    # of restriction energies we want to make sure that all the corresponding free
    # conformers are also part of the comprehensive ensemble.  This will also
    # assign solvent charges on the molecule and check that the ensemble is
    # otherwise ready for FreeFormConf calculations. The resulting `fmol`
    # contains the correspondig free conformers.
    if not (ffconf.PrepareEnsemble(omol, rmol, fmol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error(
            "Failed to prepare ensemble for FreeFormConf calculations")

    # Perform loose optimization of the ensemble conformers.  We will remove
    # duplicates based on the loose optimization, to reduce the time needed for
    # tighter, more stricter optimization
    if not (ffconf.PreOptimizeEnsemble(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Pre-optimization of the ensembles failed")

    # Remove duplicates from the pre-optimized ensemble
    if not (ffconf.RemoveDuplicates(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Duplicate removal from the ensembles failed")

    # Perform the desired optimization.  This uses a stricter convergence
    # criteria in the default settings.
    if not (ffconf.Optimize(omol) == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Optimization of the ensembles failed")

    # Remove duplicates to obtain the set of minimum energy conformers
    if not (ffconf.RemoveDuplicates(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Duplicate removal from the ensembles failed")

    # Perform FreeFormConf free energy calculations.  When all the above steps
    # have already been performed on the ensemble, this energy calculation
    # step is fast.
    if not (ffconf.EstimateEnergies(omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Estimation of FreeFormConf energies failed")

    # Gather results of calculation into a results object for ease of viewing, etc.
    res = oeszybki.OEFreeFormConfResults(omol)
    oechem.OEThrow.Info("Number of unique conformations: %d" %
                        res.GetNumUniqueConfs())
    oechem.OEThrow.Info("Conf.  Delta_G   Vibrational_Entropy")
    oechem.OEThrow.Info("      [kcal/mol]     [J/(mol K)]")
    for r in res.GetResultsForConformations():
        oechem.OEThrow.Info(
            "%2d %10.2f %14.2f" %
            (r.GetConfIdx(), r.GetDeltaG(), r.GetVibrationalEntropy()))

    # Identify the corresponding conformer(s) to the free minimized conformer(s).
    # If identified, the corresponding (Conf)Free energy information is also
    # copied to the free conformers
    if not (ffconf.IdentifyConformer(fmol, omol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Identification of free conformer(s) failed")

    # Estimate restriction energies. Since both restricted and free conformer
    # energy components are already available, this operation is fast.
    if not (ffconf.EstimateRestrictionEnergy(fmol, rmol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Restriction energy estimation failed")

    # Gather restriction energies into a results object for ease of viewing, etc.
    rstrRes = oeszybki.OERestrictionEnergyResult(fmol)
    oechem.OEThrow.Info("Global strain: %f" % rstrRes.GetGlobalStrain())
    oechem.OEThrow.Info("Local strain: %f" % rstrRes.GetLocalStrain())

    # Optionally it is desired to perform a restrained optimization of the
    # restricted conformer(s) to brush out any energy differences due to
    # force field constaints or the sources of coonformer coordinates.  Note: The
    # high level EstimateFreeEnergy method does not perform this opertion.
    if not (ffconf.OptimizeRestraint(rmol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error(
            "Restraint optimization of the conformer(s) failed")

    # Estimate restriction energies on this optimized conformers.
    # Since both restricted and free conformer energy components
    # are already available, this operation is fast.
    if not (ffconf.EstimateRestrictionEnergy(fmol, rmol)
            == oeszybki.OEFreeFormReturnCode_Success):
        oechem.OEThrow.Error("Restriction energy estimation failed")

    # Gather restriction energies into a results object for ease of viewing, etc.
    rstrRes = oeszybki.OERestrictionEnergyResult(fmol)
    oechem.OEThrow.Info("Global strain: %f" % rstrRes.GetGlobalStrain())
    oechem.OEThrow.Info("Local strain: %f" % rstrRes.GetLocalStrain())

    oechem.OEWriteMolecule(ofs, omol)

    return 0