예제 #1
0
 def GetSystem ( self, log = logFile ):
     """Get the system."""
     if self.setUpType == "CHARMM":
         parameters = CHARMMParameterFiles_ToParameters ( self.parameterFiles, log = log )
         system     = CHARMMPSFFile_ToSystem ( self.setUpFile, isXPLOR = True, log = log, parameters = parameters )
     elif self.setUpType == "MOL"   : system = MOLFile_ToSystem  ( self.setUpFile )
     elif self.setUpType == "MOL2"  : system = MOL2File_ToSystem ( self.setUpFile )
     if self.xyzFile is not None: system.coordinates3 = XYZFile_ToCoordinates3 ( self.xyzFile )
     if self.mmModel is not None: system.DefineMMModel ( self.mmModel )
     if self.hasSymmetry: system.DefineSymmetry ( crystalClass = CrystalClassCubic ( ), a = self.a )
     system.label = self.label
     system.Summary ( log = log )
     return system
예제 #2
0
def SetUpSystem(path, forceNoQC=False, useSystemWithTimings=True):
    """Set up the system."""
    # . Get system data.
    systemData = YAMLUnpickle(os.path.join(path, _TestDataFileName))
    # . Get the parameters.
    parameters = CHARMMParameterFiles_ToParameters(
        glob.glob(os.path.join(path, "*.prm")))
    # . Get the test name.
    name = os.path.split(path)[-1]
    # . Generate the system.
    system = CHARMMPSFFile_ToSystem(os.path.join(path, name + ".psfx"),
                                    isXPLOR=True,
                                    parameters=parameters)
    if useSystemWithTimings: system = SystemWithTimings.FromSystem(system)
    system.coordinates3 = XYZFile_ToCoordinates3(
        os.path.join(path, name + ".xyz"))
    system.label = systemData["Label"]
    # . Symmetry.
    if systemData.get("Crystal Class", None) is not None:
        symmetryOptions = systemData["Symmetry Parameters"]
        symmetryOptions["crystalClass"] = _CrystalClasses[
            systemData["Crystal Class"]]
        system.DefineSymmetry(**symmetryOptions)
    # . QC data.
    if not forceNoQC:
        qcData = systemData.get(_QCRegionKey, None)
        if qcData is not None:
            # . Electronic state.
            system.electronicState = ElectronicState(
                charge=qcData.get("Charge", 0),
                multiplicity=qcData.get("Multiplicity", 1))
            # . QC atoms.
            qcAtoms = set()
            for path in qcData["Atoms"]:
                index = system.sequence.AtomIndex(path)
                qcAtoms.add(index)
            system.DefineQCModel(_QCModel, qcSelection=Selection(qcAtoms))
    # . Finish set up.
    system.DefineNBModel(_NBModel)
    return system
예제 #3
0
# Example script
from pCore                   import logFile
from pBabel                  import CHARMMParameterFiles_ToParameters, CHARMMPSFFile_ToSystem, CHARMMCRDFile_ToCoordinates3
from ContinuumElectrostatics import MEADModel, MEADSubstate, StateVector, TitrationCurves, MCModelDefault, MCModelGMCT


parameters = ["toppar/par_all27_prot_na.inp", ]

mol = CHARMMPSFFile_ToSystem ("defensin_xplor.psf", isXPLOR=True, parameters=CHARMMParameterFiles_ToParameters (parameters))
mol.coordinates3 = CHARMMCRDFile_ToCoordinates3 ("defensin.crd")


electrostaticModel = MEADModel (system=mol, pathMEAD="/home/mikolaj/local/bin/", pathScratch="mead", nthreads=1)
electrostaticModel.Initialize ()
electrostaticModel.Summary ()
electrostaticModel.SummarySites ()
electrostaticModel.WriteJobFiles ()
electrostaticModel.CalculateElectrostaticEnergies ()


sites = (
    ("PRTA", "ASP" , 2),
    ("PRTA", "GLU", 14),
    ("PRTA", "ARG", 15), )

mcModelGMCT    = MCModelGMCT    (pathGMCT="/home/mikolaj/local/bin/")
mcModelDefault = MCModelDefault ()

