Class PotentialScript

java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Script
ffx.utilities.FFXScript
ffx.potential.cli.PotentialScript
All Implemented Interfaces:
groovy.lang.GroovyObject

public abstract class PotentialScript extends FFXScript
Base class for scripts in the Potentials package, providing some key functions.
Since:
1.0
Author:
Michael J. Schnieders
  • Field Details

    • potentialFunctions

      public PotentialsFunctions potentialFunctions
      An instance of PotentialFunctions passed into the current context.
    • activeAssembly

      public MolecularAssembly activeAssembly
      An active MolecularAssembly passed into the current context or loaded by the Script from a file argument.
    • baseDir

      public File baseDir
      A temporary directory that contains script artifacts. Temporary files are often created by unit tests and then deleted.
  • Constructor Details

    • PotentialScript

      public PotentialScript()
      Default constructor.
    • PotentialScript

      public PotentialScript(groovy.lang.Binding binding)
      Create a Script using the supplied Binding.
      Parameters:
      binding - Binding with variables to use.
  • Method Details

    • destroyPotentials

      public boolean destroyPotentials()
      Reclaims resources associated with all Potential objects associated with this script.
      Returns:
      If all Potentials had resources reclaimed.
    • setActiveAssembly

      public void setActiveAssembly(MolecularAssembly molecularAssembly)
      Set the Active Assembly. This is a work-around for a strange Groovy static compilation bug where direct assignment of activeAssembly in Groovy scripts that extend PotentialScript fails (a NPE results).
      Parameters:
      molecularAssembly - The MolecularAssembly that should be active.
    • getPotentials

      public List<Potential> getPotentials()
      Returns a List of all Potential objects associated with this script. Should be written to tolerate nulls, as many tests run help() and exit without instantiating their Potentials.
      Returns:
      All Potentials. Sometimes empty, never null.
    • init

      public boolean init()
      Initialize this Script based on the specified command line arguments.

      Execute the BaseScript init method, then load potential functions.

      Overrides:
      init in class FFXScript
      Returns:
      boolean Returns true if the script should continue and false to exit.
    • getBaseDirString

      public String getBaseDirString(String dirFromFilename)
      Check that we can write into the current base directory. If not, update the baseDir based on the supplied filename, including updating the script Binding instance.
      Parameters:
      dirFromFilename - Set the base directory variable baseDir using this filename if it's not set to a writeable directory.
      Returns:
      Return the base directory as a String (including an appended File.separator).
    • getActiveAssembly

      public MolecularAssembly getActiveAssembly(@Nullable String filename)
      If a filename is supplied, open it and return the MolecularAssembly. Otherwise, the current activeAssembly is returned (which may be null).
      Parameters:
      filename - Filename to open.
      Returns:
      The active assembly.
    • getActiveAssemblies

      public MolecularAssembly[] getActiveAssemblies(@Nullable String filename)
      If a filename is supplied, open it and return the MolecularAssemblies. Otherwise, the current activeAssembly is returned (which may be null).
      Parameters:
      filename - Filename to open.
      Returns:
      The active assemblies.