Package ffx.potential.cli
Class PotentialScript
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Script
ffx.utilities.FFXScript
ffx.potential.cli.PotentialScript
- All Implemented Interfaces:
groovy.lang.GroovyObject
Base class for scripts in the Potentials package, providing some key functions.
- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Field Summary
Modifier and TypeFieldDescriptionAn active MolecularAssembly passed into the current context or loaded by the Script from a file argument.A temporary directory that contains script artifacts.An instance of PotentialFunctions passed into the current context. -
Constructor Summary
ConstructorDescriptionDefault constructor.PotentialScript
(groovy.lang.Binding binding) Create a Script using the supplied Binding. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Reclaims resources associated with all Potential objects associated with this script.getActiveAssemblies
(String filename) If a filename is supplied, open it and return the MolecularAssemblies.getActiveAssembly
(String filename) If a filename is supplied, open it and return the MolecularAssembly.getBaseDirString
(String dirFromFilename) Check that we can write into the current base directory.Returns a List of all Potential objects associated with this script.boolean
init()
Initialize this Script based on the specified command line arguments.void
setActiveAssembly
(MolecularAssembly molecularAssembly) Set the Active Assembly.Methods inherited from class ffx.utilities.FFXScript
getScript, helpString, listGroovyScripts, run
Methods inherited from class groovy.lang.Script
evaluate, evaluate, getBinding, getProperty, invokeMethod, print, printf, printf, println, println, run, setBinding, setProperty
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
-
Field Details
-
potentialFunctions
An instance of PotentialFunctions passed into the current context. -
activeAssembly
An active MolecularAssembly passed into the current context or loaded by the Script from a file argument. -
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
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
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.
-
getBaseDirString
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 variablebaseDir
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
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
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.
-