def _clear_output(self): """Reset stdout and stderr.""" # Call the base class method. super()._clear_output() # Delete any restart and trajectory files in the working directory. file = "%s/sim_restart.s3" % self._work_dir if _os.path.isfile(file): _os.remove(file) file = "%s/SYSTEM.s3" % self._work_dir if _os.path.isfile(file): _os.remove(file) files = _IO.glob("%s/traj*.dcd" % self._work_dir) for file in files: if _os.path.isfile(file): _os.remove(file) # Additional files for free energy simulations. if type(self._protocol) is _Protocol.FreeEnergy: file = "%s/gradients.dat" % self._work_dir if _os.path.isfile(file): _os.remove(file) file = "%s/simfile.dat" % self._work_dir if _os.path.isfile(file): _os.remove(file)
def _find_force_field(forcefield): """Internal function to search LEaP compatible force field files. Parameters ---------- forcefield : str The name of the force field. Returns ------- file : str The full path of the matching force field file. """ # Whether the force field is old. is_old = False # Search for a compatible force field file. ff = _IO.glob("%s/*.%s" % (_cmd_dir, forcefield)) # Search the old force fields. First try a specific match. if len(ff) == 0: ff = _IO.glob("%s/oldff/leaprc.%s" % (_cmd_dir, forcefield)) is_old = True # No matches, try globbing all files with matching extension. if len(ff) == 0: ff = _IO.glob("%s/oldff/*.%s" % (_cmd_dir, forcefield)) # No force field found! if len(ff) == 0: raise ValueError("No force field file found for '%s'" % forcefield) # Multiple force fields found. elif len(ff) > 1: raise ValueError("Multiple force fields found for '%s': %s" % (forcefield, ff)) # Create the force field name. ff = _os.path.basename(ff[0]) if is_old: ff = "oldff/" + ff # Return the force field. return ff