for mcModel, folded, direc, message, sedFile, substateFile in (
    (None           , True  , "curves_analytic"          , "analytically"             , "prob_ph7_analytic.sed"          , "substate_ph7_analytic.tex"         ),
    (mcModelGMCT    , True  , "curves_gmct"              , "using GMCT"               , "prob_ph7_gmct.sed"              , "substate_ph7_gmct.tex"             ),
예제 #4
0
pcetk_root = os.path.join(os.environ["HOME"], "devel", "pcetk_testing")
sys.path.append(pcetk_root)

os.environ["PDYNAMO_PCETK"] = pcetk_root

#-------------------------------------------------------------------------------
from pBabel import CHARMMParameterFiles_ToParameters, CHARMMPSFFile_ToSystem, CHARMMCRDFile_ToCoordinates3

from ContinuumElectrostatics import MEADModel, MCModelDefault, TitrationCurves, StateVector

parameters = [
    "toppar/par_all27_prot_na.inp",
]

mol = CHARMMPSFFile_ToSystem(
    "setup/lysozyme1977_xplor.psf",
    isXPLOR=True,
    parameters=CHARMMParameterFiles_ToParameters(parameters))
mol.coordinates3 = CHARMMCRDFile_ToCoordinates3("setup/lysozyme1977.crd")

cem = MEADModel(system=mol,
                pathMEAD="/home/mikolaj/local/bin/",
                pathScratch="mead",
                nthreads=1)

exclusions = (
    ("PRTA", "CYS", 6),
    ("PRTA", "CYS", 127),
    ("PRTA", "CYS", 30),
    ("PRTA", "CYS", 115),
    ("PRTA", "CYS", 64),
    ("PRTA", "CYS", 80),
예제 #5
0
파일: ifp20.py 프로젝트: shunsunsun/pcetk
"""Example: Protonation states in IFP2.0."""

from pBabel import CHARMMParameterFiles_ToParameters, CHARMMPSFFile_ToSystem, CHARMMCRDFile_ToCoordinates3
from ContinuumElectrostatics import MEADModel, MEADSubstate, MCModelDefault, TitrationCurves

parameters = ("toppar/par_all27_prot_na.inp", "toppar/blf.inp")

mol = CHARMMPSFFile_ToSystem(
    "setup/ifp20_xplor_separated.psf",
    isXPLOR=True,
    parameters=CHARMMParameterFiles_ToParameters(parameters))
mol.coordinates3 = CHARMMCRDFile_ToCoordinates3("setup/ifp20.crd")
mol.Summary()

mead = MEADModel(system=mol,
                 pathMEAD="/home/mikolaj/local/bin/",
                 pathScratch="mead",
                 nthreads=1)
mead.Initialize(excludeResidues=(("PRTA", "CYS", 24), ))
mead.Summary()

mead.WriteJobFiles()
mead.CalculateElectrostaticEnergies(calculateETA=False)

sampling = MCModelDefault()
mead.DefineMCModel(sampling)

tc = TitrationCurves(mead)
tc.CalculateCurves()
tc.WriteCurves(directory="curves")
예제 #6
0
    ),
    (
        "new",
        "setup/2LZT/lysozyme1990_xplor.psf",
        "setup/2LZT/lysozyme1990.crd",
        "mead/2LZT",
        "curves/2LZT",
        "New lysozyme",
    ),
):

    logFile.Text("\n*** Now calculating: %s ***\n" % message)

    protein = CHARMMPSFFile_ToSystem(
        proteinPsf,
        isXPLOR=True,
        parameters=CHARMMParameterFiles_ToParameters(parameters),
    )
    protein.coordinates3 = CHARMMCRDFile_ToCoordinates3(proteinCrd)

    model = MEADModel(
        system=protein,
        pathMEAD="/home/mikolaj/local/bin/",
        pathScratch=meadDir,
        nthreads=1,
    )
    model.Initialize(excludeResidues=exclusions, includeTermini=True)
    model.Summary()
    model.SummarySites()
    model.WriteJobFiles()
    model.CalculateElectrostaticEnergies()
예제 #7
0
    MEADModel,
    StateVector,
    MCModelDefault,
    TitrationCurves,
)

logFile.Header(
    "Calculate protonation states of two titratable sites in a hypothetical peptide."
)

parameters = [
    "charmm/toppar/par_all27_prot_na.inp",
]
mol = CHARMMPSFFile_ToSystem(
    "charmm/testpeptide_xplor.psf",
    isXPLOR=True,
    parameters=CHARMMParameterFiles_ToParameters(parameters),
)
mol.coordinates3 = CHARMMCRDFile_ToCoordinates3("charmm/testpeptide.crd")

cem = MEADModel(system=mol,
                pathMEAD="/home/mikolaj/local/bin/",
                pathScratch="mead",
                nthreads=1)
cem.Initialize()
cem.Summary()
cem.SummarySites()
cem.WriteJobFiles()
cem.CalculateElectrostaticEnergies()

