Пример #1
0
    def runTest(self):
        """The test."""

        # . Initialization.
        isOK = True
        log = self.GetLog()

        # . Paths.
        sourcePath = os.path.join(os.getenv("PDYNAMO_ROOT"),
                                  "molecularStructures",
                                  "gaussianGeometryOptimization")
        statesPath = os.path.join(sourcePath, "states.yaml")
        xyzPaths = glob.glob(os.path.join(sourcePath, "xyz", "*.xyz"))
        xyzPaths.sort()

        # . Get the states.
        states = YAMLUnpickle(statesPath)

        # . Loop over the molecules.
        reports = {}
        numberNotConverged = 0
        for xyzPath in xyzPaths:

            # . Basic set up.
            label = os.path.split(xyzPath)[1][0:-4]
            (charge, multiplicity) = states.get(label, (0, 1))
            system = XYZFile_ToSystem(xyzPath)
            system.electronicState = ElectronicState(charge=charge,
                                                     multiplicity=multiplicity)
            system.DefineQCModel(QCModelMNDO("am1", isSpinRestricted=True))
            system.Summary(log=log)

            # . Skip molecules that are too large.
            if len(system.atoms) > _MaximumMoleculeSize: continue

            # . Loop over the optimizers.
            tagReports = {}
            for (tag, minimizer, options) in _Minimizers:

                # . Reset the system.
                system.coordinates3 = XYZFile_ToCoordinates3(xyzPath)
                system.Energy(log=log)

                # . Minimization.
                keywordArguments = dict(options)
                keywordArguments["log"] = log
                cpu = CPUTime()
                tagReports[tag] = minimizer(system, **keywordArguments)
                tagReports[tag]["CPU Time"] = cpu.Current()
                if not tagReports[tag].get("Converged", False):
                    numberNotConverged += 1

            # . Save the results.
            reports[label] = tagReports

        # . Finish up.
        self.ReportsSummary(reports, log=log)
        self.assertTrue(numberNotConverged == 0)
Пример #2
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
Пример #3
0
 def GetSystem ( self, log = logFile ):
     """Get the system."""
     # . Set up the system with an MM model if it exists.
     if self.setUpMode == "amber":
         system              = AmberTopologyFile_ToSystem  ( os.path.join ( self.dataPath, self.amberTopologyFile    ), log = log, mmModel = self.mmModel )
         system.coordinates3 = AmberCrdFile_ToCoordinates3 ( os.path.join ( self.dataPath, self.setUpCoordinatesFile ), log = log )
     elif self.setUpMode == "mol":
         system = MOLFile_ToSystem ( os.path.join ( self.dataPath, self.setUpCoordinatesFile ) )
         if self.mmModel is not None: system.DefineMMModel ( self.mmModel )
     elif self.setUpMode == "xyz":
         system = XYZFile_ToSystem ( os.path.join ( self.dataPath, self.setUpCoordinatesFile ) )
     else:
         raise ValueError ( "Invalid set up mode: {:s}.".format ( self.setUpMode ) )
     # . Finish energy model set up.
     if self.qcModel is not None: system.DefineQCModel ( self.qcModel )
     if self.nbModel is not None: system.DefineNBModel ( self.nbModel )
     # . Get reactants and products.
     self.reactants = XYZFile_ToCoordinates3 ( os.path.join ( self.dataPath, self.reactantsFile ) )
     self.products  = XYZFile_ToCoordinates3 ( os.path.join ( self.dataPath, self.productsFile  ) )
     # . Finish up.
     self.system = system
     return system
Пример #4
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
Пример #5
0
    def runTest(self):
        """The test."""

        # . Paths.
        dataPath = os.path.join(os.getenv("PDYNAMO_PMOLECULE"), "data")
        molPath = os.path.join(dataPath, "mol")
        xyzPath = os.path.join(dataPath, "bAlaConformations")
        log = self.GetLog()

        # . Conformations.
        xyzFiles = glob.glob(os.path.join(xyzPath, "*.xyz"))
        xyzFiles.sort()

        # . Generate the molecule.
        molecule = MOLFile_ToSystem(os.path.join(molPath, "bAla_c7eq.mol"))
        molecule.Summary(log=log)

        # . Initialization.
        isOK = True

        # . Loop over the structures in the xyz files.
        for xyzFile in xyzFiles:
            molecule.coordinates3 = XYZFile_ToCoordinates3(xyzFile)
            if log is not None:
                conformation = os.path.split(xyzFile)[-1].split("_",
                                                                1)[-1][0:-4]
                log.Heading("bALA Configuration " + conformation,
                            QBLANKLINE=True)
            results = CIPLabelFinder(molecule, log=log)
            if results is None:
                localIsOK = False
            else:
                ((tCenters, rtCenters, stCenters, utCenters),
                 (dCenters, edCenters, zdCenters, udCenters)) = results
                localIsOK = ( len ( tCenters  ) == 4 ) and ( len ( dCenters  ) == 0 ) and \
                            ( len ( stCenters ) == 1 ) and ( len ( utCenters ) == 3 )
            isOK = (isOK and localIsOK)

        # . Success/failure.
        self.assertTrue(isOK)
Пример #6
0
    def runTest(self):
        """The test."""

        # . Paths.
        dataPath = os.path.join(os.getenv("PDYNAMO_PMOLECULE"), "data")
        molPath = os.path.join(dataPath, "mol")
        xyzPath = os.path.join(dataPath, "bAlaConformations")
        log = self.GetLog()

        # . Conformations.
        xyzFiles = glob.glob(os.path.join(xyzPath, "*.xyz"))
        xyzFiles.sort()

        # . Generate the molecule.
        molecule = MOLFile_ToSystem(os.path.join(molPath, "bAla_c7eq.mol"))
        molecule.Summary(log=log)

        # . Translate to principal axes using masses as weights.
        masses = molecule.atoms.GetItemAttributes("mass")
        molecule.coordinates3.ToPrincipalAxes(weights=masses)

        # . Loop over structures and output at the same time.
        if log is not None:
            table = log.GetTable(columns=[20, 10])
            table.Start()
            table.Title("Radii Of Gyration")
            table.Heading("Conformation")
            table.Heading("Value")
            for xyzFile in xyzFiles:
                conformation = os.path.split(xyzFile)[-1].split("_",
                                                                1)[-1][0:-4]
                coordinates3 = XYZFile_ToCoordinates3(xyzFile)
                radiusOfGyration = coordinates3.RadiusOfGyration(
                    weights=masses)
                table.Entry(conformation, alignment="left")
                table.Entry("{:.2f}".format(radiusOfGyration))
            table.Stop()

        # . Success/failure.
        self.assertTrue(True)
Пример #7
0
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
# direc = "traj"
#