MayaChemTools

    1 #!/bin/env python
    2 #
    3 # File: OpenMMPerformMDSimulation.py
    4 # Author: Manish Sud <msud@san.rr.com>
    5 #
    6 # Copyright (C) 2025 Manish Sud. All rights reserved.
    7 #
    8 # The functionality available in this script is implemented using OpenMM, an
    9 # open source molecuar simulation package.
   10 #
   11 # This file is part of MayaChemTools.
   12 #
   13 # MayaChemTools is free software; you can redistribute it and/or modify it under
   14 # the terms of the GNU Lesser General Public License as published by the Free
   15 # Software Foundation; either version 3 of the License, or (at your option) any
   16 # later version.
   17 #
   18 # MayaChemTools is distributed in the hope that it will be useful, but without
   19 # any warranty; without even the implied warranty of merchantability of fitness
   20 # for a particular purpose.  See the GNU Lesser General Public License for more
   21 # details.
   22 #
   23 # You should have received a copy of the GNU Lesser General Public License
   24 # along with MayaChemTools; if not, see <http://www.gnu.org/licenses/> or
   25 # write to the Free Software Foundation Inc., 59 Temple Place, Suite 330,
   26 # Boston, MA, 02111-1307, USA.
   27 #
   28 
   29 from __future__ import print_function
   30 
   31 # Add local python path to the global path and import standard library modules...
   32 import os
   33 import sys;  sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), "..", "lib", "Python"))
   34 import time
   35 import re
   36 
   37 # OpenMM imports...
   38 try:
   39     import openmm as mm
   40     import openmm.app
   41 except ImportError as ErrMsg:
   42     sys.stderr.write("\nFailed to import OpenMM related module/package: %s\n" % ErrMsg)
   43     sys.stderr.write("Check/update your OpenMM environment and try again.\n\n")
   44     sys.exit(1)
   45 
   46 # MDTraj import...
   47 try:
   48     import mdtraj
   49 except ImportError as ErrMsg:
   50     sys.stderr.write("\nFailed to import MDTraj: %s\n" % ErrMsg)
   51     sys.stderr.write("Check/update your MDTraj environment and try again.\n\n")
   52     sys.exit(1)
   53 
   54 # MayaChemTools imports...
   55 try:
   56     from docopt import docopt
   57     import MiscUtil
   58     import OpenMMUtil
   59 except ImportError as ErrMsg:
   60     sys.stderr.write("\nFailed to import MayaChemTools module/package: %s\n" % ErrMsg)
   61     sys.stderr.write("Check/update your MayaChemTools environment and try again.\n\n")
   62     sys.exit(1)
   63 
   64 ScriptName = os.path.basename(sys.argv[0])
   65 Options = {}
   66 OptionsInfo = {}
   67 
   68 def main():
   69     """Start execution of the script."""
   70     
   71     MiscUtil.PrintInfo("\n%s (OpenMM v%s; MayaChemTools v%s; %s): Starting...\n" % (ScriptName, mm.Platform.getOpenMMVersion(), MiscUtil.GetMayaChemToolsVersion(), time.asctime()))
   72     
   73     (WallClockTime, ProcessorTime) = MiscUtil.GetWallClockAndProcessorTime()
   74     
   75     # Retrieve command line arguments and options...
   76     RetrieveOptions()
   77     
   78     # Process and validate command line arguments and options...
   79     ProcessOptions()
   80 
   81     # Perform actions required by the script...
   82     PerformMDSimulation()
   83     
   84     MiscUtil.PrintInfo("\n%s: Done...\n" % ScriptName)
   85     MiscUtil.PrintInfo("Total time: %s" % MiscUtil.GetFormattedElapsedTime(WallClockTime, ProcessorTime))
   86 
   87 def PerformMDSimulation():
   88     """Perform MD simulation."""
   89 
   90     # Prepare system for simulation...
   91     System, Topology, Positions = PrepareSystem()
   92 
   93     # Freeze and restraint atoms...
   94     FreezeRestraintAtoms(System, Topology, Positions)
   95 
   96     # Setup integrator...
   97     Integrator = SetupIntegrator()
   98 
   99     # Setup simulation...
  100     Simulation = SetupSimulation(System, Integrator, Topology, Positions)
  101 
  102     # Write setup files...
  103     WriteSimulationSetupFiles(System, Integrator)
  104 
  105     # Perform minimization...
  106     PerformMinimization(Simulation)
  107 
  108     # Set up intial velocities...
  109     SetupInitialVelocities(Simulation)
  110 
  111     # Perform equilibration...
  112     PerformEquilibration(Simulation)
  113 
  114     #  Setup reporters for production run...
  115     SetupReporters(Simulation)
  116 
  117     #  Perform or restart production run...
  118     PerformOrRestartProductionRun(Simulation)
  119 
  120     # Save final state files...
  121     WriteFinalStateFiles(Simulation)
  122 
  123     # Reimage and realign trajectory for periodic systems...
  124     ProcessTrajectory(System, Topology)
  125 
  126 def PrepareSystem():
  127     """Prepare system for simulation."""
  128 
  129     System, Topology, Positions  = OpenMMUtil.InitializeSystem(OptionsInfo["Infile"], OptionsInfo["ForcefieldParams"], OptionsInfo["SystemParams"], OptionsInfo["WaterBox"], OptionsInfo["WaterBoxParams"], OptionsInfo["SmallMolFile"], OptionsInfo["SmallMolID"])
  130 
  131     if OptionsInfo["NPTMode"]:
  132         BarostatHandle = OpenMMUtil.InitializeBarostat(OptionsInfo["IntegratorParams"])
  133         MiscUtil.PrintInfo("Adding barostat to system for NPT simulation...")
  134         try:
  135             System.addForce(BarostatHandle)
  136         except Exception as ErrMsg:
  137             MiscUtil.PrintInfo("")
  138             MiscUtil.PrintError("Failed to add barostat:\n%s\n" % (ErrMsg))
  139 
  140     # Write out a PDB file for the system...
  141     PDBFile = OptionsInfo["PDBOutfile"]
  142     if OptionsInfo["RestartMode"]:
  143         MiscUtil.PrintInfo("\nSkipping wrriting of PDB file %s during restart..." % PDBFile)
  144     else:
  145         MiscUtil.PrintInfo("\nWriting PDB file %s..." % PDBFile)
  146         OpenMMUtil.WritePDBFile(PDBFile, Topology, Positions, OptionsInfo["OutputParams"]["PDBOutKeepIDs"])
  147 
  148     return (System, Topology, Positions)
  149 
  150 def SetupIntegrator():
  151     """Setup integrator. """
  152 
  153     Integrator = OpenMMUtil.InitializeIntegrator(OptionsInfo["IntegratorParams"], OptionsInfo["SystemParams"]["ConstraintErrorTolerance"])
  154 
  155     return Integrator
  156 
  157 def SetupSimulation(System, Integrator, Topology, Positions):
  158     """Setup simulation. """
  159 
  160     Simulation = OpenMMUtil.InitializeSimulation(System, Integrator, Topology, Positions, OptionsInfo["PlatformParams"])
  161 
  162     return Simulation
  163 
  164 def SetupInitialVelocities(Simulation):
  165     """Setup initial velocities."""
  166 
  167     # Set velocities to random values choosen from a Boltzman distribution at a given
  168     # temperature...
  169     if OptionsInfo["RestartMode"]:
  170         MiscUtil.PrintInfo("\nSkipping settting of intial velocities to temperature during restart...")
  171     else:
  172         MiscUtil.PrintInfo("\nSettting intial velocities to temperature...")
  173         IntegratorParamsInfo = OpenMMUtil.SetupIntegratorParameters(OptionsInfo["IntegratorParams"])
  174         Simulation.context.setVelocitiesToTemperature(IntegratorParamsInfo["Temperature"])
  175 
  176 def PerformMinimization(Simulation):
  177     """Perform minimization."""
  178 
  179     SimulationParams = OpenMMUtil.SetupSimulationParameters(OptionsInfo["SimulationParams"])
  180 
  181     if OptionsInfo["RestartMode"]:
  182         MiscUtil.PrintInfo("\nSkipping energy minimization during restart...")
  183         return
  184     else:
  185         if not SimulationParams["Minimization"]:
  186             MiscUtil.PrintInfo("\nSkipping energy minimization...")
  187             return
  188 
  189     OutputParams = OptionsInfo["OutputParams"]
  190 
  191     # Setup a local minimization reporter...
  192     MinimizeReporter = None
  193     if OutputParams["MinimizationDataStdout"] or OutputParams["MinimizationDataLog"]:
  194         MinimizeReporter = LocalMinimizationReporter()
  195 
  196     if MinimizeReporter is not None:
  197         MiscUtil.PrintInfo("\nAdding minimization reporters...")
  198         if OutputParams["MinimizationDataLog"]:
  199             MiscUtil.PrintInfo("Adding data log minimization reporter (Steps: %s; File: %s)..." % (OutputParams["MinimizationDataSteps"], OutputParams["MinimizationDataLogFile"]))
  200         if OutputParams["MinimizationDataStdout"]:
  201             MiscUtil.PrintInfo("Adding data stdout minimization reporter (Steps: %s)..." % (OutputParams["MinimizationDataSteps"]))
  202     else:
  203         MiscUtil.PrintInfo("\nSkipping addition of minimization reporters...")
  204         
  205     MaxSteps = SimulationParams["MinimizationMaxSteps"]
  206 
  207     MaxStepsMsg = "MaxSteps: %s" % ("UntilConverged" if MaxSteps == 0 else MaxSteps)
  208     ToleranceMsg = "Tolerance: %.2f kcal/mol/A (%.2f kjoules/mol/nm)" % (SimulationParams["MinimizationToleranceInKcal"], SimulationParams["MinimizationToleranceInJoules"])
  209 
  210     MiscUtil.PrintInfo("\nPerforming energy minimization (%s; %s)..." % (MaxStepsMsg, ToleranceMsg))
  211 
  212     if OutputParams["MinimizationDataStdout"]:
  213         HeaderLine = SetupMinimizationDataOutHeaderLine()
  214         print("\n%s" % HeaderLine)
  215 
  216     Simulation.minimizeEnergy(tolerance = SimulationParams["MinimizationTolerance"], maxIterations = MaxSteps, reporter = MinimizeReporter)
  217 
  218     if OutputParams["MinimizationDataLog"]:
  219         WriteMinimizationDataLogFile(MinimizeReporter.DataOutValues)
  220 
  221     if OutputParams["PDBOutMinimized"]:
  222         MiscUtil.PrintInfo("\nWriting PDB file %s..." % OptionsInfo["MinimizedPDBOutfile"])
  223         OpenMMUtil.WriteSimulationStatePDBFile(Simulation, OptionsInfo["MinimizedPDBOutfile"], OutputParams["PDBOutKeepIDs"])
  224 
  225 def PerformEquilibration(Simulation):
  226     """Perform equilibration."""
  227 
  228     Mode = OptionsInfo["Mode"]
  229     SimulationParams = OptionsInfo["SimulationParams"]
  230     OutputParams = OptionsInfo["OutputParams"]
  231 
  232     if OptionsInfo["RestartMode"]:
  233         MiscUtil.PrintInfo("\nSkipping equilibration during restart...")
  234         return
  235     else:
  236         if not SimulationParams["Equilibration"]:
  237             MiscUtil.PrintInfo("\nSkipping equilibration...")
  238             return
  239 
  240     EquilibrationSteps = SimulationParams["EquilibrationSteps"]
  241 
  242     IntegratorParamsInfo = OpenMMUtil.SetupIntegratorParameters(OptionsInfo["IntegratorParams"])
  243     StepSize = IntegratorParamsInfo["StepSize"]
  244     
  245     TotalTime = OpenMMUtil.GetFormattedTotalSimulationTime(StepSize, EquilibrationSteps)
  246     MiscUtil.PrintInfo("\nPerforming equilibration (Mode: %s; Steps: %s; StepSize: %s; TotalTime: %s)..." % (Mode, EquilibrationSteps, StepSize, TotalTime))
  247 
  248     # Equilibrate...
  249     Simulation.step(EquilibrationSteps)
  250 
  251     if OutputParams["PDBOutEquilibrated"]:
  252         MiscUtil.PrintInfo("\nWriting PDB file %s..." % OptionsInfo["EquilibratedPDBOutfile"])
  253         OpenMMUtil.WriteSimulationStatePDBFile(Simulation, OptionsInfo["EquilibratedPDBOutfile"], OutputParams["PDBOutKeepIDs"])
  254 
  255 def PerformOrRestartProductionRun(Simulation):
  256     """Perform or restart production run. """
  257 
  258     if OptionsInfo["RestartMode"]:
  259         RestartProductionRun(Simulation)
  260     else:
  261         PerformProductionRun(Simulation)
  262 
  263 def PerformProductionRun(Simulation):
  264     """Perform production run."""
  265 
  266     Mode = OptionsInfo["Mode"]
  267     SimulationParams = OptionsInfo["SimulationParams"]
  268     Steps = SimulationParams["Steps"]
  269 
  270     IntegratorParamsInfo = OpenMMUtil.SetupIntegratorParameters(OptionsInfo["IntegratorParams"])
  271     StepSize = IntegratorParamsInfo["StepSize"]
  272 
  273     if SimulationParams["Equilibration"]:
  274         Simulation.currentStep = 0
  275         Simulation.context.setTime(0.0 * mm.unit.picoseconds)
  276         MiscUtil.PrintInfo("\nSetting current step and current time to 0 for starting production run after equilibration...")
  277         
  278     TotalTime = OpenMMUtil.GetFormattedTotalSimulationTime(StepSize, Steps)
  279     MiscUtil.PrintInfo("\nPerforming production run (Mode: %s; Steps: %s; StepSize: %s; TotalTime: %s)..." % (Mode, Steps, StepSize, TotalTime))
  280 
  281     Simulation.step(Steps)
  282     
  283 def RestartProductionRun(Simulation):
  284     """Restart production run."""
  285 
  286     SimulationParams = OptionsInfo["SimulationParams"]
  287     RestartParams = OptionsInfo["RestartParams"]
  288 
  289     RestartFile = RestartParams["FinalStateFile"]
  290 
  291     Steps = SimulationParams["Steps"]
  292 
  293     IntegratorParamsInfo = OpenMMUtil.SetupIntegratorParameters(OptionsInfo["IntegratorParams"])
  294     StepSize = IntegratorParamsInfo["StepSize"]
  295 
  296     TotalTime = OpenMMUtil.GetFormattedTotalSimulationTime(StepSize, Steps)
  297     MiscUtil.PrintInfo("\nRestarting production run (Steps: %s; StepSize: %s; TotalTime: %s)..." % (Steps, StepSize, TotalTime))
  298 
  299     if RestartParams["FinalStateFileCheckpointMode"]:
  300         MiscUtil.PrintInfo("Loading final state checkpoint file %s...\n" % RestartFile)
  301         Simulation.loadCheckpoint(RestartFile)
  302     elif RestartParams["FinalStateFileXMLMode"]:
  303         MiscUtil.PrintInfo("Loading final state XML f ile %s...\n" % RestartFile)
  304         Simulation.loadState(RestartFile)
  305     else:
  306         MiscUtil.PrintError("The specified final state restart file, %s, is not a valid. Supported file formats: chk or xml" % (RestartFile))
  307 
  308     Simulation.step(Steps)
  309     
  310 def SetupReporters(Simulation):
  311     """Setup reporters. """
  312 
  313     (TrajReporter, DataLogReporter, DataStdoutReporter, CheckpointReporter) = OpenMMUtil.InitializeReporters(OptionsInfo["OutputParams"], OptionsInfo["SimulationParams"]["Steps"], OptionsInfo["DataOutAppendMode"])
  314 
  315     if TrajReporter is None and DataLogReporter is None and DataStdoutReporter is None and  CheckpointReporter is None:
  316         MiscUtil.PrintInfo("\nSkip adding  reporters...")
  317         return
  318 
  319     MiscUtil.PrintInfo("\nAdding reporters...")
  320 
  321     OutputParams = OptionsInfo["OutputParams"]
  322     AppendMsg = ""
  323     if OptionsInfo["RestartMode"]:
  324         AppendMsg = "; Append: Yes" if OptionsInfo["DataOutAppendMode"] else "; Append: No"
  325     if TrajReporter is not None:
  326         MiscUtil.PrintInfo("Adding trajectory reporter (Steps: %s; File: %s%s)..." % (OutputParams["TrajSteps"], OutputParams["TrajFile"], AppendMsg))
  327         Simulation.reporters.append(TrajReporter)
  328 
  329     if CheckpointReporter is not None:
  330         MiscUtil.PrintInfo("Adding checkpoint reporter (Steps: %s; File: %s)..." % (OutputParams["CheckpointSteps"], OutputParams["CheckpointFile"]))
  331         Simulation.reporters.append(CheckpointReporter)
  332 
  333     if DataLogReporter is not None:
  334         MiscUtil.PrintInfo("Adding data log reporter (Steps: %s; File: %s%s)..." % (OutputParams["DataLogSteps"], OutputParams["DataLogFile"], AppendMsg))
  335         Simulation.reporters.append(DataLogReporter)
  336 
  337     if DataStdoutReporter is not None:
  338         MiscUtil.PrintInfo("Adding data stdout reporter (Steps: %s)..." % (OutputParams["DataStdoutSteps"]))
  339         Simulation.reporters.append(DataStdoutReporter)
  340 
  341 class LocalMinimizationReporter(mm.MinimizationReporter):
  342     """Setup a local minimization reporter. """
  343 
  344     (DataSteps, DataOutTypeList, DataOutDelimiter, StdoutStatus) = [None] * 4
  345 
  346     DataOutValues = []
  347     First = True
  348 
  349     def report(self, Iteration, PositonsList, GradientsList, DataStatisticsMap):
  350         """Report and track minimization."""
  351 
  352         if self.First:
  353             # Initialize...
  354             self.DataSteps = OptionsInfo["OutputParams"]["MinimizationDataSteps"]
  355             self.DataOutTypeList = OptionsInfo["OutputParams"]["MinimizationDataOutTypeOpenMMNameList"]
  356             self.DataOutDelimiter = OptionsInfo["OutputParams"]["DataOutDelimiter"]
  357             self.StdoutStatus = True if OptionsInfo["OutputParams"]["MinimizationDataStdout"] else False
  358 
  359             self.First = False
  360 
  361         if Iteration % self.DataSteps == 0:
  362             # Setup data values...
  363             DataValues = []
  364             DataValues.append("%s" % Iteration)
  365             for DataType in self.DataOutTypeList:
  366                 DataValue = "%.4f" % DataStatisticsMap[DataType]
  367                 DataValues.append(DataValue)
  368 
  369             # Track data...
  370             self.DataOutValues.append(DataValues)
  371 
  372             # Print data values...
  373             if self.StdoutStatus:
  374                 print("%s" % self.DataOutDelimiter.join(DataValues))
  375                 
  376         # This method must return a bool. You may return true for early termination.
  377         return False
  378 
  379 def WriteMinimizationDataLogFile(DataOutValues):
  380     """Write minimization data log file. """
  381 
  382     OutputParams = OptionsInfo["OutputParams"]
  383 
  384     Outfile = OutputParams["MinimizationDataLogFile"]
  385     OutDelimiter = OutputParams["DataOutDelimiter"]
  386 
  387     MiscUtil.PrintInfo("\nWriting minimization log file %s..." % Outfile)
  388     OutFH = open(Outfile, "w")
  389 
  390     HeaderLine = SetupMinimizationDataOutHeaderLine()
  391     OutFH.write("%s\n" % HeaderLine)
  392 
  393     for LineWords in DataOutValues:
  394         Line = OutDelimiter.join(LineWords)
  395         OutFH.write("%s\n" % Line)
  396 
  397     OutFH.close()
  398     
  399 def SetupMinimizationDataOutHeaderLine():
  400     """Setup minimization data output header line. """
  401 
  402     LineWords = ["Iteration"]
  403     for Label in OptionsInfo["OutputParams"]["MinimizationDataOutTypeList"]:
  404         if re.match("^(SystemEnergy|RestraintEnergy)$", Label, re.I):
  405             LineWords.append("%s(kjoules/mol)" % Label)
  406         elif re.match("^RestraintStrength$", Label, re.I):
  407             LineWords.append("%s(kjoules/mol/nm^2)" % Label)
  408         else:
  409             LineWords.append(Label)
  410 
  411     Line = OptionsInfo["OutputParams"]["DataOutDelimiter"].join(LineWords)
  412 
  413     return Line
  414 
  415 def FreezeRestraintAtoms(System, Topology, Positions):
  416     """Handle freezing and restraining of atoms."""
  417 
  418     # Get atoms for freezing...
  419     FreezeAtomList = None
  420     if OptionsInfo["FreezeAtoms"]:
  421         FreezeAtomList =  OpenMMUtil.GetAtoms(Topology, OptionsInfo["FreezeAtomsParams"]["CAlphaProteinStatus"], OptionsInfo["FreezeAtomsParams"]["ResidueNames"], OptionsInfo["FreezeAtomsParams"]["Negate"])
  422         if FreezeAtomList is None:
  423             MiscUtil.PrintError("The freeze atoms parameters specified, \"selection, %s, selectionSpec, %s, negate, %s\", - using \"--freezeAtomsParams\" option didn't match any atoms in the system. You must specify a valid set of parameters for freezing atoms or disable freezing using \"No\" value for \"--freezeAtoms\" option.." % (OptionsInfo["FreezeAtomsParams"]["Selection"], OptionsInfo["FreezeAtomsParams"]["SelectionSpec"], OptionsInfo["FreezeAtomsParams"]["Negate"]))
  424 
  425     # Get atoms for restraining...
  426     RestraintAtomList = None
  427     if OptionsInfo["RestraintAtoms"]:
  428         RestraintAtomList =  OpenMMUtil.GetAtoms(Topology, OptionsInfo["RestraintAtomsParams"]["CAlphaProteinStatus"], OptionsInfo["RestraintAtomsParams"]["ResidueNames"], OptionsInfo["RestraintAtomsParams"]["Negate"])
  429         if RestraintAtomList is None:
  430             MiscUtil.PrintError("The restraint atoms parameters specified, \"selection, %s, selectionSpec, %s, negate, %s\", - using \"--restraintAtomsParams\" option didn't match any atoms in the system. You must specify a valid set of parameters for restraining atoms or disable restraining using \"No\" value for \"--restraintAtoms\" option." % (OptionsInfo["RestraintAtomsParams"]["Selection"], OptionsInfo["RestraintAtomsParams"]["SelectionSpec"], OptionsInfo["RestraintAtomsParams"]["Negate"]))
  431 
  432     # Check for atoms to freeze or restraint...
  433     if FreezeAtomList is None and RestraintAtomList is None:
  434         return
  435 
  436     #   Check for overlap between freeze and restraint atoms...
  437     if OpenMMUtil.DoAtomListsOverlap(FreezeAtomList, RestraintAtomList):
  438         MiscUtil.PrintError("The atoms specified using \"--freezeAtomsParams\" and \"--restraintAtomsParams\" options appear to overlap. You must specify unique sets of atoms to freeze and restraint.")
  439 
  440     #  Check overlap of freeze atoms with system constraints...
  441     if OpenMMUtil.DoesAtomListOverlapWithSystemConstraints(System, FreezeAtomList):
  442         MiscUtil.PrintError("The atoms specified using \"--freezeAtomsParams\" appear to overlap with atoms being constrained corresponding to the value specified, %s, for paramater name \"constraints\" using \"--systemParams\" option.\n\nYou must specify a unique set of atoms to freeze or turn off system constaints by specifying value, None, for \"constraints\" parameter using option \"--systemsParams\".\n\nIn addtion, you may want specify, no, value for \"rigidWater\" option.\n\nThe atoms are frozen by setting their particle mass to zero. OpenMM doesn't allow to both constraint atoms and set their mass to zero." % (OptionsInfo["SystemParams"]["Constraints"]))
  443 
  444     #  Check overlap of restraint atoms with system constraints...
  445     if OpenMMUtil.DoesAtomListOverlapWithSystemConstraints(System, RestraintAtomList):
  446         MiscUtil.PrintInfo("")
  447         MiscUtil.PrintWarning("The atoms specified using \"--restraintAtomsParams\" appear to overlap with atoms being constrained corresponding to the value specified, %s, for paramater name \"constraints\" using \"--systemParams\" option. You may want to specify a unique set of atoms to restraints or turn off system constaints by specifying value, None, for \"constraints\" parameter using option \"--systemsParams\"." % (OptionsInfo["SystemParams"]["Constraints"]))
  448 
  449     #  Check and adjust step size...
  450     if FreezeAtomList is not None or RestraintAtomList is not None:
  451         CheckAndAdjustStepSizeDuringFreezeRestraintAtoms()
  452 
  453     # Freeze atoms...
  454     if FreezeAtomList is None:
  455         MiscUtil.PrintInfo("\nSkipping freezing of atoms...")
  456     else:
  457         MiscUtil.PrintInfo("\nFreezing atoms (Selection: %s)..." % OptionsInfo["FreezeAtomsParams"]["Selection"])
  458         OpenMMUtil.FreezeAtoms(System, FreezeAtomList)
  459         
  460     # Restraint atoms...
  461     if RestraintAtomList is None:
  462         MiscUtil.PrintInfo("\nSkipping restraining of atoms...")
  463     else:
  464         MiscUtil.PrintInfo("\nRestraining atoms (Selection: %s)..." % OptionsInfo["RestraintAtomsParams"]["Selection"])
  465         
  466         SprintConstantInKcal = OptionsInfo["RestraintSpringConstant"]
  467         OpenMMUtil.RestraintAtoms(System, Positions, RestraintAtomList, SprintConstantInKcal)
  468 
  469 def CheckAndAdjustStepSizeDuringFreezeRestraintAtoms():
  470     """Check and set step size during freezing or restraining of atoms """
  471 
  472     if re.match("^auto$", OptionsInfo["IntegratorParams"]["StepSizeSpecified"], re.I):
  473         # Automatically set stepSize to 2.0 fs..
  474         OptionsInfo["IntegratorParams"]["StepSize"] = 2.0
  475         MiscUtil.PrintInfo("")
  476         MiscUtil.PrintWarning("The time step has been automatically set to %s fs during freezing or restraining of atoms. You may specify an explicit value for parameter name, stepSize, using \"--integratorParams\" option." % (OptionsInfo["IntegratorParams"]["StepSize"]))
  477     elif OptionsInfo["IntegratorParams"]["StepSize"] > 2:
  478         MiscUtil.PrintInfo("")
  479         MiscUtil.PrintWarning("A word to the wise: The parameter value specified, %s, for parameter name, stepSize, using \"--integratorParams\" option may be too large. You may want to consider using a smaller time step. Othwerwise, your simulation may blow up." % (OptionsInfo["IntegratorParams"]["StepSize"] ))
  480         MiscUtil.PrintInfo("")
  481 
  482 def WriteSimulationSetupFiles(System, Integrator):
  483     """Write simulation setup files for system and integrator."""
  484 
  485     OutputParams = OptionsInfo["OutputParams"]
  486 
  487     if OutputParams["XmlSystemOut"] or OutputParams["XmlIntegratorOut"]:
  488         MiscUtil.PrintInfo("")
  489 
  490     if OutputParams["XmlSystemOut"]:
  491         Outfile = OutputParams["XmlSystemFile"]
  492         MiscUtil.PrintInfo("Writing system setup XML file %s..." % Outfile)
  493         with open(Outfile, mode = "w") as OutFH:
  494             OutFH.write(mm.XmlSerializer.serialize(System))
  495 
  496     if OutputParams["XmlIntegratorOut"]:
  497         Outfile = OutputParams["XmlIntegratorFile"]
  498         MiscUtil.PrintInfo("Writing integrator setup XML file %s..." % Outfile)
  499         with open(Outfile, mode = "w") as OutFH:
  500             OutFH.write(mm.XmlSerializer.serialize(Integrator))
  501 
  502 def WriteFinalStateFiles(Simulation):
  503     """Write final state files. """
  504 
  505     OutputParams = OptionsInfo["OutputParams"]
  506 
  507     if OutputParams["SaveFinalStateCheckpoint"] or OutputParams["SaveFinalStateXML"] or OutputParams["PDBOutFinal"]:
  508         MiscUtil.PrintInfo("")
  509 
  510     if OutputParams["SaveFinalStateCheckpoint"]:
  511         Outfile = OutputParams["SaveFinalStateCheckpointFile"]
  512         MiscUtil.PrintInfo("Writing final state checkpoint file %s..." % Outfile)
  513         Simulation.saveCheckpoint(Outfile)
  514 
  515     if OutputParams["SaveFinalStateXML"]:
  516         Outfile = OutputParams["SaveFinalStateXMLFile"]
  517         MiscUtil.PrintInfo("Writing final state XML file %s..." % Outfile)
  518         Simulation.saveState(Outfile)
  519 
  520     if OutputParams["PDBOutFinal"]:
  521         MiscUtil.PrintInfo("\nWriting PDB file %s..." % OptionsInfo["FinalPDBOutfile"])
  522         OpenMMUtil.WriteSimulationStatePDBFile(Simulation, OptionsInfo["FinalPDBOutfile"], OutputParams["PDBOutKeepIDs"])
  523 
  524 def ProcessTrajectory(System, Topology):
  525     """Reimage and realign trajectory for periodic systems. """
  526 
  527     ReimageFrames = True if OpenMMUtil.DoesSystemUsesPeriodicBoundaryConditions(System) else False
  528     if not ReimageFrames:
  529         MiscUtil.PrintInfo("\nSkipping reimaging and realigning of trajectory for a system not using periodic boundary conditions...")
  530         return
  531 
  532     MiscUtil.PrintInfo("\nReimaging and realigning trajectory for a system using periodic boundary conditions...")
  533 
  534     # Reimage and realign trajectory file...
  535     RealignFrames = True
  536     TrajTopologyFile = OptionsInfo["PDBOutfile"]
  537     TrajFile = OptionsInfo["OutputParams"]["TrajFile"]
  538     Traj, ReimagedStatus, RealignedStatus = OpenMMUtil.ReimageRealignTrajectory(Topology, TrajFile, ReimageFrames, RealignFrames)
  539 
  540     if (Traj is None) or (not ReimagedStatus and not RealignedStatus): 
  541         MiscUtil.PrintInfo("Skipping writing first frame to PDB file %s..." % PDBOutfile)
  542         MiscUtil.PrintInfo("Skippig writing trajectory file %s..." % TrajOutfile)
  543         return
  544 
  545     PDBOutFormat = OptionsInfo["OutputParams"]["PDBOutFormat"]
  546     PDBOutfile = OptionsInfo["ReimagedPDBOutfile"]
  547     TrajOutfile = OptionsInfo["ReimagedTrajOutfile"]
  548 
  549     # Write out first frame...
  550     MiscUtil.PrintInfo("Writing first frame to PDB file %s..." % PDBOutfile)
  551     if re.match("^CIF$", PDBOutFormat, re.I):
  552         # MDTraj doesn't appear to support CIF format. Write it out as a temporary
  553         #  PDB file and convert it using OpenMM...
  554         FileDir, FileRoot, FileExt = MiscUtil.ParseFileName(PDBOutfile)
  555         TmpPDBOutfile = "%s_PID%s.pdb" % (FileRoot, os.getpid())
  556         Traj[0].save(TmpPDBOutfile)
  557 
  558         PDBHandle = OpenMMUtil.ReadPDBFile(TmpPDBOutfile)
  559         OpenMMUtil.WritePDBFile(PDBOutfile, PDBHandle.topology, PDBHandle.positions, OptionsInfo["OutputParams"]["PDBOutKeepIDs"])
  560 
  561         os.remove(TmpPDBOutfile)
  562     else:
  563         Traj[0].save(PDBOutfile)
  564 
  565     # Write out reimaged and realinged trajectory...
  566     MiscUtil.PrintInfo("Writing trajectory file %s..." % TrajOutfile)
  567     Traj.save(TrajOutfile)
  568 
  569 def ProcessOutfilePrefixParameter():
  570     """Process outfile prefix paramater."""
  571 
  572     OutfilePrefix = Options["--outfilePrefix"]
  573 
  574     if not re.match("^auto$", OutfilePrefix, re.I):
  575         OptionsInfo["OutfilePrefix"] = OutfilePrefix
  576         return
  577 
  578     if OptionsInfo["SmallMolFileMode"]:
  579         OutfilePrefix = "%s_%s_Complex" % (OptionsInfo["InfileRoot"], OptionsInfo["SmallMolFileRoot"])
  580     else:
  581         OutfilePrefix = "%s" % (OptionsInfo["InfileRoot"])
  582 
  583     if re.match("^yes$", Options["--waterBox"], re.I):
  584         OutfilePrefix = "%s_Solvated" % (OutfilePrefix)
  585 
  586     OutfilePrefix = "%s_%s" % (OutfilePrefix, OptionsInfo["Mode"])
  587 
  588     OptionsInfo["OutfilePrefix"] = OutfilePrefix
  589 
  590 def ProcessOutfileNames():
  591     """Process outfile names."""
  592 
  593     OutputParams = OptionsInfo["OutputParams"]
  594     OutfileParamNames = ["CheckpointFile", "DataLogFile", "MinimizationDataLogFile", "SaveFinalStateCheckpointFile", "SaveFinalStateXMLFile", "TrajFile", "XmlSystemFile", "XmlIntegratorFile"]
  595     for OutfileParamName in  OutfileParamNames:
  596         OutfileParamValue = OutputParams[OutfileParamName]
  597         if not Options["--overwrite"]:
  598             if os.path.exists(OutfileParamValue):
  599                 MiscUtil.PrintError("The file specified, %s, for parameter name, %s, using option \"--outfileParams\" already exist. Use option \"--ov\" or \"--overwrite\" and try again. " % (OutfileParamValue, OutfileParamName))
  600 
  601     PDBOutfile = "%s.%s" % (OptionsInfo["OutfilePrefix"], OutputParams["PDBOutfileExt"])
  602     ReimagedPDBOutfile = "%s_Reimaged.%s" % (OptionsInfo["OutfilePrefix"], OutputParams["PDBOutfileExt"])
  603     ReimagedTrajOutfile = "%s_Reimaged.%s" % (OptionsInfo["OutfilePrefix"], OutputParams["TrajFileExt"])
  604 
  605     MinimizedPDBOutfile = "%s_Minimized.%s" % (OptionsInfo["OutfilePrefix"], OutputParams["PDBOutfileExt"])
  606     EquilibratedPDBOutfile = "%s_Equilibrated.%s" % (OptionsInfo["OutfilePrefix"], OutputParams["PDBOutfileExt"])
  607     FinalPDBOutfile = "%s_Final.%s" % (OptionsInfo["OutfilePrefix"], OutputParams["PDBOutfileExt"])
  608 
  609     for Outfile in [PDBOutfile, ReimagedPDBOutfile, ReimagedTrajOutfile, MinimizedPDBOutfile, EquilibratedPDBOutfile, FinalPDBOutfile]:
  610         if not Options["--overwrite"]:
  611             if os.path.exists(Outfile):
  612                 MiscUtil.PrintError("The file name, %s, generated using option \"--outfilePrefix\" already exist. Use option \"--ov\" or \"--overwrite\" and try again. " % (Outfile))
  613     OptionsInfo["PDBOutfile"] = PDBOutfile
  614     OptionsInfo["ReimagedPDBOutfile"] = ReimagedPDBOutfile
  615     OptionsInfo["ReimagedTrajOutfile"] = ReimagedTrajOutfile
  616 
  617     OptionsInfo["MinimizedPDBOutfile"] = MinimizedPDBOutfile
  618     OptionsInfo["EquilibratedPDBOutfile"] = EquilibratedPDBOutfile
  619     OptionsInfo["FinalPDBOutfile"] = FinalPDBOutfile
  620 
  621 def ProcessRestartParameters():
  622     """Process restart parameters. """
  623 
  624     OptionsInfo["RestartMode"] = True if re.match("^yes$", Options["--restart"], re.I) else False
  625     OptionsInfo["RestartParams"] = OpenMMUtil.ProcessOptionOpenMMRestartParameters("--restartParams", Options["--restartParams"], OptionsInfo["OutfilePrefix"])
  626     if OptionsInfo["RestartMode"]:
  627         RestartFile = OptionsInfo["RestartParams"]["FinalStateFile"]
  628         if not os.path.exists(RestartFile):
  629             MiscUtil.PrintError("The file specified, %s, for parameter name, finalStateFile, using option \"--restartParams\" doesn't exist." % (RestartFile))
  630 
  631     DataOutAppendMode = False
  632     if OptionsInfo["RestartMode"]:
  633         DataOutAppendMode = True if OptionsInfo["RestartParams"]["DataAppend"] else False
  634     OptionsInfo["DataOutAppendMode"] = DataOutAppendMode
  635 
  636 def ProcessWaterBoxParameters():
  637     """Process water box parameters. """
  638 
  639     OptionsInfo["WaterBox"] = True if re.match("^yes$", Options["--waterBox"], re.I) else False
  640     OptionsInfo["WaterBoxParams"] = OpenMMUtil.ProcessOptionOpenMMWaterBoxParameters("--waterBoxParams", Options["--waterBoxParams"])
  641     
  642     if OptionsInfo["WaterBox"]:
  643         if OptionsInfo["ForcefieldParams"]["ImplicitWater"]:
  644             MiscUtil.PrintInfo("")
  645             MiscUtil.PrintWarning("The value, %s, specified using option \"--waterBox\" may not be valid for the combination of biopolymer and water forcefields, %s and %s, specified using \"--forcefieldParams\". You may consider using a valid combination of biopolymer and water forcefields for explicit water during the addition of a water box." % (Options["--waterBox"], OptionsInfo["ForcefieldParams"]["Biopolymer"], OptionsInfo["ForcefieldParams"]["Water"]))
  646 
  647 def ProcessOptions():
  648     """Process and validate command line arguments and options."""
  649 
  650     MiscUtil.PrintInfo("Processing options...")
  651 
  652     ValidateOptions()
  653 
  654     OptionsInfo["Infile"] = Options["--infile"]
  655     FileDir, FileName, FileExt = MiscUtil.ParseFileName(OptionsInfo["Infile"])
  656     OptionsInfo["InfileRoot"] = FileName
  657 
  658     SmallMolFile = Options["--smallMolFile"]
  659     SmallMolID = Options["--smallMolID"]
  660     SmallMolFileMode = False
  661     SmallMolFileRoot = None
  662     if SmallMolFile is not None:
  663         FileDir, FileName, FileExt = MiscUtil.ParseFileName(SmallMolFile)
  664         SmallMolFileRoot = FileName
  665         SmallMolFileMode = True
  666 
  667     OptionsInfo["SmallMolFile"] = SmallMolFile
  668     OptionsInfo["SmallMolFileRoot"] = SmallMolFileRoot
  669     OptionsInfo["SmallMolFileMode"] = SmallMolFileMode
  670     OptionsInfo["SmallMolID"] = SmallMolID.upper()
  671     
  672     OptionsInfo["Mode"] = Options["--mode"].upper()
  673     OptionsInfo["NPTMode"] = True if re.match("^NPT$", OptionsInfo["Mode"]) else False
  674     OptionsInfo["NVTMode"] = True if re.match("^NVT$", OptionsInfo["Mode"]) else False
  675     
  676     ProcessOutfilePrefixParameter()
  677 
  678     if OptionsInfo["NVTMode"]:
  679         ParamsDefaultInfoOverride = {"DataOutType": "Step Speed Progress PotentialEnergy Temperature Time Volume"}
  680     else:
  681         ParamsDefaultInfoOverride = {"DataOutType": "Step Speed Progress PotentialEnergy Temperature Time Density"}
  682     OptionsInfo["OutputParams"] = OpenMMUtil.ProcessOptionOpenMMOutputParameters("--outputParams", Options["--outputParams"], OptionsInfo["OutfilePrefix"], ParamsDefaultInfoOverride)
  683     ProcessOutfileNames()
  684 
  685     OptionsInfo["ForcefieldParams"] = OpenMMUtil.ProcessOptionOpenMMForcefieldParameters("--forcefieldParams", Options["--forcefieldParams"])
  686 
  687     OptionsInfo["FreezeAtoms"] = True if re.match("^yes$", Options["--freezeAtoms"], re.I) else False
  688     if OptionsInfo["FreezeAtoms"]:
  689         OptionsInfo["FreezeAtomsParams"] = OpenMMUtil.ProcessOptionOpenMMAtomsSelectionParameters("--freezeAtomsParams", Options["--freezeAtomsParams"])
  690     else:
  691         OptionsInfo["FreezeAtomsParams"] = None
  692 
  693     ParamsDefaultInfoOverride = {"Name": Options["--platform"], "Threads": 1}
  694     OptionsInfo["PlatformParams"] = OpenMMUtil.ProcessOptionOpenMMPlatformParameters("--platformParams", Options["--platformParams"], ParamsDefaultInfoOverride)
  695 
  696     OptionsInfo["RestraintAtoms"] = True if re.match("^yes$", Options["--restraintAtoms"], re.I) else False
  697     if OptionsInfo["RestraintAtoms"]:
  698         OptionsInfo["RestraintAtomsParams"] = OpenMMUtil.ProcessOptionOpenMMAtomsSelectionParameters("--restraintAtomsParams", Options["--restraintAtomsParams"])
  699     else:
  700         OptionsInfo["RestraintAtomsParams"] = None
  701     OptionsInfo["RestraintSpringConstant"] = float(Options["--restraintSpringConstant"])
  702 
  703     ProcessRestartParameters()
  704 
  705     OptionsInfo["SystemParams"] = OpenMMUtil.ProcessOptionOpenMMSystemParameters("--systemParams", Options["--systemParams"])
  706 
  707     OptionsInfo["IntegratorParams"] = OpenMMUtil.ProcessOptionOpenMMIntegratorParameters("--integratorParams", Options["--integratorParams"], HydrogenMassRepartioningStatus = OptionsInfo["SystemParams"]["HydrogenMassRepartioning"])
  708 
  709     OptionsInfo["SimulationParams"] = OpenMMUtil.ProcessOptionOpenMMSimulationParameters("--simulationParams", Options["--simulationParams"])
  710 
  711     ProcessWaterBoxParameters()
  712 
  713     OptionsInfo["Overwrite"] = Options["--overwrite"]
  714 
  715 def RetrieveOptions(): 
  716     """Retrieve command line arguments and options."""
  717     
  718     # Get options...
  719     global Options
  720     Options = docopt(_docoptUsage_)
  721 
  722     # Set current working directory to the specified directory...
  723     WorkingDir = Options["--workingdir"]
  724     if WorkingDir:
  725         os.chdir(WorkingDir)
  726     
  727     # Handle examples option...
  728     if "--examples" in Options and Options["--examples"]:
  729         MiscUtil.PrintInfo(MiscUtil.GetExamplesTextFromDocOptText(_docoptUsage_))
  730         sys.exit(0)
  731 
  732 def ValidateOptions():
  733     """Validate option values."""
  734 
  735     MiscUtil.ValidateOptionFilePath("-i, --infile", Options["--infile"])
  736     MiscUtil.ValidateOptionFileExt("-i, --infile", Options["--infile"], "pdb cif")
  737 
  738     FileDir, FileName, FileExt = MiscUtil.ParseFileName(Options["--infile"])
  739     OutfilePrefix = Options["--outfilePrefix"]
  740     if not re.match("^auto$", OutfilePrefix, re.I):
  741         if re.match("^(%s)$" % OutfilePrefix, FileName, re.I):
  742             MiscUtil.PrintError("The value specified, %s, for option \"--outfilePrefix\" is not valid. You must specify a value different from, %s, the root of infile name." % (OutfilePrefix, FileName))
  743 
  744     if Options["--smallMolFile"] is not None:
  745         MiscUtil.ValidateOptionFilePath("-l, --smallMolFile", Options["--smallMolFile"])
  746         MiscUtil.ValidateOptionFileExt("-l, --smallMolFile", Options["--smallMolFile"], "sd sdf")
  747 
  748     SmallMolID = Options["--smallMolID"]
  749     if len(SmallMolID) != 3:
  750         MiscUtil.PrintError("The value specified, %s, for option \"--smallMolID\" is not valid. You must specify a three letter small molecule ID." % (SmallMolID))
  751 
  752     MiscUtil.ValidateOptionTextValue("--freezeAtoms", Options["--freezeAtoms"], "yes no")
  753     if re.match("^yes$", Options["--freezeAtoms"], re.I):
  754         if Options["--freezeAtomsParams"] is None:
  755             MiscUtil.PrintError("No value specified for option \"--freezeAtomsParams\". You must specify valid values during, yes, value for \"--freezeAtoms\" option.")
  756     
  757     MiscUtil.ValidateOptionTextValue("-m, --mode", Options["--mode"], "NPT NVT")
  758 
  759     MiscUtil.ValidateOptionTextValue("-p, --platform", Options["--platform"], "CPU CUDA OpenCL Reference")
  760 
  761     MiscUtil.ValidateOptionTextValue("-r, --restart ", Options["--restart"], "yes no")
  762 
  763     MiscUtil.ValidateOptionTextValue("--restraintAtoms", Options["--restraintAtoms"], "yes no")
  764     if re.match("^yes$", Options["--restraintAtoms"], re.I):
  765         if Options["--restraintAtomsParams"] is None:
  766             MiscUtil.PrintError("No value specified for option \"--restraintAtomsParams\". You must specify valid values during, yes, value for \"--restraintAtoms\" option.")
  767     
  768     MiscUtil.ValidateOptionFloatValue("--restraintSpringConstant", Options["--restraintSpringConstant"], {">": 0})
  769 
  770     MiscUtil.ValidateOptionTextValue("--waterBox", Options["--waterBox"], "yes no")
  771 
  772 # Setup a usage string for docopt...
  773 _docoptUsage_ = """
  774 OpenMMPerformMDSimulation.py - Perform a MD simulation.
  775 
  776 Usage:
  777     OpenMMPerformMDSimulation.py [--forcefieldParams <Name,Value,..>] [--freezeAtoms <yes or no>]
  778                                  [--freezeAtomsParams <Name,Value,..>] [--integratorParams <Name,Value,..>]
  779                                  [--mode <NVT or NPT>] [--outputParams <Name,Value,..>] [--outfilePrefix <text>]
  780                                  [--overwrite] [--platform <text>] [--platformParams <Name,Value,..>] [--restart <yes or no>]
  781                                  [--restartParams <Name,Value,..>] [--restraintAtoms <yes or no>]
  782                                  [--restraintAtomsParams <Name,Value,..>] [--restraintSpringConstant <number>]
  783                                  [--simulationParams <Name,Value,..>] [--smallMolFile <SmallMolFile>] [--smallMolID <text>]
  784                                  [--systemParams <Name,Value,..>] [--waterBox <yes or no>]
  785                                  [--waterBoxParams <Name,Value,..>] [-w <dir>] -i <infile>
  786     OpenMMPerformMDSimulation.py -h | --help | -e | --examples
  787 
  788 Description: 
  789     Perform a MD simulation using an NPT or NVT statistical ensemble. You may
  790     run a simulation using a macromolecule or a macromolecule in a complex with
  791     small molecule. By default, the system is minimized and equilibrated before the
  792     production run.
  793 
  794     The input file must contain a macromolecule already prepared for simulation.
  795     The preparation of the macromolecule for a simulation generally involves the
  796     following: tasks:  Identification and replacement non-standard residues;
  797     Addition of missing residues; Addition of missing heavy atoms; Addition of
  798     missing hydrogens; Addition of a water box which is optional.
  799 
  800     In addition, the small molecule input file must contain a molecule already
  801     prepared for simulation. It must contain  appropriate 3D coordinates relative
  802     to the macromolecule along with no missing hydrogens.
  803 
  804     You may optionally add a water box and freeze/restraint atoms for the
  805     simulation.
  806 
  807     The supported macromolecule input file formats are:  PDB (.pdb) and
  808     CIF (.cif)
  809 
  810     The supported small molecule input file format are : SD (.sdf, .sd)
  811 
  812     Possible outfile prefixes:
  813          
  814         <InfieRoot>_<Mode>
  815         <InfieRoot>_Solvated_<Mode>
  816         <InfieRoot>_<SmallMolFileRoot>_Complex_<Mode>,
  817         <InfieRoot>_<SmallMolFileRoot>_Complex_Solvated_<Mode>
  818          
  819     Possible output files:
  820          
  821         <OutfilePrefix>.<pdb or cif> [ Initial sytem ]
  822         <OutfilePrefix>.<dcd or xtc>
  823          
  824         <OutfilePrefix>_Reimaged.<pdb or cif> [ First frame ]
  825         <OutfilePrefix>_Reimaged.<dcd or xtc>
  826          
  827         <OutfilePrefix>_Minimized.<pdb or cif>
  828         <OutfilePrefix>_Equilibrated.<pdb or cif>
  829         <OutfilePrefix>_Final.<pdb or cif> [ Final system ]
  830          
  831         <OutfilePrefix>.chk
  832         <OutfilePrefix>.csv
  833         <OutfilePrefix>_Minimization.csv
  834         <OutfilePrefix>_FinalState.chk
  835         <OutfilePrefix>_FinalState.xml
  836          
  837         <OutfilePrefix>_System.xml
  838         <OutfilePrefix>_Integrator.xml
  839          
  840     The reimaged PDB file, <OutfilePrefix>_Reimaged.pdb, corresponds to the first
  841     frame in the trajectory. The reimaged trajectory file contains all the frames
  842     aligned to the first frame after reimaging of the frames for periodic systems.
  843 
  844 Options:
  845     -e, --examples
  846         Print examples.
  847     -f, --forcefieldParams <Name,Value,..>  [default: auto]
  848         A comma delimited list of parameter name and value pairs for biopolymer,
  849         water, and small molecule forcefields.
  850         
  851         The supported parameter names along with their default values are
  852         are shown below:
  853             
  854             biopolymer, amber14-all.xml  [ Possible values: Any Valid value ]
  855             smallMolecule, openff-2.2.1  [ Possible values: Any Valid value ]
  856             water, auto  [ Possible values: Any Valid value ]
  857             additional, none [ Possible values: Space delimited list of any
  858                 valid value ]
  859             
  860         Possible biopolymer forcefield values:
  861             
  862             amber14-all.xml, amber99sb.xml, amber99sbildn.xml, amber03.xml,
  863             amber10.xml
  864             charmm36.xml, charmm_polar_2019.xml
  865             amoeba2018.xml
  866         
  867         Possible small molecule forcefield values:
  868             
  869             openff-2.2.1, openff-2.0.0, openff-1.3.1, openff-1.2.1,
  870             openff-1.1.1, openff-1.1.0,...
  871             smirnoff99Frosst-1.1.0, smirnoff99Frosst-1.0.9,...
  872             gaff-2.11, gaff-2.1, gaff-1.81, gaff-1.8, gaff-1.4,...
  873         
  874         The default water forcefield valus is dependent on the type of the
  875         biopolymer forcefield as shown below:
  876             
  877             Amber: amber14/tip3pfb.xml
  878             CHARMM: charmm36/water.xml or None for charmm_polar_2019.xml
  879             Amoeba: None (Explicit)
  880             
  881         Possible water forcefield values:
  882             
  883             amber14/tip3p.xml, amber14/tip3pfb.xml, amber14/spce.xml,
  884             amber14/tip4pew.xml, amber14/tip4pfb.xml,
  885             charmm36/water.xml, charmm36/tip3p-pme-b.xml,
  886             charmm36/tip3p-pme-f.xml, charmm36/spce.xml,
  887             charmm36/tip4pew.xml, charmm36/tip4p2005.xml,
  888             charmm36/tip5p.xml, charmm36/tip5pew.xml,
  889             implicit/obc2.xml, implicit/GBn.xml, implicit/GBn2.xml,
  890             amoeba2018_gk.xml (Implict water)
  891             None (Explicit water for amoeba)
  892         
  893         The additional forcefield value is a space delimited list of any valid
  894         forcefield values and is passed on to the OpenMMForcefields
  895         SystemGenerator along with the specified forcefield  values for
  896         biopolymer, water, and mall molecule. Possible additional forcefield
  897         values are:
  898             
  899             amber14/DNA.OL15.xml amber14/RNA.OL3.xml
  900             amber14/lipid17.xml amber14/GLYCAM_06j-1.xml
  901             ... ... ...
  902             
  903         You may specify any valid forcefield names supported by OpenMM. No
  904         explicit validation is performed.
  905     --freezeAtoms <yes or no>  [default: no]
  906         Freeze atoms during a simulation. The specified atoms are kept completely
  907         fixed by setting their masses to zero. Their positions do not change during
  908         local energy minimization and MD simulation, and they do not contribute
  909         to the kinetic energy of the system.
  910     --freezeAtomsParams <Name,Value,..>
  911         A comma delimited list of parameter name and value pairs for freezing
  912         atoms during a simulation. You must specify these parameters for 'yes'
  913         value of '--freezeAtoms' option.
  914         
  915         The supported parameter names along with their default values are
  916         are shown below:
  917             
  918             selection, none [ Possible values: CAlphaProtein, Ions, Ligand,
  919                 Protein, Residues, or Water ]
  920             selectionSpec, auto [ Possible values: A space delimited list of
  921                 residue names ]
  922             negate, no [ Possible values: yes or no ]
  923             
  924         A brief description of parameters is provided below:
  925             
  926             selection: Atom selection to freeze.
  927             selectionSpec: A space delimited list of residue names for
  928                 selecting atoms to freeze. You must specify its value during
  929                 'Ligand' and 'Protein' value for 'selection'. The default values
  930                 are automatically set for 'CAlphaProtein', 'Ions', 'Protein',
  931                 and 'Water' values of 'selection' as shown below:
  932                 
  933                 CAlphaProtein: List of stadard protein residues from pdbfixer
  934                     for selecting CAlpha atoms.
  935                 Ions: Li Na K Rb Cs Cl Br F I
  936                 Water: HOH
  937                 Protein: List of standard protein residues from pdbfixer.
  938                 
  939             negate: Negate atom selection match to select atoms for freezing.
  940             
  941         In addition, you may specify an explicit space delimited list of residue
  942         names using 'selectionSpec' for any 'selection". The specified residue
  943         names are appended to the appropriate default values during the
  944         selection of atoms for freezing.
  945     -h, --help
  946         Print this help message.
  947     -i, --infile <infile>
  948         Input file name containing a macromolecule.
  949     --integratorParams <Name,Value,..>  [default: auto]
  950         A comma delimited list of parameter name and value pairs for integrator
  951         during a simulation.
  952         
  953         The supported parameter names along with their default values are
  954         are shown below:
  955             
  956             integrator, LangevinMiddle [ Possible values: LangevinMiddle,
  957                 Langevin, NoseHoover, Brownian ]
  958             
  959             randomSeed, auto [ Possible values: > 0 ]
  960             
  961             frictionCoefficient, 1.0 [ Units: 1/ps ]
  962             stepSize, auto [ Units: fs; Default value: 4 fs during yes value of
  963                 hydrogen mass repartioning with no freezing/restraining of atoms;
  964                 otherwsie, 2 fs ] 
  965             temperature, 300.0 [ Units: kelvin ]
  966             
  967             barostat, MonteCarlo [ Possible values: MonteCarlo or
  968                 MonteCarloMembrane ]
  969             barostatInterval, 25
  970             pressure, 1.0 [ Units: atm ]
  971             
  972             Parameters used only for MonteCarloMembraneBarostat with default
  973             values corresponding to Amber forcefields:
  974             
  975             surfaceTension, 0.0 [ Units: atm*A. It is automatically converted 
  976                 into OpenMM default units of atm*nm before its usage.  ]
  977             xymode,  Isotropic [ Possible values: Anisotropic or  Isotropic ]
  978             zmode,  Free [ Possible values: Free or  Fixed ]
  979             
  980         A brief description of parameters is provided below:
  981             
  982             integrator: Type of integrator
  983             
  984             randomSeed: Random number seed for barostat and integrator. Not
  985                 supported for NoseHoover integrator.
  986             
  987             frictionCoefficient: Friction coefficient for coupling the system to
  988                 the heat bath..
  989             stepSize: Simulation time step size.
  990             temperature: Simulation temperature.
  991             
  992             barostat: Barostat type.
  993             barostatInterval: Barostat interval step size during NPT
  994                 simulation for applying Monte Carlo pressure changes.
  995             pressure: Pressure during NPT simulation. 
  996             
  997             Parameters used only for MonteCarloMembraneBarostat:
  998             
  999             surfaceTension: Surface tension acting on the system.
 1000             xymode: Behavior along X and Y axes. You may allow the X and Y axes
 1001                 to vary independently of each other or always scale them by the same
 1002                 amount to keep the ratio of their lengths constant.
 1003             zmode: Beahvior along Z axis. You may allow the Z axis to vary
 1004                 independently of the other axes or keep it fixed.
 1005             
 1006     -m, --mode <NPT or NVT>  [default: NPT]
 1007         Type of statistical ensemble to use for simulation. Possible values:
 1008         NPT (constant Number of particles, Pressure, and Temperature) or
 1009         NVT ((constant Number of particles, Volume and Temperature)
 1010     --outfilePrefix <text>  [default: auto]
 1011         File prefix for generating the names of output files. The default value
 1012         depends on the names of input files for macromolecule and small molecule
 1013         along with the type of statistical ensemble and the nature of the solvation.
 1014         
 1015         The possible values for outfile prefix are shown below:
 1016             
 1017             <InfieRoot>_<Mode>
 1018             <InfieRoot>_Solvated_<Mode>
 1019             <InfieRoot>_<SmallMolFileRoot>_Complex_<Mode>,
 1020             <InfieRoot>_<SmallMolFileRoot>_Complex_Solvated_<Mode>
 1021             
 1022     --outputParams <Name,Value,..>  [default: auto]
 1023         A comma delimited list of parameter name and value pairs for generating
 1024        output during a simulation.
 1025         
 1026         The supported parameter names along with their default values are
 1027         are shown below:
 1028             
 1029             checkpoint, no  [ Possible values: yes or no ]
 1030             checkpointFile, auto  [ Default: <OutfilePrefix>.chk ]
 1031             checkpointSteps, 10000
 1032             
 1033             dataOutType, auto [ Possible values: A space delimited list of valid
 1034                 parameter names.
 1035                 NPT simulation default: Density Step Speed Progress
 1036                 PotentialEnergy Temperature Time.
 1037                 NVT simulation default: Step Speed Progress PotentialEnergy
 1038                 Temperature Time Volumne
 1039                 Other valid names: ElapsedTime RemainingTime KineticEnergy
 1040                 TotalEnergy  ]
 1041             
 1042             dataLog, yes  [ Possible values: yes or no ]
 1043             dataLogFile, auto  [ Default: <OutfilePrefix>.csv ]
 1044             dataLogSteps, 1000
 1045             
 1046             dataStdout, no  [ Possible values: yes or no ]
 1047             dataStdoutSteps, 1000
 1048             
 1049             minimizationDataSteps, 100
 1050             minimizationDataStdout, no  [ Possible values: yes or no ]
 1051             minimizationDataLog, no  [ Possible values: yes or no ]
 1052             minimizationDataLogFile, auto  [ Default:
 1053                 <OutfilePrefix>_MinimizationOut.csv ]
 1054             minimizationDataOutType, auto [ Possible values: A space delimited
 1055                list of valid parameter names.  Default: SystemEnergy
 1056                RestraintEnergy MaxConstraintError.
 1057                Other valid names: RestraintStrength ]
 1058             
 1059             pdbOutFormat, PDB  [ Possible values: PDB or CIF ]
 1060             pdbOutKeepIDs, yes  [ Possible values: yes or no ]
 1061             
 1062             pdbOutMinimized, no  [ Possible values: yes or no ]
 1063             pdbOutEquilibrated, no  [ Possible values: yes or no ]
 1064             pdbOutFinal, no  [ Possible values: yes or no ]
 1065             
 1066             saveFinalStateCheckpoint, yes  [ Possible values: yes or no ]
 1067             saveFinalStateCheckpointFile, auto  [ Default:
 1068                 <OutfilePrefix>_FinalState.chk ]
 1069             saveFinalStateXML, no  [ Possible values: yes or no ]
 1070             saveFinalStateXMLFile, auto  [ Default:
 1071                 <OutfilePrefix>_FinalState.xml]
 1072             
 1073             traj, yes  [ Possible values: yes or no ]
 1074             trajFile, auto  [ Default: <OutfilePrefix>.<TrajFormat> ]
 1075             trajFormat, DCD  [ Possible values: DCD or XTC ]
 1076             trajSteps, 10000 [ The default value corresponds to 40 ps for step
 1077                 size of 4 fs. ]
 1078             
 1079             xmlSystemOut, no  [ Possible values: yes or no ]
 1080             xmlSystemFile, auto  [ Default: <OutfilePrefix>_System.xml ]
 1081             xmlIntegratorOut, no  [ Possible values: yes or no ]
 1082             xmlIntegratorFile, auto  [ Default: <OutfilePrefix>_Integrator.xml ]
 1083             
 1084         A brief description of parameters is provided below:
 1085             
 1086             checkpoint: Write intermediate checkpoint file.
 1087             checkpointFile: Intermediate checkpoint file name.
 1088             checkpointSteps: Frequency of writing intermediate checkpoint file.
 1089             
 1090             dataOutType: Type of data to write to stdout and log file.
 1091             
 1092             dataLog: Write data to log file.
 1093             dataLogFile: Data log file name.
 1094             dataLogSteps: Frequency of writing data to log file.
 1095             
 1096             dataStdout: Write data to stdout.
 1097             dataStdoutSteps: Frequency of writing data to stdout.
 1098             
 1099             minimizationDataSteps: Frequency of writing data to stdout
 1100                 and log file.
 1101             minimizationDataStdout: Write data to stdout.
 1102             minimizationDataLog: Write data to log file.
 1103             minimizationDataLogFile: Data log fie name.
 1104             minimizationDataOutType: Type of data to write to stdout
 1105                 and log file.
 1106             
 1107             saveFinalStateCheckpoint: Save final state checkpoint file.
 1108             saveFinalStateCheckpointFile: Name of final state checkpoint file.
 1109             saveFinalStateXML: Save final state XML file.
 1110             saveFinalStateXMLFile: Name of final state XML file.
 1111             
 1112             pdbOutFormat: Format of output PDB files.
 1113             pdbOutKeepIDs: Keep existing chain and residue IDs.
 1114             
 1115             pdbOutMinimized: Write PDB file after minimization.
 1116             pdbOutEquilibrated: Write PDB file after equilibration.
 1117             pdbOutFinal: Write final PDB file after production run.
 1118             
 1119             traj: Write out trajectory file.
 1120             trajFile: Trajectory file name.
 1121             trajFormat: Trajectory file format.
 1122             trajSteps: Frequency of writing trajectory file.
 1123             
 1124             xmlSystemOut: Write system XML file.
 1125             xmlSystemFile: System XML file name.
 1126             xmlIntegratorOut: Write integrator XML file.
 1127             xmlIntegratorFile: Integrator XML file name.
 1128             
 1129     --overwrite
 1130         Overwrite existing files.
 1131     -p, --platform <text>  [default: CPU]
 1132         Platform to use for running MD simulation. Possible values: CPU, CUDA,
 1133        OpenCL, or Reference.
 1134     --platformParams <Name,Value,..>  [default: auto]
 1135         A comma delimited list of parameter name and value pairs to configure
 1136         platform for running MD simulation.
 1137         
 1138         The supported parameter names along with their default values for
 1139         different platforms are shown below:
 1140             
 1141             CPU:
 1142             
 1143             threads, 1  [ Possible value: >= 0 or auto.  The value of 'auto'
 1144                 or zero implies the use of all available CPUs for threading. ]
 1145             
 1146             CUDA:
 1147             
 1148             deviceIndex, auto  [ Possible values: 0, '0 1' etc. ]
 1149             deterministicForces, auto [ Possible values: yes or no ]
 1150             precision, single  [ Possible values: single, double, or mix ]
 1151             tempDirectory, auto [ Possible value: DirName ]
 1152             useBlockingSync, auto [ Possible values: yes or no ]
 1153             useCpuPme, auto [ Possible values: yes or no ]
 1154             
 1155             OpenCL:
 1156             
 1157             deviceIndex, auto  [ Possible values: 0, '0 1' etc. ]
 1158             openCLPlatformIndex, auto  [ Possible value: Number]
 1159             precision, single  [ Possible values: single, double, or mix ]
 1160             useCpuPme, auto [ Possible values: yes or no ]
 1161             
 1162         A brief description of parameters is provided below:
 1163             
 1164             CPU:
 1165             
 1166             threads: Number of threads to use for simulation.
 1167             
 1168             CUDA:
 1169             
 1170             deviceIndex: Space delimited list of device indices to use for
 1171                 calculations.
 1172             deterministicForces: Generate reproducible results at the cost of a
 1173                 small decrease in performance.
 1174             precision: Number precision to use for calculations.
 1175             tempDirectory: Directory name for storing temporary files.
 1176             useBlockingSync: Control run-time synchronization between CPU and
 1177                 GPU.
 1178             useCpuPme: Use CPU-based PME implementation.
 1179             
 1180             OpenCL:
 1181             
 1182             deviceIndex: Space delimited list of device indices to use for
 1183                 simulation.
 1184             openCLPlatformIndex: Platform index to use for calculations.
 1185             precision: Number precision to use for calculations.
 1186             useCpuPme: Use CPU-based PME implementation.
 1187             
 1188     -r, --restart <yes or no>  [default: no]
 1189         Restart simulation using a previously saved final state checkpoint or
 1190         XML file.
 1191     --restartParams <Name,Value,..>  [default: auto]
 1192         A comma delimited list of parameter name and value pairs for restarting
 1193         a simulation.
 1194         
 1195         The supported parameter names along with their default values are
 1196         are shown below:
 1197             
 1198             finalStateFile, <OutfilePrefix>_FinalState.<chk>  [ Possible values:
 1199                 Valid final state checkpoint or XML filename ]
 1200             dataAppend, yes [ Possible values: yes or no]
 1201             
 1202         A brief description of parameters is provided below:
 1203             
 1204             finalStateFile: Final state checkpoint or XML file
 1205             dataAppend: Append data to existing trajectory and data log files
 1206                 during the restart of a simulation using a previously saved  final
 1207                 state checkpoint or XML file.
 1208             
 1209     --restraintAtoms <yes or no>  [default: no]
 1210         Restraint atoms during a simulation. The motion of specified atoms is
 1211         restricted by adding a harmonic force that binds them to their starting
 1212         positions. The atoms are not completely fixed unlike freezing of atoms.
 1213         Their motion, however, is restricted and they are not able to move far away
 1214         from their starting positions during local energy minimization and MD
 1215         simulation.
 1216     --restraintAtomsParams <Name,Value,..>
 1217         A comma delimited list of parameter name and value pairs for restraining
 1218         atoms during a simulation. You must specify these parameters for 'yes'
 1219         value of '--restraintAtoms' option.
 1220         
 1221         The supported parameter names along with their default values are
 1222         are shown below:
 1223             
 1224             selection, none [ Possible values: CAlphaProtein, Ions, Ligand,
 1225                 Protein, Residues, or Water ]
 1226             selectionSpec, auto [ Possible values: A space delimited list of
 1227                 residue names ]
 1228             negate, no [ Possible values: yes or no ]
 1229             
 1230         A brief description of parameters is provided below:
 1231             
 1232             selection: Atom selection to restraint.
 1233             selectionSpec: A space delimited list of residue names for
 1234                 selecting atoms to restraint. You must specify its value during
 1235                 'Ligand' and 'Protein' value for 'selection'. The default values
 1236                 are automatically set for 'CAlphaProtein', 'Ions', 'Protein',
 1237                 and 'Water' values of 'selection' as shown below:
 1238                 
 1239                 CAlphaProtein: List of stadard protein residues from pdbfixer
 1240                   for selecting CAlpha atoms.
 1241                 Ions: Li Na K Rb Cs Cl Br F I
 1242                 Water: HOH
 1243                 Protein: List of standard protein residues from pdbfixer.
 1244                 
 1245             negate: Negate atom selection match to select atoms for freezing.
 1246             
 1247         In addition, you may specify an explicit space delimited list of residue
 1248         names using 'selectionSpec' for any 'selection". The specified residue
 1249         names are appended to the appropriate default values during the
 1250         selection of atoms for restraining.
 1251     --restraintSpringConstant <number>  [default: 2.5]
 1252         Restraint spring constant for applying external restraint force to restraint
 1253         atoms relative to their initial positions during 'yes' value of '--restraintAtoms'
 1254         option. Default units: kcal/mol/A**2. The default value, 2.5, corresponds to
 1255         1046.0 kjoules/mol/nm**2. The default value is automatically converted into
 1256         units of kjoules/mol/nm**2 before its usage.
 1257     --simulationParams <Name,Value,..>  [default: auto]
 1258         A comma delimited list of parameter name and value pairs for simulation.
 1259         
 1260         The supported parameter names along with their default values are
 1261         are shown below:
 1262             
 1263             steps, 1000000 [ Possible values: > 0. The default value
 1264                 corresponds to 4 ns for step size of 4 fs. ]
 1265             
 1266             minimization, yes [ Possible values: yes or no ] 
 1267             minimizationMaxSteps, auto  [ Possible values: >= 0. The value of
 1268                 zero implies until the minimization is converged. ]
 1269             minimizationTolerance, 0.24  [ Units: kcal/mol/A. The default value
 1270                 0.25, corresponds to OpenMM default of value of 10.04
 1271                 kjoules/mol/nm. It is automatically converted into OpenMM
 1272                 default units before its usage. ]
 1273             
 1274             equilibration, yes [ Possible values: yes or no ] 
 1275             equilibrationSteps, 1000  [ Possible values: > 0 ]
 1276             
 1277         A brief description of parameters is provided below:
 1278             
 1279             steps: Number of steps for production run.
 1280             
 1281             minimization: Perform minimization before equilibration and
 1282                 production run.
 1283             minimizationMaxSteps: Maximum number of minimization steps. The
 1284                 value of zero implies until the minimization is converged.
 1285             minimizationTolerance: Energy convergence tolerance during
 1286                 minimization.
 1287             
 1288             equilibration: Perform equilibration before the production run.
 1289             equilibrationSteps: Number of steps for equilibration.
 1290             
 1291     -s, --smallMolFile <SmallMolFile>
 1292         Small molecule input file name. The macromolecue and small molecule are
 1293         merged for simulation and the complex is written out to a PDB file.
 1294     --smallMolID <text>  [default: LIG]
 1295         Three letter small molecule residue ID. The small molecule ID corresponds
 1296         to the residue name of the small molecule and is written out to a PDB file
 1297         containing the complex.
 1298     --systemParams <Name,Value,..>  [default: auto]
 1299         A comma delimited list of parameter name and value pairs to configure
 1300         a system for simulation.
 1301         
 1302         The supported parameter names along with their default values are
 1303         are shown below:
 1304             
 1305             constraints, BondsInvolvingHydrogens [ Possible values: None,
 1306                 WaterOnly, BondsInvolvingHydrogens, AllBonds, or
 1307                 AnglesInvolvingHydrogens ]
 1308             constraintErrorTolerance, 0.000001
 1309             ewaldErrorTolerance, 0.0005
 1310             
 1311             nonbondedMethodPeriodic, PME [ Possible values: NoCutoff,
 1312                 CutoffNonPeriodic, or PME ]
 1313             nonbondedMethodNonPeriodic, NoCutoff [ Possible values:
 1314                 NoCutoff or CutoffNonPeriodic]
 1315             nonbondedCutoff, 1.0 [ Units: nm ]
 1316             
 1317             hydrogenMassRepartioning, yes [ Possible values: yes or no ]
 1318             hydrogenMass, 1.5 [ Units: amu]
 1319             
 1320             removeCMMotion, yes [ Possible values: yes or no ]
 1321             rigidWater, auto [ Possible values: yes or no. Default: 'No' for
 1322                'None' value of constraints; Otherwise, yes ]
 1323             
 1324         A brief description of parameters is provided below:
 1325             
 1326             constraints: Type of system constraints to use for simulation. These
 1327                 constraints are different from freezing and restraining of any
 1328                 atoms in the system.
 1329             constraintErrorTolerance: Distance tolerance for constraints as a
 1330                 fraction of the constrained distance.
 1331             ewaldErrorTolerance: Ewald error tolerance for a periodic system.
 1332             
 1333             nonbondedMethodPeriodic: Nonbonded method to use during the
 1334                 calculation of long range interactions for a periodic system.
 1335             nonbondedMethodNonPeriodic: Nonbonded method to use during the
 1336                 calculation of long range interactions for a non-periodic system.
 1337             nonbondedCutoff: Cutoff distance to use for long range interactions
 1338                 in both perioidic non-periodic systems.
 1339             
 1340             hydrogenMassRepartioning: Use hydrogen mass repartioning. It
 1341                 increases the mass of the hydrogen atoms attached to the heavy
 1342                 atoms and decreasing the mass of the bonded heavy atom to
 1343                 maintain constant system mass. This allows the use of larger
 1344                 integration step size (4 fs) during a simulation.
 1345             hydrogenMass: Hydrogen mass to use during repartioning.
 1346             
 1347             removeCMMotion: Remove all center of mass motion at every time step.
 1348             rigidWater: Keep water rigid during a simulation. This is determined
 1349                 automatically based on the value of 'constraints' parameter.
 1350             
 1351     --waterBox <yes or no>  [default: no]
 1352         Add water box.
 1353     --waterBoxParams <Name,Value,..>  [default: auto]
 1354         A comma delimited list of parameter name and value pairs for adding
 1355         a water box.
 1356         
 1357         The supported parameter names along with their default values are
 1358         are shown below:
 1359             
 1360             model, tip3p [ Possible values: tip3p, spce, tip4pew, tip5p or
 1361                 swm4ndp ]
 1362             mode, Padding  [ Possible values: Size or Padding ]
 1363             padding, 1.0
 1364             size, None  [ Possible value: xsize ysize zsize ]
 1365             shape, cube  [ Possible values: cube, dodecahedron, or octahedron ]
 1366             ionPositive, Na+ [ Possible values: Li+, Na+, K+, Rb+, or Cs+ ]
 1367             ionNegative, Cl- [ Possible values: Cl-, Br-, F-, or I- ]
 1368             ionicStrength, 0.0
 1369             
 1370         A brief description of parameters is provided below:
 1371             
 1372             model: Water model to use for adding water box. The van der
 1373                 Waals radii and atomic charges are determined using the
 1374                 specified water forcefield. You must specify an appropriate
 1375                 water forcefield. No validation is performed.
 1376             mode: Specify the size of the waterbox explicitly or calculate it
 1377                 automatically for a macromolecule along with adding padding
 1378                 around ther macromolecule.
 1379             padding: Padding around a macromolecule in nanometers for filling
 1380                 box with water. It must be specified during 'Padding' value of
 1381                 'mode' parameter.
 1382             size: A space delimited triplet of values corresponding to water
 1383                 size in nanometers. It must be specified during 'Size' value of
 1384                 'mode' parameter.
 1385             ionPositive: Type of positive ion to add during the addition of a
 1386                 water box.
 1387             ionNegative: Type of negative ion to add during the addition of a
 1388                 water box.
 1389             ionicStrength: Total concentration of both positive and negative
 1390                 ions to add excluding the ions added to neutralize the system
 1391                 during the addition of a water box.
 1392             
 1393     -w, --workingdir <dir>
 1394         Location of working directory which defaults to the current directory.
 1395 
 1396 Examples:
 1397     To perform a MD simulation for a macromolecule in a PDB file by using an NPT
 1398     ensemble, applying system constraints for bonds involving hydrogens along
 1399     with hydrogen mass repartioning, using a step size of 4 fs, performing minimization
 1400     until it's converged along with equilibration for 1,000 steps ( 4 ps), performing
 1401     production run for 1,000,000 steps (4 ns), writing trajectory file every 10,000
 1402     steps (40 ps), writing data log file every 1,000 steps (4 ps), generating a checkpoint
 1403     file after the completion of the, and generating a PDB for the final system, type:
 1404 
 1405         % OpenMMPerformMDSimulation.py -i Sample13.pdb --waterBox yes
 1406 
 1407     To run the first example for performing OpenMM simulation using multi-
 1408     threading employing all available CPUs on your machine and generate various
 1409     output files, type:
 1410 
 1411         % OpenMMPerformMDSimulation.py -i Sample13.pdb --waterBox yes
 1412           --platformParams "threads,0"
 1413 
 1414     To run the first example for performing OpenMM simulation using CUDA platform
 1415     on your machine and generate various output files, type:
 1416 
 1417         % OpenMMPerformMDSimulation.py -i Sample13.pdb --waterBox yes -p CUDA
 1418 
 1419     To run the second example for a marcomolecule in a complex with a small
 1420     molecule and generate various output files, type:
 1421 
 1422         % OpenMMPerformMDSimulation.py -i Sample13.pdb -s Sample13Ligand.sdf
 1423           --waterBox yes --platformParams "threads,0"
 1424 
 1425     To run the second example for performing NVT simulation and generate various
 1426     output files, type:
 1427 
 1428         % OpenMMPerformMDSimulation.py -i Sample13.pdb -s Sample13Ligand.sdf
 1429           --mode NVT --platformParams "threads,0"
 1430 
 1431         % OpenMMPerformMDSimulation.py -i Sample13.pdb -s Sample13Ligand.sdf
 1432           --mode NVT --waterBox yes --platformParams "threads,0"
 1433 
 1434     To run the second example for a macromolecule in a lipid bilayer, write out
 1435     reimaged and realigned trajectory file for the periodic system, along with a
 1436     PDB file corresponding to the first frame, and generate various output files,
 1437     type:
 1438 
 1439         % OpenMMPerformMDSimulation.py -i Sample12LipidBilayer.pdb
 1440           --platformParams "threads,0" --integratorParams
 1441           "barostat,MonteCarloMembrane"
 1442 
 1443     To run the second example by freezing CAlpha atoms in a macromolecule without
 1444     using any system constraints to avoid any issues with the freezing of the same atoms,
 1445     using a step size of 2 fs, and generate various output files, type:
 1446 
 1447         % OpenMMPerformMDSimulation.py -i Sample13.pdb --waterBox yes
 1448           --freezeAtoms yes --freezeAtomsParams "selection,CAlphaProtein"
 1449           --systemParams "constraints, None"
 1450           --platformParams "threads,0" --integratorParams "stepSize,2"
 1451 
 1452     To run the second example by restrainting CAlpha atoms in a macromolecule and
 1453     and generate various output files, type:
 1454 
 1455         % OpenMMPerformMDSimulation.py -i Sample13.pdb --waterBox yes
 1456           --restraintAtomsParams "selection,CAlphaProtein"
 1457           --platformParams "threads,0" --integratorParams "stepSize,2"
 1458 
 1459     To run the second example for a marcomolecule in a complex with a small
 1460     molecule by using implicit water and generate various output files, type:
 1461 
 1462         % OpenMMPerformMDSimulation.py -i Sample13.pdb -s Sample13Ligand.sdf
 1463           --mode NVT --platformParams "threads,0"
 1464           --forcefieldParams "biopolymer, amber14-all.xml, water,
 1465           implicit/obc2.xml"
 1466 
 1467     To run the second example by specifying explict values for various parametres
 1468     and generate various output files, type:
 1469 
 1470         % OpenMMPerformMDSimulation.py -m NPT -i Sample13.pdb
 1471           -f " biopolymer,amber14-all.xml,smallMolecule, openff-2.2.1,
 1472           water,amber14/tip3pfb.xml" --waterBox yes
 1473           --integratorParams "integrator,LangevinMiddle,randomSeed,42,
 1474           stepSize,2, temperature, 300.0,pressure, 1.0"
 1475           --outputParams "checkpoint,yes,dataLog,yes,dataStdout,yes,
 1476           minimizationDataStdout,yes,minimizationDataLog,yes,
 1477           pdbOutFormat,CIF,pdbOutKeepIDs,yes,saveFinalStateCheckpoint, yes,
 1478           traj,yes,xmlSystemOut,yes,xmlIntegratorOut,yes"
 1479           -p CPU --platformParams "threads,0"
 1480           --simulationParams "steps,10000,minimization,yes,
 1481           minimizationMaxSteps,500,equilibration,yes,equilibrationSteps,1000"
 1482           --systemParams "constraints,BondsInvolvingHydrogens,
 1483           nonbondedMethodPeriodic,PME,nonbondedMethodNonPeriodic,NoCutoff,
 1484           hydrogenMassRepartioning, yes"
 1485 
 1486 Author:
 1487     Manish Sud(msud@san.rr.com)
 1488 
 1489 See also:
 1490     OpenMMPrepareMacromolecule.py, OpenMMPerformMinimization.py
 1491 
 1492 Copyright:
 1493     Copyright (C) 2025 Manish Sud. All rights reserved.
 1494 
 1495     The functionality available in this script is implemented using OpenMM, an
 1496     open source molecuar simulation package.
 1497 
 1498     This file is part of MayaChemTools.
 1499 
 1500     MayaChemTools is free software; you can redistribute it and/or modify it under
 1501     the terms of the GNU Lesser General Public License as published by the Free
 1502     Software Foundation; either version 3 of the License, or (at your option) any
 1503     later version.
 1504 
 1505 """
 1506 
 1507 if __name__ == "__main__":
 1508     main()