logFile.Text(
예제 #8
0
    def runTest(self):
        """The test."""

        # . Initialization.
        if self.generateReferenceData:
            referenceData = TestDataSet("Charmm Test")
        else:
            observed = {}

        # . Output setup.
        dataPath = os.path.join(os.getenv("PDYNAMO_PBABEL"), "data", "charmm")
        outPath = None
        if self.resultPath is not None:
            outPath = os.path.join(self.resultPath, "pdb")
            if not os.path.exists(outPath): os.mkdir(outPath)
        log = self.GetLog()

        # . Get the parameters.
        parameterPaths = []
        for parameterPath in _ParameterPaths:
            parameterPaths.append(
                os.path.join(dataPath, parameterPath + ".prm"))
        parameters = CHARMMParameterFiles_ToParameters(parameterPaths, log=log)

        # . Generate systems.
        for label in _SystemLabels:

            if log is not None:
                log.Text("\n" + (80 * "=") + "\n")
                log.Text(label + "\n")
                log.Text(80 * "=" + "\n")
            system = CHARMMPSFFile_ToSystem(os.path.join(
                dataPath, label + ".psfx"),
                                            isXPLOR=True,
                                            parameters=parameters,
                                            log=log)
            system.coordinates3 = CHARMMCRDFile_ToCoordinates3(os.path.join(
                dataPath, label + ".chm"),
                                                               log=log)
            system.label = label
            system.DefineNBModel(NBModelFull())
            system.Summary(log=log)
            energy = system.Energy(log=log)
            log.Text("\nEnergy (kcal/mole) = {:.4f}\n".format(
                energy /
                UNITS_ENERGY_KILOCALORIES_PER_MOLE_TO_KILOJOULES_PER_MOLE))

            # . Get the dictionary of energies.
            localObserved = system.configuration.energyTerms.Terms(
                asDictionary=True)
            localObserved["Potential Energy"] = energy

            # . Test gradients.
            if len(system.atoms) <= _MaximumAtoms:
                of = SystemGeometryObjectiveFunction.FromSystem(system)
                of.TestGradients(log=log)
                localObserved["Gradient Error"] = of.TestGradients(log=log)

            # . Write PDB file and do various sequence tests.
            if not self.generateReferenceData:
                if outPath is not None:
                    PDBFile_FromSystem(os.path.join(outPath, label + ".pdb"),
                                       system,
                                       useSegmentEntityLabels=True)
                system.sequence.PrintComponentSequence(log=log)
                log.Text("\nSelections:\n\n")
                for pattern in _Patterns[label]:
                    log.Text("{:<30s} {:5d}\n".format(
                        pattern,
                        len(AtomSelection.FromAtomPattern(system, pattern))))

            # . Generate reference data.
            if self.generateReferenceData:
                localData = TestDataSet(label, parent=referenceData)
                for (key, value) in localObserved.iteritems():
                    if key == "Gradient Error":
                        localData.AddDatum(
                            TestReal(key,
                                     value,
                                     localData,
                                     absoluteErrorTolerance=
                                     _GradientAbsoluteErrorTolerance))
                    else:
                        localData.AddDatum(
                            TestReal(
                                key,
                                value,
                                localData,
                                absoluteErrorTolerance=_AbsoluteErrorTolerance,
                                toleranceFormat="{:.3f}",
                                valueFormat="{:.3f}"))
                referenceData.AddDatum(localData)
            # . Accumulate observed data.
            else:
                observed[label] = localObserved

        # . Generate the reference data.
        if self.generateReferenceData:
            referenceData.Summary(log=log)
            Pickle(self.referenceDataPath, referenceData)
            isOK = True
        # . Verify the observed data against the reference data.
        else:
            referenceData = Unpickle(self.referenceDataPath)
            results = referenceData.VerifyAgainst(observed)
            results.Summary(log=log, fullSummary=self.fullVerificationSummary)
            isOK = results.WasSuccessful()

        # . Success/failure.
        self.assertTrue(isOK)
예제 #9
0
from pCore import logFile
from pBabel import CHARMMParameterFiles_ToParameters, CHARMMPSFFile_ToSystem, XYZFile_ToCoordinates3, XYZFile_FromSystem
from XTCTrajectory import XTCTrajectoryFileReader, XTCTrajectory_ToSystemGeometryTrajectory

import os

#===========================================================
logFile.Header("Infrared fluorescent protein (parent)")

parameters = (
    "par_all27_prot_na.inp",
    "par.inp",
)

mol = CHARMMPSFFile_ToSystem(
    "parent_waterbox.psf",
    isXPLOR=True,
    parameters=CHARMMParameterFiles_ToParameters(parameters))
mol.coordinates3 = XYZFile_ToCoordinates3("geometry.xyz")
mol.Summary()

trajectory = XTCTrajectoryFileReader("heat.xtc", mol)
trajectory.Summary()

while trajectory.RestoreOwnerData():
    logFile.Text("Frame count: %d\n" % trajectory.currentFrame)
    XYZFile_FromSystem("sav%03d.xyz" % trajectory.currentFrame, mol)

trajectory.Summary()

#===========================================================
# This part takes a bit more time to execute, uncomment if you like