Class PotentialsUtils

java.lang.Object
ffx.potential.utils.PotentialsUtils
All Implemented Interfaces:
PotentialsFunctions
Direct Known Subclasses:
AlgorithmUtils

public class PotentialsUtils extends Object implements PotentialsFunctions
PotentialsUtils implements core functionality for many Force Field X algorithms and scripts, such as opening and closing structure files, basic force field evaluations, etc. This implementation does not do anything on top of what is specified by the interface, and is used primarily by tests. It is also potentially useful for third parties who would like to use FFX without its graphical user interface.
Since:
1.0
Author:
Jacob M. Litman, Michael J. Schnieders
  • Constructor Details

    • PotentialsUtils

      public PotentialsUtils()
      Constructor for PotentialsUtils.
  • Method Details

    • close

      public void close(MolecularAssembly assembly)
      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
      Parameters:
      assembly - Assembly to close.
    • closeAll

      public void closeAll(MolecularAssembly[] assemblies)
      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
      Parameters:
      assemblies - Assemblies to close.
    • energy

      public ForceFieldEnergy energy(MolecularAssembly molecularAssembly)
      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
      Parameters:
      molecularAssembly - To evaluate
      Returns:
      assembly's ForceFieldEnergy.
    • energy

      public ForceFieldEnergy[] energy(MolecularAssembly[] molecularAssemblies)
      Evaluates the energy of each MolecularAssembly and returns their ForceFieldEnergy instances.
      Specified by:
      energy in interface PotentialsFunctions
      Parameters:
      molecularAssemblies - An array of molecularAssembly instances.
      Returns:
      An array of ForceFieldEnergy instances.
    • getFilter

      public SystemFilter getFilter()
      Returns the last SystemFilter created by this (can be null).
      Specified by:
      getFilter in interface PotentialsFunctions
      Returns:
      Last SystemFilter
    • isLocal

      public boolean isLocal()
      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
      Returns:
      If a local implementation
    • open

      public MolecularAssembly open(String filename)
      open.
      Specified by:
      open in interface PotentialsFunctions
      Parameters:
      filename - a String object.
      Returns:
      a MolecularAssembly object.
    • open

      public MolecularAssembly open(File file)
      Return one MolecularAssembly.
      Parameters:
      file - a File object.
      Returns:
      a MolecularAssembly object.
    • open

      public MolecularAssembly[] open(String[] files, int nThreads)
      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
      Parameters:
      files - an array of String objects.
      nThreads - Use non-default num threads
      Returns:
      Array of MolecularAssembly.
    • openAll

      public MolecularAssembly[] openAll(String file)
      Opens a file and returns all created MolecularAssembly objects.

      Opens a file and returns all created MolecularAssembly objects.

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

      public MolecularAssembly[] openAll(String[] files)
      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
      Parameters:
      files - Filenames to open.
      Returns:
      Array of MolecularAssembly.
    • openAll

      public MolecularAssembly[] openAll(String file, int nThreads)
      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
      Parameters:
      file - Filename to open
      nThreads - Use non-default num threads
      Returns:
      Array of MolecularAssembly.
    • openQuietly

      public MolecularAssembly openQuietly(String filename)
      Open one filename string without printing all the header material.
      Parameters:
      filename - a String object.
      Returns:
      a MolecularAssembly object.
    • 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.
      Parameters:
      file - a File object.
      mutations - a List object.
      Returns:
      a MolecularAssembly object.
    • returnEnergy

      public double returnEnergy(MolecularAssembly assembly)
      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
      Parameters:
      assembly - To evaluate energy of
      Returns:
      Potential energy (kcal/mol)
    • save

      public void save(MolecularAssembly assembly, File file)
      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
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .xyz
    • saveAsXYZinP1

      public void saveAsXYZinP1(MolecularAssembly assembly, File file)
      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
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .xyz
    • saveAsXYZasReplicates

      public void saveAsXYZasReplicates(MolecularAssembly assembly, File file, int[] lmn)
      Saves the current state of a MolecularAssembly to an XYZ file as a replicates crystal.

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

      Specified by:
      saveAsXYZasReplicates in interface PotentialsFunctions
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .xyz
      lmn - Dimensions for replicates crystal.
    • saveAsPDB

      public void saveAsPDB(MolecularAssembly assembly, File file)
      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
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .pdb
    • saveAsPDB

      public void saveAsPDB(MolecularAssembly assembly, File file, boolean writeEnd, boolean append)

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

      Specified by:
      saveAsPDB in interface PotentialsFunctions
    • saveAsPDB

      public void saveAsPDB(MolecularAssembly[] assemblies, File file)
      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
      Parameters:
      assemblies - MolecularAssembly array to save
      file - Destination .pdb
    • saveAsXYZ

      public void saveAsXYZ(MolecularAssembly assembly, File file)
      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
      Parameters:
      assembly - MolecularAssembly to save
      file - Destination .xyz
    • saveAsPDBinP1

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

      public void saveAsPDBinP1(MolecularAssembly assembly, File file, int[] lmn)
    • time

      public double time()
      Logs time elapsed since last call.

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

      Specified by:
      time in interface PotentialsFunctions
      Returns:
      Time.