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

public abstract class PotentialCommand extends FFXCommand
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

    • PotentialCommand

      public PotentialCommand()
      Default constructor.
    • PotentialCommand

      public PotentialCommand(FFXBinding binding)
      Create a Script using the supplied Binding.
      Parameters:
      binding - Binding with variables to use.
    • PotentialCommand

      public PotentialCommand(String[] args)
      Create a Script using the supplied command line arguments.
      Parameters:
      args - The command line arguments.
  • Method Details

    • 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 result).
      Parameters:
      molecularAssembly - The MolecularAssembly that should be active.
    • getPotentials

      public List<Potential> 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

      public List<Potential> getPotentialsFromAssemblies(MolecularAssembly[] assemblies)
      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:
      init in class FFXCommand
      Returns:
      boolean Returns true if the script should continue and false to exit.
    • 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.
    • getActiveAssembly

      public MolecularAssembly getActiveAssembly(@Nullable List<String> filenames)
      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

      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.
    • 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).
    • parseFilePath

      public FilePathInfo parseFilePath(String filepath)
      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

      public File createOutputFile(String filepath, String newExtension)
      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

      public void saveByExtension(MolecularAssembly[] assemblies, String filename, String extension)
      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

      public void saveByExtension(MolecularAssembly molecularAssembly, String filename, String extension)
      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

      public void saveByOriginalExtension(MolecularAssembly[] assemblies, String filename)
      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

      public void saveByOriginalExtension(MolecularAssembly molecularAssembly, String filename)
      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.