2.17.2: 2011-06-17

net.sf.basedb.plugins
Class Base1PluginExecuter

java.lang.Object
  extended by net.sf.basedb.core.plugin.AbstractPlugin
      extended by net.sf.basedb.core.plugin.AbstractAnalysisPlugin
          extended by net.sf.basedb.plugins.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.

Version:
2.2
Author:
Johan Enell
Last modified
$Date: 2011-03-15 14:19:25 +0100 (Tue, 15 Mar 2011) $

Nested Class Summary
private static class Base1PluginExecuter.Base1JobParameterType
           
private  class Base1PluginExecuter.JobParameter
           
 
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin
Plugin.MainType
 
Field Summary
private static About about
          Plugin description
private static String COMMAND_MANUAL_CONFIG
          This command is used if the user decides to configure the plugin by hand.
private  RequestInformation configureJob
          Holds info about a job configuration request.
private  RequestInformation configureManual
          Holds information about a manual plugin configuration request.
private  RequestInformation configurePlugin
          Holds information about a plugin configuration request.
private static URL dtdFile
           
private  File execDirectory
          This is the directory where the plugin will generate its output.
private  PluginParameter<String> execNameParameter
          The name of the executable.
private static PluginParameter<String> execPathParameter
          The path to where the plug-in executer can find the executables.
private static PluginParameter<File> fileParameter
          Parameter definition that asks for the configuration file that should be imported.
private  PluginParameter<Boolean> geneAveragesParameter
          If the data should be exported averaged per gene.
private  List<PluginParameter<?>> jobParameters
          This list holds the job parameters derived from the configuration file.
private  PluginParameter<String> jobParametersParameter
          This parameter describes the job parameters that the base1 plugin needs.
private  PluginParameter<Boolean> leaveStdinParameter
          If the plug-in should leave the stdin.txt after execution.
private  PluginParameter<Boolean> leaveStdoutParameter
          If the plug-in should leave the stdout.txt after execution.
private  PluginParameter<Integer> maxChannelsParameter
          The maximum number of channels, 0 means unlimited.
private  PluginParameter<Integer> minChannelsParameter
          The minimum number of channels.
private static Set<Permissions> permissions
          The plug-in permissions.
private  PluginParameter<String> pluginDirectoryParameter
          The directory where the plug-in will store it's output.
private  PluginParameter<Boolean> serialFormatParameter
          This parameter describes if the data should be exported in serial format or in matrix.
private  ThreadSignalHandler signalHandler
           
private  PluginParameter<String> usedColumnsParameter
          The reporter fields that should be exported as a tab separated string of column headers.
private  PluginParameter<String> usedFieldsParameter
          The spot fields that should be exported as a tab separated string of column headers.
private  PluginParameter<String> versionNumberParameter
          The version number of the plug-in.
 
Fields inherited from class net.sf.basedb.core.plugin.AbstractAnalysisPlugin
CHILD_DESCRIPTION, CHILD_NAME, CONTEXT_BIOASSAYS, CONTEXT_BIOASSAYSET, defaultGuiContexts, nameType, optionalNameType, SOURCE_BIOASSAYS, SOURCE_BIOASSAYSET, TRANSFORMATION_NAME
 
Fields inherited from class net.sf.basedb.core.plugin.AbstractPlugin
annotationSection, configuration, COPY_ANNOTATIONS, job, OVERWRITE_ANNOTATIONS, sc
 
Constructor Summary
Base1PluginExecuter()
           
 
Method Summary
private  void associateFiles(DbControl dc, Transformation trans, Directory homeDirectory)
           
 void configure(GuiContext context, Request request, Response response)
          Configure the plugin.
private  void copy(File f, File d)
          Copies the content from a File to a directory on the file system.
private  boolean deleteDir(File dir)
          Deletes all files and sub directories under dir.
private  File exportData(DbControl dc, Directory workingDirectory, ProgressReporter progress)
          Export the bioassay set to a file called 'stdin.txt' in the plugin directory.
 About getAbout()
          Get information about the plugin, such as name, version, authors, etc.
private  List<AnnotationType> getAnnotationTypes()
          Get the experimental factors connected to a experiment.
private  Boolean getBoolean(String s)
          Creates a boolean from a string.
private  RequestInformation getConfigureJobParameters()
          Creates the information needed for job configuration and initiates the parameters.
private  RequestInformation getConfigurePluginParameters()
          Creates the information needed for plugin configuration and initiates the parameters.
private  File getExecDirectory()
          Get the exec directory as a java.io.File.
private  String getExecLine()
           
private  FlatFileParser getInitializedFlatFileParser(InputStream stream, String charset)
          Creates a FlatFileParser for a plugin configuration file.
private  Map<String,Base1PluginExecuter.JobParameter> getJobParameterObjectsFromXML(String xml, boolean hideRemoved)
           
private  List<PluginParameter<?>> getJobParameters()
          Reads the configuration file an creates the parameters found there.
private  List<PluginParameter<?>> getJobParametersFromXML(String xml, boolean hideRemoved)
           
