Class Base1PluginExecuter

All Implemented Interfaces:
InteractivePlugin, Plugin, SignalTarget

public class Base1PluginExecuter
extends AbstractAnalysisPlugin
implements InteractivePlugin, SignalTarget
This plug-in executes a plug-in from the Base1 system. It takes a base1 configuration file to create its configuration.
Johan Enell
Last modified
$Date: 2018-11-02 09:45:34 +0100 (fr, 02 nov 2018) $
  • Field Details

    • permissions

      private static final Set<Permissions> permissions
      The plug-in permissions.
    • dtdFile

      private static final URL dtdFile
    • fileParameter

      private static final PluginParameter<File> fileParameter
      Parameter definition that asks for the configuration file that should be imported.
    • execPathParameter

      private static PluginParameter<String> execPathParameter
      The path to where the plug-in executer can find the executables. In Base1 this was default to /usr/local/base/plugins.
    • serialFormatParameter

      private PluginParameter<Boolean> serialFormatParameter
      This parameter describes if the data should be exported in serial format or in matrix.
    • versionNumberParameter

      private PluginParameter<String> versionNumberParameter
      The version number of the plug-in.
    • execNameParameter

      private PluginParameter<String> execNameParameter
      The name of the executable.
    • geneAveragesParameter

      private PluginParameter<Boolean> geneAveragesParameter
      If the data should be exported averaged per gene.
    • minChannelsParameter

      private PluginParameter<Integer> minChannelsParameter
      The minimum number of channels.
    • maxChannelsParameter

      private PluginParameter<Integer> maxChannelsParameter
      The maximum number of channels, 0 means unlimited.
    • leaveStdinParameter

      private PluginParameter<Boolean> leaveStdinParameter
      If the plug-in should leave the stdin.txt after execution.
    • leaveStdoutParameter

      private PluginParameter<Boolean> leaveStdoutParameter
      If the plug-in should leave the stdout.txt after execution.
    • usedColumnsParameter

      private PluginParameter<String> usedColumnsParameter
      The reporter fields that should be exported as a tab separated string of column headers.
    • usedFieldsParameter

      private PluginParameter<String> usedFieldsParameter
      The spot fields that should be exported as a tab separated string of column headers.
    • jobParametersParameter

      private PluginParameter<String> jobParametersParameter
      This parameter describes the job parameters that the base1 plugin needs.
    • pluginDirectoryParameter

      private PluginParameter<String> pluginDirectoryParameter
      The directory where the plug-in will store it's output.

      private static final String COMMAND_MANUAL_CONFIG
      This command is used if the user decides to configure the plugin by hand.
      See Also:
      Constant Field Values
    • configureJob

      private RequestInformation configureJob
      Holds info about a job configuration request.
    • configurePlugin

      private RequestInformation configurePlugin
      Holds information about a plugin configuration request.
    • configureManual

      private RequestInformation configureManual
      Holds information about a manual plugin configuration request.
    • jobParameters

      private List<PluginParameter<?>> jobParameters
      This list holds the job parameters derived from the configuration file.
    • execDirectory

      private File execDirectory
      This is the directory where the plugin will generate its output.
    • signalHandler

      private ThreadSignalHandler signalHandler
  • Constructor Details

    • Base1PluginExecuter

      public Base1PluginExecuter()
  • Method Details

    • isInContext

      public String isInContext​(GuiContext context, Object item)
      Checks if the BioAssaySet has the number of channels specified by the configuration and that it has the extra values.
      Specified by:
      isInContext in interface InteractivePlugin
      isInContext in class AbstractAnalysisPlugin
      context - The context from where the plugin is invoked.
      item - The item that should be checked if it is in context.
      null if the item is in context, otherwise an error message.
      See Also:
      AbstractAnalysisPlugin.isInContext(net.sf.basedb.core.plugin.GuiContext, java.lang.Object)
    • getRequestInformation

      public RequestInformation getRequestInformation​(GuiContext context, String command) throws BaseException
      Description copied from interface: InteractivePlugin
      This method will return the RequestInformation for a given command, i.e. the list of parameters and some nice help text.
      Specified by:
      getRequestInformation in interface InteractivePlugin
      context - The current context of the client application, it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
      command - The command
      The RequestInformation for the command
      BaseException - if there is an error
    • configure

      public void configure​(GuiContext context, Request request, Response response)
      Description copied from interface: InteractivePlugin
      Configure the plugin. Hopefully the client is supplying values for the parameters specified by InteractivePlugin.getRequestInformation(GuiContext, String).
      Specified by:
      configure in interface InteractivePlugin
      context - The current context of the client application, it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
      request - Request object with the command and parameters
      response - Response object in for the plugin to response through
    • copy

      private void copy​(File f, File d) throws IOException
      Copies the content from a File to a directory on the file system.
      f - The file to be copied.
      d - The directory where the file will be written.
      IOException - If there is any error with target.
    • deleteDir

      private boolean deleteDir​(File dir)
      Deletes all files and sub directories under dir.
      true if all deletions were successful
    • getPermissions

      public Collection<Permissions> getPermissions()
      Description copied from class: AbstractPlugin
      Return null, which gives the plugin the same permissions as the logged in user.
      Specified by:
      getPermissions in interface Plugin
      getPermissions in class AbstractPlugin
      A collection of permissions or null to not use permissions
    • supportsConfigurations

      public boolean supportsConfigurations()
      Description copied from class: AbstractPlugin
      Returns TRUE, since that is how the plugins used to work before this method was introduced.
      Specified by:
      supportsConfigurations in interface Plugin
      supportsConfigurations in class AbstractPlugin
      TRUE or FALSE
    • requiresConfiguration

      public boolean requiresConfiguration()
      Description copied from class: AbstractPlugin
      Returns FALSE, since that is how the plugins used to work before this method was introduced.
      Specified by:
      requiresConfiguration in interface Plugin
      requiresConfiguration in class AbstractPlugin
      TRUE or FALSE
    • run

      public void run​(Request request, Response response, ProgressReporter progress)
      Description copied from interface: Plugin
      Run the plugin. If a progress reporter object is passed it is recommended that the plugin makes use of it.
      Specified by:
      run in interface Plugin
      request - Request object with the command and parameters
      response - Response object in for the plugin to response through
      progress - A ProgressReporter where the plugin can report its progess, can be null
    • getSignalHandler

      public SignalHandler getSignalHandler()
      Description copied from interface: SignalTarget
      Get the signal handler that is handling signals on behalf of this object. Multiple invokations of this method may receive the same or different objects. Null may be returned if, for some reason, the current object instance doesn't want to receive signals. Returning null is the same as not implementing this interface.
      Specified by:
      getSignalHandler in interface SignalTarget
      A SignalHandler object, or null if the current instance doesn't support signals
    • exportData

      private File exportData​(DbControl dc, Directory workingDirectory, ProgressReporter progress)
      Export the bioassay set to a file called 'stdin.txt' in the plugin directory.
      dc - DbControl used to access the database
      workingDirectory - Where in base' file system the exported BASEFile should be stored.
      The file where the data is exported to.
    • getAnnotationTypes

      private List<AnnotationType> getAnnotationTypes()
      Get the experimental factors connected to a experiment.
      A list of AnnotationType:s
    • getParametersFromBaseFile

      private Map<String,​String> getParametersFromBaseFile​(File f) throws IOException
      Get the data from the configuration file.
      f - The file.
      A map of name->value pairs.
      IOException - If there i any problem reading from file.
    • getJobParameterObjectsFromXML

      private Map<String,​Base1PluginExecuter.JobParameter> getJobParameterObjectsFromXML​(String xml, boolean hideRemoved)
    • getJobParametersFromXML

      private List<PluginParameter<?>> getJobParametersFromXML​(String xml, boolean hideRemoved)
    • getBoolean

      private Boolean getBoolean​(String s)
      Creates a boolean from a string.
      s - The string.
      false if s.equals("0") else true.
    • getManualConfigureParameters

      private RequestInformation getManualConfigureParameters()
      Creates the information needed for manual configuration and initiates the parameters. The parameters added are: versionNumber, usedColumns, usedFields, execName, geneAverages, SerialFormat, leaveStdin, leaveStdout, minChannel and maxCannel.
      The RequestInformation.
    • getConfigureJobParameters

      private RequestInformation getConfigureJobParameters()
      Creates the information needed for job configuration and initiates the parameters. The parameters added are: bioAssaySet and the parameters found in the configuration file.
      The RequestInformation
    • getConfigurePluginParameters

      private RequestInformation getConfigurePluginParameters()
      Creates the information needed for plugin configuration and initiates the parameters. The parameters added are: file and execPath.
      The RequestInformation.
    • getExecDirectory

      private File getExecDirectory() throws IOException
      Get the exec directory as a The exec directory is a sub directory in "".
      the directory.
    • getExecLine

      private String getExecLine()
    • getInitializedFlatFileParser

      private FlatFileParser getInitializedFlatFileParser​(InputStream stream, String charset)
      Creates a FlatFileParser for a plugin configuration file.
      stream - The stream that the parser should read from.
      The initialised parser
    • getJobParameters

      private List<PluginParameter<?>> getJobParameters() throws BaseException
      Reads the configuration file an creates the parameters found there.
      A list of PluginParameter:s
    • getPluginDirectory

      private Directory getPluginDirectory​(DbControl dc, String pathName)
      Get a directory
    • importData

      private BioAssaySet importData​(DbControl dc, File stdout, Transformation t, IntensityTransform resultTransform, ProgressReporter progress) throws SQLException, IOException
      Imports the data from the file stdout.txt in the execution directory.
      IOException - if there is any error reading from stdout.txt
    • associateFiles

      private void associateFiles​(DbControl dc, Transformation trans, Directory homeDirectory)
    • importTempFiles

      private void importTempFiles​(DbControl dc, File[] files, Directory d)