Package ffx.ui

Class UIUtils

All Implemented Interfaces:
AlgorithmFunctions, PotentialsFunctions

public class UIUtils extends AlgorithmUtils implements AlgorithmFunctions
UIUtils implements core and extended functionality for many Force Field X algorithms and scripts, such as opening and closing structure files, basic force field evaluations, molecular dynamics, etc. This implementation performs additional tasks for the FFX graphical user interface, such as updating the GUI and tree structure. This is widely used by our scripts. The AlgorithmUtils and PotentialsUtils implementations of their respective interfaces lack the additional functionality provided here.
Author:
Jacob M. Litman, Michael J. Schnieders
  • Constructor Details

  • Method Details

    • close

      public void close(MolecularAssembly assembly)
      Description copied from class: PotentialsUtils
      Performs any necessary shutdown operations on a MolecularAssembly, primarily shutting down Parallel Java threads and closing any other open resources.

      Shuts down parallel teams in the force field of the provided MolecularAssembly. Kaminsky's ParallelTeamThreads' run() methods are infinite loops, and because running threads are always GC roots, it is necessary to send them a signal to shut down to enable garbage collection.

      Specified by:
      close in interface PotentialsFunctions
      Overrides:
      close in class PotentialsUtils
      Parameters:
      assembly - Assembly to close.
    • closeAll

      public void closeAll(MolecularAssembly[] assemblies)
      Description copied from class: PotentialsUtils
      Performs any necessary shutdown operations on an array of MolecularAssembly, primarily shutting down Parallel Java threads and closing any other open resources.

      Shuts down parallel teams in the force fields of the provided MolecularAssemblys.

      Specified by:
      closeAll in interface PotentialsFunctions
      Overrides:
      closeAll in class PotentialsUtils
      Parameters:
      assemblies - Assemblies to close.
    • energy

      public ForceFieldEnergy energy(MolecularAssembly molecularAssembly)
      Description copied from class: PotentialsUtils
      Evaluates the energy of a MolecularAssembly and returns its ForceFieldEnergy object.

      Evaluates the energy of a MolecularAssembly and returns its ForceFieldEnergy object.

      Specified by:
      energy in interface PotentialsFunctions
      Overrides:
      energy in class PotentialsUtils
      Parameters:
      molecularAssembly - To evaluate
      Returns:
      assembly's ForceFieldEnergy.
    • getActiveAssembly

      public MolecularAssembly getActiveAssembly()
      Description copied from interface: PotentialsFunctions
      Returns either the active assembly from the overlying UI, or the "active" molecular assembly from the last used SystemFilter.
      Specified by:
      getActiveAssembly in interface PotentialsFunctions
      Returns:
      A MolecularAssembly or null
    • getArguments

      public List<String> getArguments()
      Description copied from interface: PotentialsFunctions
      If available, returns CLI arguments; default implementation does not have access to CLI arguments, and throws UnsupportedOperationException.
      Specified by:
      getArguments in interface PotentialsFunctions
      Returns:
      CLI arguments
    • getDefaultListener

      public AlgorithmListener getDefaultListener()
      Description copied from interface: AlgorithmFunctions
      Returns a default Listener if available (null by default).
      Specified by:
      getDefaultListener in interface AlgorithmFunctions
      Returns:
      An AlgorithmListener or null.
    • getFilter

      public SystemFilter getFilter()
      Description copied from class: PotentialsUtils
      Returns the last SystemFilter created by this (can be null).
      Specified by:
      getFilter in interface PotentialsFunctions
      Overrides:
      getFilter in class PotentialsUtils
      Returns:
      Last SystemFilter
    • isLocal

      public boolean isLocal()
      Description copied from class: PotentialsUtils
      True if using a local implementation (not in a user interfaces module).

      Returns true (this is the local implementation).

      Specified by:
      isLocal in interface PotentialsFunctions
      Overrides:
      isLocal in class PotentialsUtils
      Returns:
      If a local implementation
    • md

      public void md(MolecularAssembly assembly, int nStep, double timeStep, double printInterval, double saveInterval, double temperature, boolean initVelocities, File dyn)
      Description copied from class: AlgorithmUtils
      Runs molecular dynamics on an assembly.

      Performs molecular dynamics on a MolecularAssembly.

      Specified by:
      md in interface AlgorithmFunctions
      Overrides:
      md in class AlgorithmUtils
      Parameters:
      assembly - a MolecularAssembly object.
      nStep - Timesteps
      timeStep - Time per step
      printInterval - a double.
      saveInterval - a double.
      temperature - a double.
      initVelocities - Initialize velocities from Maxwell-Boltzmann distribution
      dyn - Dynamics file
    • minimize

      public Potential minimize(MolecularAssembly assembly, double eps)
      Description copied from class: AlgorithmUtils
      Relax the coordinates of a MolecularAssembly and minimize its potential energy

      Minimizes a MolecularAssembly using AMOEBA potential energy.

      Specified by:
      minimize in interface AlgorithmFunctions
      Overrides:
      minimize in class AlgorithmUtils
      Parameters:
      assembly - a MolecularAssembly object.
      eps - RMS gradient convergence criteria
      Returns:
      A Potential
    • open

      public FFXSystem[] open(String[] files, int nThreads)
      Description copied from class: PotentialsUtils
      Opens an array of files and returns all created MolecularAssembly objects, setting any underlying Potential to use a certain number of threads. Default implementation simply ignores nThreads.

      Opens an array of files and returns all created MolecularAssembly objects, setting any underlying Potential to use a certain number of threads.

      Specified by:
      open in interface PotentialsFunctions
      Overrides:
      open in class PotentialsUtils
      Parameters:
      files - an array of String objects.
      nThreads - Use non-default num threads
      Returns:
      Array of MolecularAssembly.
    • open

      public FFXSystem open(String file)
      Description copied from class: PotentialsUtils
      open.
      Specified by:
      open in interface PotentialsFunctions
      Overrides:
      open in class PotentialsUtils
      Parameters:
      file - a String object.
      Returns:
      a MolecularAssembly object.
    • openAll

      public FFXSystem[] openAll(String file)
      Description copied from class: PotentialsUtils
      Opens a file and returns all created MolecularAssembly objects.

      Opens a file and returns all created MolecularAssembly objects.

      Specified by:
      openAll in interface PotentialsFunctions
      Overrides:
      openAll in class PotentialsUtils
      Parameters:
      file - Filename to open
      Returns:
      Array of MolecularAssembly.
    • openAll

      public FFXSystem[] openAll(String[] files)
      Description copied from class: PotentialsUtils
      Opens an array of files and returns the created MolecularAssembly objects.

      Opens an array of files and returns the created MolecularAssembly objects.

      Specified by:
      openAll in interface PotentialsFunctions
      Overrides:
      openAll in class PotentialsUtils
      Parameters:
      files - Filenames to open.
      Returns:
      Array of MolecularAssembly.
    • openAll

      public FFXSystem[] openAll(String file, int nThreads)
      Description copied from class: PotentialsUtils
      Opens a file and returns all created MolecularAssembly objects, setting any underlying Potential to use a certain number of threads. Default implementation simply ignores nThreads.

      Opens a file and returns all created MolecularAssembly objects, setting any underlying Potential to use a certain number of threads.

      Specified by:
      openAll in interface PotentialsFunctions
      Overrides:
      openAll in class PotentialsUtils
      Parameters:
      file - Filename to open
      nThreads - Use non-default num threads
      Returns:
      Array of MolecularAssembly.
    • openWithMutations

      public MolecularAssembly openWithMutations(File file, List<PDBFilter.Mutation> mutations)
      Mutates file on-the-fly as it is being opened. Used to open files for pHMD in fully-protonated form.
      Overrides:
      openWithMutations in class PotentialsUtils
      Parameters:
      file - a File object.
      mutations - a List object.
      Returns:
      a MolecularAssembly object.
    • returnEnergy

      public double returnEnergy(MolecularAssembly assembly)
      Description copied from class: PotentialsUtils
      Returns the energy of a MolecularAssembly in kcal/mol (as a double) and prints the energy evaluation

      Returns the energy of a MolecularAssembly in kcal/mol (as a double) and prints the energy evaluation

      Specified by:
      returnEnergy in interface PotentialsFunctions
      Overrides:
      returnEnergy in class PotentialsUtils
      Parameters:
      assembly - To evaluate energy of
      Returns:
      Potential energy (kcal/mol)
    • save

      public void save(MolecularAssembly assembly, File file)
      Description copied from class: PotentialsUtils
      Saves the current state of a MolecularAssembly to an XYZ file.

      Saves the current state of a MolecularAssembly to an XYZ file.

      Specified by:
      save in interface PotentialsFunctions
      Overrides:
      save in class PotentialsUtils
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .xyz
    • saveAsXYZinP1

      public void saveAsXYZinP1(MolecularAssembly assembly, File file)
      Description copied from class: PotentialsUtils
      Saves the current state of a MolecularAssembly to an XYZ file as a P1 crystal.

      Saves the current state of a MolecularAssembly to an XYZ file as a P1 crystal.

      Specified by:
      saveAsXYZinP1 in interface PotentialsFunctions
      Overrides:
      saveAsXYZinP1 in class PotentialsUtils
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .xyz
    • saveAsPDB

      public void saveAsPDB(MolecularAssembly assembly, File file)
      Description copied from class: PotentialsUtils
      Saves the current state of a MolecularAssembly to a PDB file.

      Saves the current state of a MolecularAssembly to a PDB file.

      Specified by:
      saveAsPDB in interface PotentialsFunctions
      Overrides:
      saveAsPDB in class PotentialsUtils
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .pdb
    • saveAsPDB

      public void saveAsPDB(MolecularAssembly assembly, File file, boolean writeEnd, boolean append)
      Description copied from class: PotentialsUtils

      Saves the current state of a MolecularAssembly to a PDB file.

      Specified by:
      saveAsPDB in interface PotentialsFunctions
      Overrides:
      saveAsPDB in class PotentialsUtils
    • saveAsPDB

      public void saveAsPDB(MolecularAssembly[] assemblies, File file)
      Description copied from class: PotentialsUtils
      Saves the current state of an array of MolecularAssembly instances to a PDB file.

      Saves the current state of an array of MolecularAssemblys to a PDB file.

      Specified by:
      saveAsPDB in interface PotentialsFunctions
      Overrides:
      saveAsPDB in class PotentialsUtils
      Parameters:
      assemblies - MolecularAssembly array to save
      file - Destination .pdb
    • saveAsXYZ

      public void saveAsXYZ(MolecularAssembly assembly, File file)
      Description copied from class: PotentialsUtils
      Saves the current state of a MolecularAssembly to an XYZ file.

      Saves the current state of a MolecularAssembly to an XYZ file.

      Specified by:
      saveAsXYZ in interface PotentialsFunctions
      Overrides:
      saveAsXYZ in class PotentialsUtils
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .xyz
    • saveAsPDBinP1

      public void saveAsPDBinP1(MolecularAssembly assembly, File file)
      Description copied from class: PotentialsUtils
      Saves the symmetry mates of a MolecularAssembly to PDB files.
      Specified by:
      saveAsPDBinP1 in interface PotentialsFunctions
      Overrides:
      saveAsPDBinP1 in class PotentialsUtils
      Parameters:
      assembly - To save
      file - Destination file
    • time

      public double time()
      Description copied from class: AlgorithmUtils
      Logs time elapsed since last call.

      Logs time since this interface was created and the last time this method was called.

      Logs time since this interface was created and the last time this method was called. May be more elegant to replace this by using protected variables and simply inheriting the time() function.

      Specified by:
      time in interface PotentialsFunctions
      Overrides:
      time in class AlgorithmUtils
      Returns:
      Time.