private  RequestInformation getManualConfigureParameters()
          Creates the information needed for manual configuration and initiates the parameters.
private  Map<String,String> getParametersFromBaseFile(File f)
          Get the data from the configuration file.
 Collection<Permissions> getPermissions()
          Return null, which gives the plugin the same permissions as the logged in user.
private  Directory getPluginDirectory(DbControl dc, String pathName)
          Get a directory
 RequestInformation getRequestInformation(GuiContext context, String command)
          This method will return the RequestInformation for a given command, i.e.
 SignalHandler getSignalHandler()
          Get the signal handler that is handling signals on behalf of this object.
private  BioAssaySet importData(DbControl dc, File stdout, Transformation t, IntensityTransform resultTransform, ProgressReporter progress)
          Imports the data from the file stdout.txt in the execution directory.
private  void importTempFiles(DbControl dc, File[] files, Directory d)
           
 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.
 boolean requiresConfiguration()
          Returns FALSE, since that is how the plugins used to work before this method was introduced.
 void run(Request request, Response response, ProgressReporter progress)
          Run the plugin.
 boolean supportsConfigurations()
          Returns TRUE, since that is how the plugins used to work before this method was introduced.
 
Methods inherited from class net.sf.basedb.core.plugin.AbstractAnalysisPlugin
getChildDescriptionParameter, getChildNameParameter, getCurrentBioAssaySet, getCurrentExperiment, getGuiContexts, getMainType, getSourceBioAssays, getSourceBioAssaySet, getSourceBioAssaySetParameter, getSourceBioAssaysParameter, getTransformationName, getTransformationNameParameter, restrictSource
 
Methods inherited from class net.sf.basedb.core.plugin.AbstractPlugin
checkInterrupted, cloneParameterWithDefaultValue, closeLogFile, createLogFile, done, getCopyAnnotationsParmeter, getCurrentConfiguration, getCurrentJob, getJobOrConfigurationValue, getOverwriteAnnotationsParameters, init, log, log, storeValue, storeValue, storeValues, validateRequestParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.plugin.InteractivePlugin
getGuiContexts
 
Methods inherited from interface net.sf.basedb.core.plugin.Plugin
done, getMainType, init
 

Field Detail

about

private static final About about
Plugin description


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.


COMMAND_MANUAL_CONFIG

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 Detail

Base1PluginExecuter

public Base1PluginExecuter()
Method Detail

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
Overrides:
isInContext in class AbstractAnalysisPlugin
Parameters:
context - The context from where the plugin is invoked.
item - The item that should be checked if it is in context.
Returns:
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
Parameters:
context - The current context of the client application, it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
command - The command
Returns:
The RequestInformation for the command
Throws:
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
Parameters:
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.

Parameters:
f - The file to be copied.
d - The directory where the file will be written.
Throws:
IOException - If there is any error with target.

deleteDir

private boolean deleteDir(File dir)
Deletes all files and sub directories under dir.

Parameters:
dir -
Returns:
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
Overrides:
getPermissions in class AbstractPlugin
Returns:
A collection of permissions or null to not use permissions

getAbout

public About getAbout()
Description copied from interface: Plugin
Get information about the plugin, such as name, version, authors, etc.

Specified by:
getAbout in interface Plugin
Returns:
An About object

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
Overrides:
supportsConfigurations in class AbstractPlugin
Returns:
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
Overrides:
requiresConfiguration in class AbstractPlugin
Returns:
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
Parameters:
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
Returns:
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.

Parameters:
dc - DbControl used to access the database
workingDirectory - Where in base' file system the exported BASEFile should be stored.
Returns:
The file where the data is exported to.

getAnnotationTypes

private List<AnnotationType> getAnnotationTypes()
Get the experimental factors connected to a experiment.

Returns:
A list of AnnotationType:s

getParametersFromBaseFile

private Map<String,String> getParametersFromBaseFile(File f)
                                              throws IOException
Get the data from the configuration file.

Parameters:
f - The file.
Returns:
A map of name->value pairs.
Throws:
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.

Parameters:
s - The string.
Returns:
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.

Returns:
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.

Returns:
The RequestInformation

getConfigurePluginParameters

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

Returns:
The RequestInformation.

getExecDirectory

private File getExecDirectory()
                       throws IOException
Get the exec directory as a java.io.File. The exec directory is a sub directory in "java.io.tmpdir".

Returns:
the directory.
Throws:
IOException

getExecLine

private String getExecLine()

getInitializedFlatFileParser

private FlatFileParser getInitializedFlatFileParser(InputStream stream,
                                                    String charset)
Creates a FlatFileParser for a plugin configuration file.

Parameters:
stream - The stream that the parser should read from.
Returns:
The initialised parser

getJobParameters

private List<PluginParameter<?>> getJobParameters()
                                           throws BaseException
Reads the configuration file an creates the parameters found there.

Returns:
A list of PluginParameter:s
Throws:
BaseException

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.

Throws:
IOException - if there is any error reading from stdout.txt
SQLException

associateFiles

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

importTempFiles

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

2.17.2: 2011-06-17