Package ffx.potential.cli
Class PotentialCommand
java.lang.Object
ffx.utilities.FFXCommand
ffx.potential.cli.PotentialCommand
- Direct Known Subclasses:
Biotype,Cart2Frac,ChainBreaks,Density,Energy,ExportQE,Fasta,FeatureMap,FFtoXML,Frac2Cart,Gradient,ImportCIF,LambdaGradient,MoveIntoUnitCell,NucleicAcidAnalysis,PhEnergy,PhGradient,PrepareSpaceGroups,PrmToProperty,ReorderAtoms,SaveAsConstantPhPDB,SaveAsP1,SaveAsPDB,SaveAsXYZ,Solvator,Timer,Volume,VolumeArc,WriteRestraints
Base class for scripts in the Potentials package, providing some key functions.
- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Field Summary
FieldsModifier 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.Fields inherited from class ffx.utilities.FFXCommand
args, binding, color, help, logger, parseResult, version -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.PotentialCommand(FFXBinding binding) Create a Script using the supplied Binding.PotentialCommand(String[] args) Create a Script using the supplied command line arguments. -
Method Summary
Modifier and TypeMethodDescriptioncreateOutputFile(String filepath, String newExtension) Create an output File with a new extension based on the input filepath.booleanReclaims 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.getActiveAssembly(List<String> filenames) If filenames is supplied, open the first entry 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 command.getPotentialsFromAssemblies(MolecularAssembly[] assemblies) Returns a List of all Potential objects from the supplied MolecularAssembly array.booleaninit()Initialize this Command based on the specified command line arguments.parseFilePath(String filepath) Parse a filepath into directory, base name, and extension.voidsaveByExtension(MolecularAssembly[] assemblies, String filename, String extension) Save MolecularAssemblies to a file based on the supplied extension.voidsaveByExtension(MolecularAssembly molecularAssembly, String filename, String extension) Save MolecularAssembly to a file based on the supplied extension.voidsaveByOriginalExtension(MolecularAssembly[] assemblies, String filename) Save MolecularAssemblies to file using the extension of an original filename.voidsaveByOriginalExtension(MolecularAssembly molecularAssembly, String filename) Save MolecularAssembly to a file using the extension of an original filename.voidsetActiveAssembly(MolecularAssembly molecularAssembly) Set the Active Assembly.Methods inherited from class ffx.utilities.FFXCommand
getCommand, helpString, listCommands, run, setBinding
-
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
-
PotentialCommand
public PotentialCommand()Default constructor. -
PotentialCommand
Create a Script using the supplied Binding.- Parameters:
binding- Binding with variables to use.
-
PotentialCommand
Create a Script using the supplied command line arguments.- Parameters:
args- The command line arguments.
-
-
Method Details
-
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 result).- Parameters:
molecularAssembly- The MolecularAssembly that should be active.
-
getPotentials
Returns a List of all Potential objects associated with this command. Should be written to tolerate nulls, as many tests run help() and exit without instantiating their Potentials.- Returns:
- All Potentials. Sometimes empty, never null.
-
destroyPotentials
public boolean destroyPotentials()Reclaims resources associated with all Potential objects associated with this script.- Returns:
- If all Potentials had resources reclaimed.
-
getPotentialsFromAssemblies
Returns a List of all Potential objects from the supplied MolecularAssembly array. Should be written to tolerate nulls, as many tests run help() and exit without instantiating their Potentials.- Parameters:
assemblies- An array of MolecularAssembly instances.- Returns:
- All Potentials. Sometimes empty, never null.
-
init
public boolean init()Initialize this Command based on the specified command line arguments.Execute the BaseScript init method, then load potential functions.
- Overrides:
initin classFFXCommand- Returns:
- boolean Returns true if the script should continue and false to exit.
-
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.
-
getActiveAssembly
If filenames is supplied, open the first entry and return the MolecularAssembly. Otherwise, the current activeAssembly is returned (which may be null).- Parameters:
filenames- Filenames 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.
-
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 variablebaseDirusing this filename if it's not set to a writeable directory.- Returns:
- Return the base directory as a String (including an appended
File.separator).
-
parseFilePath
Parse a filepath into directory, base name, and extension.- Parameters:
filepath- The filepath to parse.- Returns:
- A FilePathInfo object containing the directory, base name, and extension.
-
createOutputFile
Create an output File with a new extension based on the input filepath.- Parameters:
filepath- The input filepath.newExtension- The new extension for the output file.- Returns:
- A File object with the new extension.
-
saveByExtension
Save MolecularAssemblies to a file based on the supplied extension.- Parameters:
assemblies- The MolecularAssembly array to save.filename- The filename.extension- The extension to determine the file format.
-
saveByExtension
Save MolecularAssembly to a file based on the supplied extension.- Parameters:
molecularAssembly- The MolecularAssembly to save.filename- The filename.extension- The extension to determine the file format.
-
saveByOriginalExtension
Save MolecularAssemblies to file using the extension of an original filename.- Parameters:
assemblies- The MolecularAssembly array to save.filename- The original filename to extract the extension from.
-
saveByOriginalExtension
Save MolecularAssembly to a file using the extension of an original filename.- Parameters:
molecularAssembly- The MolecularAssembly array to save.filename- The original filename to extract the extension from.
-