Class RevalBase

java.lang.Object
  |
  +--RevalBase
Direct Known Subclasses:
Reval

public abstract class RevalBase
extends java.lang.Object

Class RevalBase is an abstract base class used to define the base infrastructure for evaluating R scripts (using the R program) using data supplied from a client program. It was developed with the MAExplorer client program. We will refer to the "client" or client program throughout this file. We may refer to the client {installation directory} and to the client {project diretory} where data files are found and generated. Note that one must always extend this base class using an instance of Reval.java edited for the particular client program. Data will be defined there that is used in this base class.

Class Reval extends RevalBase and is used to evaluate R scripts with data supplied from the client program via the MJA API. Each R analysis is defined by a R LayOut (RLO). Each RLO is saved in an internal RLO database managed by the Reval MJA class (see addRLO() method for details on the RLO).

R is an extensible language and envirnment for statistical computing and graphics. R is Open Source (GNU public license) and is available for download at www.r-project.org.

This class's methods contain a command interpreter, and support methods and data structures to enable you to execute R program .R scripts using client data.

It is intended to be used when writing MAEPlugins that need to access the R program to execute .R scripts with client data. This may generate reports and plots (PDF, JPG, PNG, Postscript, SVG). Some of these reports may be used to pass the R results back into the client state.

This class evaluates R scripts with data supplied from the client via the MJAReval API. Each R analysis is defined by a R LayOut (RLO). Each RLO is saved in an internal RLO database managed by the mjaReval MJAReval class. (See class variable definitions and addRLO() method for details on the RLO). The RLOs specify the evaluation environment for the .R script when evaluated by R. The R program is then run as a separate process using a System.exec()

The clientProgram-R interface library RLORlibr is kept in the client program {installation directory}/lib/{RLORlibr}/ and contains the standard R library format subdirectories including R/ (separate files) and R-ex/ (single file).

When an RLO script is evaluated, we copy the .R script with a "tmp-" prefix to the project Temp/ and prepend the following 2 lines:

   setwd("...Temp/")
   library({RLOR}libr,lib.loc="{installation directory}/lib")
which are required for the .R script to access the data generated by the client program and to access the library.

When executed, an R script is allowed to generate multiple output files that may include the following formats: text, tab-delimited text, PDF, JPG, etc. There may be also multiple data input files requested by the R script. These are generated by mjaReval class methods as specified by the RLO database entry. Note: during R execution, all files are read and written from the {project}/Temp directory, the R current working directory. They may be copied to or from this directory from or to other directories as required.

 1. data is exported from the client program to tab-delimited data input
    files {Project}/Temp/. These will then be read by R when your script
    is evaluated.
 2. The output of R is saved to any number of files into the 
    {project directory}/Temp/ and then moved to the
    {Project directory}/Report/ where they may then be displayed or 
    read by the client program if required.
 3. The .R scripts are shared with all instances of the client program
    and are kept in {installation directory}/R/
 4. The .rlo files are shared by all instances of the client program and
    are kept in {installation directory}/RLO/ directory.
 5. The startup script is generated by an mjaReval method and placed in
    the {project directory}/Temp directory where it will be used by a 
    System.exec() call.
This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.

Version:
$Date: 2003/07/07 21:40:40 $ $Revision: 1.66 $
Author:
P. Lemkin (NCI), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home, Reval, RLO

Field Summary
(package private) static RLO[] analyses
          List [0:nAnalyses-1] of R analysis procedures descriptions
(package private)  java.lang.String clientName
          Name of the client program
(package private) static java.lang.String clientRlibrBasePath
          base path of where {client installation} R project RLORlibr/ directory lives
(package private) static int curAnalysis
          Current analysis procedure being used from the analyses[] list
(package private)  boolean dbugFlag
          Flag set debugging - toggled by dbugCheckbox if DBUG_FLAG is set
private static java.lang.String DEFAULT_R_OUTPUT_FILE
          default output file for R to save any output if we do not specify an output file for the current analysis.
(package private) static java.lang.String fileSeparator
           
(package private)  java.lang.String fullRoutputFilePath
          full path of R output file
(package private) static java.lang.String fullRscriptInputPath
          full path of .R input script file
(package private) static java.lang.String fullRunRfilePath
          full path of batch R startup script file
(package private) static java.lang.String inputRscriptFileName
           
(package private) static boolean isWindowsFlag
          Flag set if running on a Windows computer
(package private) static java.lang.String javaHome
           
(package private) static int MAX_ANALYSES
          default # of analyses allowed
(package private) static int maxRLO
          max # of Rscript analysis procedures
(package private) static int nAnalyses
          # of Rscript analysis procedures
private static java.lang.String NO_R_INSTALLED
          This is the name of the path for the saved R base path in the Temp/.RbasePath file it it ever tried to prompt for the R base path and there was no response to the\ prompt.
(package private) static int nOfileTypes
          Number of R output file types
(package private) static int nProcessBits
          Number of R2Client actions
(package private) static int nR2ClientActions
          Number of R2Client actions
(package private) static int nRdataTypes
          Number of client export data file types for import to R
(package private) static java.lang.String osName
           
private  int parseDelimChar
          current delim of "name(delim)value" pair for StringTokenizer
private  java.lang.String parseName
          current name of "name=value" pair for StringTokenizer
private  java.lang.String parseValue
          current value of "name=value" pair for StringTokenizer
(package private)  java.lang.String promptDir
          directory used with popup file browser
(package private)  java.lang.String promptExt
          file extension used with popup file browser
(package private)  java.lang.String promptFile
          file name used with popup file browser
(package private) static boolean quoteRunPathFlag
          If the flag is set then add "\ ...\" around exec program "\"" + RbinBasePath + ("Rterm" or "splus") + "\"" BEFORE exec
(package private) static java.lang.String[] r2ClientActionMenu
          R2Client actions menu entries
(package private) static java.lang.String[] r2ClientActionName
          R2Client actions names
(package private) static int[] r2ClientActionVal
           
(package private)  java.lang.String r2ClientPrefix
          Name of the R2Client prefix
(package private) static java.lang.String RbasePath
          base Path to R executable e.g.
(package private) static java.lang.String RbinBasePath
          base bin Path to R executable if it exists.
(package private) static java.lang.String[] rDataTypeMenu
          client export data file types menu entries for import to R
(package private) static java.lang.String[] rDataTypeName
          client export data file types names for import to R
(package private) static int[] rDataTypeVal
          client export data file types values for import to R
(package private) static boolean REB_DBUG
          DEBUG flag for RevalBase
(package private) static java.lang.String reportBasePath
          path of {client project} Report/ directory
(package private) static java.lang.String reportFileName
          path of Text report file in Report/ if doing a "SaveAs" of TextArea
(package private)  RLO rlo
          instance of the RLO database.
(package private) static java.lang.String RLO_VERSION
          current RLO version number for I/O
(package private) static java.lang.String RLObasePath
          path of {client installation} RLO/ directory
(package private)  java.lang.String rloReportLoggingFile
          Name of RLO Report logging by creating subdirectory {project}/Report/{RLOname}-yymmdd.hhmmss/ to store the RLO output files copied to Report/
(package private) static java.lang.String RLORlibr
          Clients R project RLORlibr/ directory lives.
(package private) static java.lang.String[] rOfileTypeMenu
          R output file types menu entries
(package private) static java.lang.String[] rOfileTypeName
          R output file types names
(package private) static int rOfileTypeStdOut
          Special StdOut Output File type needed for RevalBase class
(package private) static int[] rOfileTypeVal
          R output file types values
(package private) static int rPB_useVanillaBit
          Special process bit needed for RevalBase class
(package private) static java.lang.String[] rProcessBitMenu
          Process Bits to use Menu entries
(package private) static java.lang.String[] rProcessBitName
          R2Client actions names
(package private) static int[] rProcessBitVal
          Process Bits to use values
(package private)  java.lang.String rReport
          Report text that results from running an R script.
(package private) static java.lang.String RscriptBasePath
          path of {client installation} R/ directory
(package private)  java.lang.String rStdout
          Stdout (and stderr) text that results from running an R script.
(package private) static java.lang.String RuserBasePath
          user's home directory for e.g.env "R_USER" or "HOME" or "C:/R/", etc.
(package private)  java.lang.String specificCreateInputFileProblem
          If createInputDataFiles() failed, this is a suggestion on how to fix the problem.
(package private) static java.lang.String SPlusBasePath
          base path to S-Plus executable e.g.
(package private) static java.lang.String SPlusBinBasePath
          base bin Path to S-Plus executable if it exists.
(package private) static java.lang.String startupRscriptFileName
          name of current batch R startup script file to exec() by the OS
(package private) static java.lang.String tempBasePath
          path of {client project} Temp/ directory
(package private)  java.lang.String timeStampReportDir
          time stamp dir for reports
(package private) static java.lang.String userDir
           
(package private)  boolean useRLOloggingFlag
          Flag for RLO Report logging by creating subdirectory in {project}/Report/{RLOname}-yymmdd.hhmmss/ to store the RLO output files copied to Report/
(package private)  boolean useSPlusFlag
          Flag to use S-Plus, else use R.
 
Constructor Summary
(package private) RevalBase(java.lang.String clientName, java.lang.String r2ClientPrefix, java.lang.String RLORlibr, int maxAnalyses)
          RevalBase() - constructor for initial database allocation
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          accept() - file browser filter used to test if file should be in directory list.
(package private)  int addRLO(java.lang.String menuName, java.lang.String menuStubName, java.lang.String RscriptName, java.lang.String[] inputDataFileNames, int[] inputDataTypes, int processBits, int genRbits, java.lang.String[] outputDataFileNames, int[] outputDataTypes, java.lang.String[] setR2ClientFileNames, java.lang.String[] setR2ClientObjNames, int[] setR2ClientObjTypes, java.lang.String scriptSpecificRoptions)
          addRLO() - add new R LayOut (RLO) instance to the RLO database.
 void clearRLOdb()
          clearRLOdb() - clear list of R LayOuts analyses in the database
(package private) abstract  boolean copyFile(java.lang.String srcName, java.lang.String dstName, java.lang.String optUpdateMsg, int optEstInputFileLth)
          copyFile() - binary copy of one file or URL toa local file
private  void copyTempOutputFilesToReportDir()
          copyTempOutputFilesToReportDir() - show plots generated if any with the last R eval.
(package private) abstract  boolean createInputDataFiles(java.lang.String inputFilesBasePath)
          createInputDataFiles() - create any input data files required for current analysis.
private  java.lang.String createRunRscript()
          createRunRscript() - create startup script to run R that is OS specific
private  java.lang.String createTempRscript(java.lang.String RscriptName)
          createTempRscript() - create a copy of the .R script in /Temp/ for the current RLO database analysis currently selected.
(package private)  java.lang.String cvRLO2string(int rloID, java.lang.String optProcessBitsStr, java.lang.String optGenRbitsStr)
          cvRLO2string() - create string representing the R LayOut (RLO) of the instance
private static int cvs2i(java.lang.String str, int defaultValue)
          cvs2i() - convert String to int with default value
private static java.lang.String cvtBackslash2Fwdslash(java.lang.String sInput)
          cvtBackslash2Fwdslash() - convert '\\' to '/' in the string
private static boolean cvtEnvPaths2Properties()
          cvtEnvPaths2Properties() - get all system ENV variables and set them as separate Java properties so we can get them individually from System.getProperty(var) calls.
(package private)  java.lang.String cvtInputType2Str(int val)
          cvtInputType2Str() - convertinput file type R_FILE_TYPE_xxxx to string
(package private)  java.lang.String cvtOutType2Str(int val)
          cvtOutType2Str() - convert output file type to string
(package private)  java.lang.String cvtR2ClientType2Str(int val)
          cvtR2ClientType2Str() - convert R2Client file type R to string
(package private) abstract  boolean deleteLocalFile(java.lang.String fileName)
          deleteLocalFile() - delete local file.
private  java.lang.String execRscript()
          execRscript() - exec R with cmd to process the .R script.
 int getAllProcessBits()
           
private static java.lang.String getCurDateStr()
          getCurDateStr() - return date string in the format of YYMMDDHHMMSS.
(package private)  RLO getCurrentRLO()
          getCurrentRLO() - get the current RLO analysis method object
(package private)  java.lang.String[] getInputDataFileNames()
          getInputDataFileNames() - get current RLO list of input data file names
(package private)  int[] getInputDataTypes()
          getInputDataTypes() - get current RLO list of input data file types
(package private)  java.lang.String[] getListofRLOmenuNames()
          getListofRLOmenuNames() - get list of all menuNames
(package private)  java.lang.String[] getListofRLOscriptNames()
          getListofRLOscriptNames() - get list of all R script names
(package private)  int getNbrAnalyses()
          getNbrAnalyses() - get the number of analyses in the RLO DB
private  boolean getNextStrNameValFromLine(java.util.StringTokenizer parser)
          getNextStrNameValFromLine() - get next line and parse 'name=value\n'.
(package private)  java.lang.String[] getOfileTypeDBmenus()
          getOfileTypeDBmenus() - get the R output file type menu
(package private)  java.lang.String[] getOfileTypeDBnames()
          getOfileTypeDBnames() - get the R output file type names
(package private)  int[] getOfileTypeDBtypes()
          getOfileTypeDBtypes() - get the R output file names type values
(package private)  java.lang.String[] getOutputDataFileNames()
          getOutputDataFileNames() - get current RLO list of output data file names.
(package private)  int[] getOutputDataTypes()
          getOutputDataTypes() - get current RLO list of output data file types
(package private)  java.lang.String[] getProcessBitsDBmenus()
          getProcessBitsDBmenus() - get Export/Import ProcessBits DB menus entries
(package private)  java.lang.String[] getProcessBitsDBnames()
          getProcessBitsDBnames() - get Export/Import ProcessBits DB names
(package private)  int[] getProcessBitsDBvalues()
          getProcessBitsDBvalues() - get Export/Import ProcessBits DB values
(package private)  java.lang.String[] getR2ClientActionDBmenus()
          getR2ClientActionDBmenus() - get R to client Actions DB menus
(package private)  java.lang.String[] getR2ClientActionDBnames()
          getR2ClientActionDBnames() - get R to client Actions DB names
(package private)  int[] getR2ClientActionDBtypes()
          getR2ClientActionDBtypes() - get R to client Actions DB type values
(package private)  java.lang.String[] getRdataTypeDBmenus()
          getRdataTypeDBmenus() - get the R input file type menus
(package private)  java.lang.String[] getRdataTypeDBnames()
          getRdataTypeDBnames() - get the R input file type names
(package private)  int[] getRdataTypeDBtypes()
          getRdataTypeDBtypes() - get the R input file type values
 int getRLOidByRscriptName(java.lang.String RscriptName)
          getRLOidByRscriptName() - get the current RLO analysis method id by RscriptName
(package private)  java.lang.String[] getSetR2ClientFileNames()
          getSetR2ClientFileNames() - get current RLO list of R2Client data file names.
(package private)  java.lang.String[] getSetR2ClientObjNames()
          getSetR2ClientObjNames() - get current RLO list of R2Client object names
(package private)  int[] getSetR2ClientObjTypes()
          getSetR2ClientObjTypes() - get current RLO list of R2Client object types
private  java.lang.String getStrValFromLine(java.lang.String key, java.util.StringTokenizer parser)
          getStrValFromLine() - get line and parse value for key 'name=value\n'.
(package private)  java.lang.String lookupOfileTypeDBmenu(int val)
          lookupOfileTypeDBmenu() - lookup R output file type menu entry by value.
(package private)  java.lang.String lookupOfileTypeDBmenu(java.lang.String name)
          lookupOfileTypeDBmenu() - lookup R output file type menu entry by name.
(package private)  int lookupOfileTypeDBvalue(java.lang.String name)
          lookupOfileTypeDBvalue() - lookup R output file type value by name.
(package private)  java.lang.String lookupProcessBitsDBmenu(int i, int val)
          lookupProcessBitsDBmenu() - lookup Export/Import ProcessBits menu by value
(package private)  int lookupProcessBitsDBvalue(java.lang.String name)
          lookupProcessBitsDBvalue() - lookup the Export/Import ProcessBits value by name
(package private)  java.lang.String lookupR2ClientActionDBMenu(int val)
          lookupR2ClientActionDBMenu() - lookup R to client Action menu by value
(package private)  java.lang.String lookupR2ClientActionDBMenu(java.lang.String name)
          lookupR2ClientActionDBMenu() - lookup R to client Action menu by name
(package private)  int lookupR2ClientActionDBtype(java.lang.String name)
          lookupR2ClientActionDBtype() - lookup R to client Action type value by name
(package private)  int lookupR2ClientActionDBvalue(java.lang.String name)
          lookupR2ClientActionDBvalue() - lookup R to client Action value by name
(package private)  java.lang.String lookupRdataTypeDBmenu(int val)
          lookupRdataTypeDBmenu() - lookup the export-types menu entry by value.
(package private)  java.lang.String lookupRdataTypeDBmenu(java.lang.String name)
          lookupRdataTypeDBmenu() - lookup the export-types menu entry by name.
(package private)  int lookupRdataTypeDBvalue(java.lang.String name)
          lookupRdataTypeDBvalue() - lookup the export-types value by name.
(package private)  int newRLO()
          newRLO() - create new empty R LayOut (RLO) instance to the RLO database.
(package private) abstract  java.lang.String popupDialog(java.lang.String promptMsg, java.lang.String defaultAnswer)
          popupDialog() prompt with message and return response.
 java.lang.String promptFileName(java.lang.String msg, java.lang.String useDir, java.lang.String initialFile, java.lang.String subDir, java.lang.String fileExt, boolean saveMode, boolean useFileDialog)
          promptFileName() - dialog prompt for file name.
(package private)  boolean readPermanentRLOdatabase(boolean loadDemoRLOsFlag)
          readPermanentRLOdatabase() - read RLO entries from the permanent /RLO/*.rlo file database.
(package private)  int readRLOfile(java.lang.String rloFileName, boolean allowDemoLoadFlag)
          readRLOfile() - read RLO by .rlo file name into a new RLO (rloID).
(package private) abstract  java.lang.String readTextFromFile(java.lang.String fileName, java.lang.String loadingMsg)
          readTextFromFile() - read text from text file.
 boolean rmvRLO(int rloIdToRemove)
          rmvRLO() - remove the RLO from the analyses database
private static java.lang.String rmvRtnChars(java.lang.String str)
          rmvRtnChars() - remove return chars.
(package private)  java.lang.String runRscriptWithR()
          runRscriptWithR() - compute report string by running R script through R.
 void setAllProcessBits(int bits)
          setAllProcessBits() - set Process Bits using R_PB_xxxx bits for current RLO.
(package private)  void setCurrentRLO(int analysisNbr)
          setCurrentRLO() - set the current RLO analysis method by id
(package private)  void setDbugFlag(boolean flag)
          setDbugFlag() - set debugging flag to print to stdout if required
 boolean setInputFilesData(java.lang.String[] fileNames, int[] dataTypes)
          setInputFilesData() - set current RLO list of input data (fileName,dataType)
(package private)  boolean setOfileTypeDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
          setOfileTypeDB() - set the R output file-types (name,menu,type) database.
 boolean setOutputFilesData(java.lang.String[] fileNames, int[] dataTypes)
          setOutputFilesData() - set current RLO list of output data (fileName,dataType)
(package private)  boolean setProcessBitsDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
          setProcessBitsDB() - set the Export/Import ProcessBits (name,menuOn,menuOFF,type) database.
(package private)  boolean setR2ClientActionDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
          setR2ClientActionDB() - set the R to client Actions (name,menu,type) database.
 boolean setR2ClientFilesData(java.lang.String[] fileNames, java.lang.String[] objNames, int[] objTypes)
          setR2ClientFilesData() - set cur.
(package private)  boolean setRdataTypeDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
          setRdataTypeDB() - set the export-types (name,menu,type) database.
(package private)  boolean setRLO(int rloID, java.lang.String menuName, java.lang.String menuStubName, java.lang.String RscriptName, java.lang.String[] inputDataFileNames, int[] inputDataTypes, int processBits, int genRbits, java.lang.String[] outputDataFileNames, int[] outputDataTypes, java.lang.String[] setR2ClientFileNames, java.lang.String[] setR2ClientObjNames, int[] setR2ClientObjTypes, java.lang.String scriptSpecificRoptions)
          setRLO() - set R LayOut (RLO) instance to the RLO database.
(package private)  void setRLOreportLoggingFlag(boolean flag)
          setRLOreportLoggingFlag() - set RLO Report logging flag for creating subdirectory in {project}/Report/{RLOname}-yymmdd.hhmmss/ to store the RLO output files copied to Report/
(package private) abstract  boolean setRoutput2ClientObjects()
          setRoutput2ClientObjects() - copy data for any entries in the RLO.
(package private)  boolean setupAllBasePaths(java.lang.String clientPrjPath)
          setupAllBasePaths() - generate all base paths of directories
(package private)  java.lang.String setupRbinPath(boolean promptIfNotFoundFlag)
          setupRbinPath() - setup RbinBasePath by analyzing OS env vars and OS name.
(package private) abstract  void setWaitCursor(boolean flag)
          setWaitCursor() - turn wait cursor on and off
(package private) abstract  void showMsg(java.lang.String msg)
          showMsg() - display message in client GUI
(package private) static java.lang.String simpleLookupRprogramPath()
          simpleLookupRprogramPath() - lookup RbinBasePath by analyzing OS env vars and OS name.
(package private) static java.lang.String simpleLookupSPLUSprogramPath()
          simpleLookupSPLUSprogramPath() - lookup SPlusBinBasePath by analyzing OS env vars and OS name.
private static java.lang.String[] sortArray(java.lang.String[] data, boolean sortAscending)
          sortArray() - bubble sort string array either ASCENDING or DESCENDING.
(package private)  java.lang.String toString(int rloID, java.lang.String optProcessBitsStr, java.lang.String optGenRbitsStr)
          toString() - create string representing the R LayOut (RLO) of the RLO instance
(package private)  boolean writePermanentRLOdatabase()
          writePermanentRLOdatabase() - write RLO entries to the permanent /RLO/ database.
(package private)  boolean writeRLOfile(java.lang.String rloBasePath, int rloID)
          writeRLOfile() - write RLO by .rlo file name for specified RLO (rloID).
(package private) abstract  boolean writeTextToFile(java.lang.String textFileName, java.lang.String textReport)
          writeTextToFile() - save text string as text file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

REB_DBUG

static final boolean REB_DBUG
DEBUG flag for RevalBase

clientName

java.lang.String clientName
Name of the client program

r2ClientPrefix

java.lang.String r2ClientPrefix
Name of the R2Client prefix

promptFile

java.lang.String promptFile
file name used with popup file browser

promptDir

java.lang.String promptDir
directory used with popup file browser

promptExt

java.lang.String promptExt
file extension used with popup file browser

parseName

private java.lang.String parseName
current name of "name=value" pair for StringTokenizer

parseValue

private java.lang.String parseValue
current value of "name=value" pair for StringTokenizer

parseDelimChar

private int parseDelimChar
current delim of "name(delim)value" pair for StringTokenizer

dbugFlag

boolean dbugFlag
Flag set debugging - toggled by dbugCheckbox if DBUG_FLAG is set

useSPlusFlag

boolean useSPlusFlag
Flag to use S-Plus, else use R. This is needed if both R and S-Plus are on the same system. The default is FALSE and is to use R.

useRLOloggingFlag

boolean useRLOloggingFlag
Flag for RLO Report logging by creating subdirectory in {project}/Report/{RLOname}-yymmdd.hhmmss/ to store the RLO output files copied to Report/

rloReportLoggingFile

java.lang.String rloReportLoggingFile
Name of RLO Report logging by creating subdirectory {project}/Report/{RLOname}-yymmdd.hhmmss/ to store the RLO output files copied to Report/

timeStampReportDir

java.lang.String timeStampReportDir
time stamp dir for reports

javaHome

static java.lang.String javaHome

osName

static java.lang.String osName

fileSeparator

static java.lang.String fileSeparator

userDir

static java.lang.String userDir

isWindowsFlag

static boolean isWindowsFlag
Flag set if running on a Windows computer

RLO_VERSION

static final java.lang.String RLO_VERSION
current RLO version number for I/O

MAX_ANALYSES

static final int MAX_ANALYSES
default # of analyses allowed

analyses

static RLO[] analyses
List [0:nAnalyses-1] of R analysis procedures descriptions

nAnalyses

static int nAnalyses
# of Rscript analysis procedures

maxRLO

static int maxRLO
max # of Rscript analysis procedures

curAnalysis

static int curAnalysis
Current analysis procedure being used from the analyses[] list

DEFAULT_R_OUTPUT_FILE

private static final java.lang.String DEFAULT_R_OUTPUT_FILE
default output file for R to save any output if we do not specify an output file for the current analysis.

NO_R_INSTALLED

private static final java.lang.String NO_R_INSTALLED
This is the name of the path for the saved R base path in the Temp/.RbasePath file it it ever tried to prompt for the R base path and there was no response to the\ prompt. This means R is not installed.

reportBasePath

static java.lang.String reportBasePath
path of {client project} Report/ directory

RscriptBasePath

static java.lang.String RscriptBasePath
path of {client installation} R/ directory

RLObasePath

static java.lang.String RLObasePath
path of {client installation} RLO/ directory

tempBasePath

static java.lang.String tempBasePath
path of {client project} Temp/ directory

clientRlibrBasePath

static java.lang.String clientRlibrBasePath
base path of where {client installation} R project RLORlibr/ directory lives

RLORlibr

static java.lang.String RLORlibr
Clients R project RLORlibr/ directory lives. Default to "RLORlibr"

RbinBasePath

static java.lang.String RbinBasePath
base bin Path to R executable if it exists. E.g., "C://R/bin/", or "C://Program Files/R/bin, or "/usr/opt/R/bin/", etc.

SPlusBinBasePath

static java.lang.String SPlusBinBasePath
base bin Path to S-Plus executable if it exists. e.g., "C://Program Files/insightful/splus61/cmd/", or "/usr/opt/insightful/splus61/cmd/", etc.

RuserBasePath

static java.lang.String RuserBasePath
user's home directory for e.g.env "R_USER" or "HOME" or "C:/R/", etc. Note: R_USER may not be defined, in which case it defaults to the starting directory i.e. C:/R/" or C:/Program Files/{client program}". This is potentially a problem, since in a shared system, the user may not have admin access. In that case they need to explicitly set the env variable "R_USER" to the {project}/Temp where the are working.

RbasePath

static java.lang.String RbasePath
base Path to R executable e.g. "C://R/"

SPlusBasePath

static java.lang.String SPlusBasePath
base path to S-Plus executable e.g. "C://Program files/splus61/"

quoteRunPathFlag

static boolean quoteRunPathFlag
If the flag is set then add "\ ...\" around exec program "\"" + RbinBasePath + ("Rterm" or "splus") + "\"" BEFORE exec

inputRscriptFileName

static java.lang.String inputRscriptFileName

startupRscriptFileName

static java.lang.String startupRscriptFileName
name of current batch R startup script file to exec() by the OS

reportFileName

static java.lang.String reportFileName
path of Text report file in Report/ if doing a "SaveAs" of TextArea

fullRunRfilePath

static java.lang.String fullRunRfilePath
full path of batch R startup script file

fullRscriptInputPath

static java.lang.String fullRscriptInputPath
full path of .R input script file

fullRoutputFilePath

java.lang.String fullRoutputFilePath
full path of R output file

specificCreateInputFileProblem

java.lang.String specificCreateInputFileProblem
If createInputDataFiles() failed, this is a suggestion on how to fix the problem.

rDataTypeName

static java.lang.String[] rDataTypeName
client export data file types names for import to R

rDataTypeMenu

static java.lang.String[] rDataTypeMenu
client export data file types menu entries for import to R

rDataTypeVal

static int[] rDataTypeVal
client export data file types values for import to R

nRdataTypes

static int nRdataTypes
Number of client export data file types for import to R

rOfileTypeName

static java.lang.String[] rOfileTypeName
R output file types names

rOfileTypeMenu

static java.lang.String[] rOfileTypeMenu
R output file types menu entries

rOfileTypeVal

static int[] rOfileTypeVal
R output file types values

nOfileTypes

static int nOfileTypes
Number of R output file types

rOfileTypeStdOut

static int rOfileTypeStdOut
Special StdOut Output File type needed for RevalBase class

r2ClientActionName

static java.lang.String[] r2ClientActionName
R2Client actions names

r2ClientActionMenu

static java.lang.String[] r2ClientActionMenu
R2Client actions menu entries

r2ClientActionVal

static int[] r2ClientActionVal

nR2ClientActions

static int nR2ClientActions
Number of R2Client actions

rProcessBitName

static java.lang.String[] rProcessBitName
R2Client actions names

rProcessBitMenu

static java.lang.String[] rProcessBitMenu
Process Bits to use Menu entries

rProcessBitVal

static int[] rProcessBitVal
Process Bits to use values

nProcessBits

static int nProcessBits
Number of R2Client actions

rPB_useVanillaBit

static int rPB_useVanillaBit
Special process bit needed for RevalBase class

rlo

RLO rlo
instance of the RLO database.

rReport

java.lang.String rReport
Report text that results from running an R script. This text is read back from the Report/ if an R_FILE_TYPE_REPORT was specified for that analysis. If there is an error in performing the eval, then rReport may contain that error.

rStdout

java.lang.String rStdout
Stdout (and stderr) text that results from running an R script. This text is captured during the eval of the R script.
Constructor Detail

RevalBase

RevalBase(java.lang.String clientName,
          java.lang.String r2ClientPrefix,
          java.lang.String RLORlibr,
          int maxAnalyses)
RevalBase() - constructor for initial database allocation
Parameters:
clientName - is the name of the client that is calling us
r2ClientPrefix - is the name of the client that is calling us
RLORlibr - is the name of the client's R library, it defaults to "RLORlibr" if not specified.
maxAnalyses - to set up the database
Method Detail

setRdataTypeDB

boolean setRdataTypeDB(java.lang.String[] names,
                       java.lang.String[] menus,
                       int[] values)
setRdataTypeDB() - set the export-types (name,menu,type) database. These files are output by the client and read by R.
Parameters:
names - is list of file names output by client and read by R
menus - is list of menu entries
values - is list of corresponding values
Returns:
true if succeed

setOfileTypeDB

boolean setOfileTypeDB(java.lang.String[] names,
                       java.lang.String[] menus,
                       int[] values)
setOfileTypeDB() - set the R output file-types (name,menu,type) database. These files are output by R.
Parameters:
names - is list of file names output by R
menus - is list of menu entries
values - is list of corresponding values
Returns:
true if succeed

setR2ClientActionDB

boolean setR2ClientActionDB(java.lang.String[] names,
                            java.lang.String[] menus,
                            int[] values)
setR2ClientActionDB() - set the R to client Actions (name,menu,type) database.
Parameters:
names - is list of names of actions
menus - is list of menu entries
values - is list of corresponding type values
Returns:
true if succeed

setProcessBitsDB

boolean setProcessBitsDB(java.lang.String[] names,
                         java.lang.String[] menus,
                         int[] values)
setProcessBitsDB() - set the Export/Import ProcessBits (name,menuOn,menuOFF,type) database.
Parameters:
names - is list of names
menus - is list of menu entries
values - is list of corresponding values
Returns:
true if succeed

lookupRdataTypeDBmenu

java.lang.String lookupRdataTypeDBmenu(java.lang.String name)
lookupRdataTypeDBmenu() - lookup the export-types menu entry by name.
Parameters:
name - is the file name to lookup
Returns:
menu else null if not found

lookupRdataTypeDBmenu

java.lang.String lookupRdataTypeDBmenu(int val)
lookupRdataTypeDBmenu() - lookup the export-types menu entry by value.
Parameters:
value - is the file name to lookup
Returns:
menu else null if not found

lookupRdataTypeDBvalue

int lookupRdataTypeDBvalue(java.lang.String name)
lookupRdataTypeDBvalue() - lookup the export-types value by name.
Parameters:
name - is the file name to lookup
Returns:
value else 0 if not found

lookupOfileTypeDBmenu

java.lang.String lookupOfileTypeDBmenu(java.lang.String name)
lookupOfileTypeDBmenu() - lookup R output file type menu entry by name.
Parameters:
name - is the file name to lookup
Returns:
menu else null if not found

lookupOfileTypeDBmenu

java.lang.String lookupOfileTypeDBmenu(int val)
lookupOfileTypeDBmenu() - lookup R output file type menu entry by value.
Parameters:
val - is the entry value
Returns:
menu else null if not found

lookupOfileTypeDBvalue

int lookupOfileTypeDBvalue(java.lang.String name)
lookupOfileTypeDBvalue() - lookup R output file type value by name.
Parameters:
name - is the file name to lookup
Returns:
value else 0 if not found

lookupR2ClientActionDBMenu

java.lang.String lookupR2ClientActionDBMenu(java.lang.String name)
lookupR2ClientActionDBMenu() - lookup R to client Action menu by name
Parameters:
name - is the name of entry
Returns:
menu else null if not found

lookupR2ClientActionDBMenu

java.lang.String lookupR2ClientActionDBMenu(int val)
lookupR2ClientActionDBMenu() - lookup R to client Action menu by value
Parameters:
value - is of the action
Returns:
menu else null if not found

lookupR2ClientActionDBvalue

int lookupR2ClientActionDBvalue(java.lang.String name)
lookupR2ClientActionDBvalue() - lookup R to client Action value by name
Parameters:
name - is the name of entry
Returns:
menu else 0 if not found

lookupProcessBitsDBmenu

java.lang.String lookupProcessBitsDBmenu(int i,
                                         int val)
lookupProcessBitsDBmenu() - lookup Export/Import ProcessBits menu by value
Parameters:
i - is ith process bit
value - is of the process bit
Returns:
menu else null if not found

lookupR2ClientActionDBtype

int lookupR2ClientActionDBtype(java.lang.String name)
lookupR2ClientActionDBtype() - lookup R to client Action type value by name
Parameters:
name - is name of the action
Returns:
value else 0 if not found

lookupProcessBitsDBvalue

int lookupProcessBitsDBvalue(java.lang.String name)
lookupProcessBitsDBvalue() - lookup the Export/Import ProcessBits value by name
Parameters:
name - is the name to lookup
Returns:
value if found, 0 if not found.

cvtInputType2Str

java.lang.String cvtInputType2Str(int val)
cvtInputType2Str() - convertinput file type R_FILE_TYPE_xxxx to string
Parameters:
val - to convert
Returns:
string name if found, else "Illegal"

cvtOutType2Str

java.lang.String cvtOutType2Str(int val)
cvtOutType2Str() - convert output file type to string
Parameters:
val - to convert
Returns:
string name if found, else "Illegal"

cvtR2ClientType2Str

java.lang.String cvtR2ClientType2Str(int val)
cvtR2ClientType2Str() - convert R2Client file type R to string
Parameters:
val - to convert
Returns:
string name if found, else "Illegal"

getRdataTypeDBnames

java.lang.String[] getRdataTypeDBnames()
getRdataTypeDBnames() - get the R input file type names
Returns:
list of names

getRdataTypeDBmenus

java.lang.String[] getRdataTypeDBmenus()
getRdataTypeDBmenus() - get the R input file type menus
Returns:
list of menu entries

getRdataTypeDBtypes

int[] getRdataTypeDBtypes()
getRdataTypeDBtypes() - get the R input file type values
Returns:
list of values

getOfileTypeDBnames

java.lang.String[] getOfileTypeDBnames()
getOfileTypeDBnames() - get the R output file type names
Returns:
list of file names

getOfileTypeDBmenus

java.lang.String[] getOfileTypeDBmenus()
getOfileTypeDBmenus() - get the R output file type menu
Returns:
list of menu entries

getOfileTypeDBtypes

int[] getOfileTypeDBtypes()
getOfileTypeDBtypes() - get the R output file names type values
Returns:
list of values

getR2ClientActionDBnames

java.lang.String[] getR2ClientActionDBnames()
getR2ClientActionDBnames() - get R to client Actions DB names
Returns:
list of names

getR2ClientActionDBmenus

java.lang.String[] getR2ClientActionDBmenus()
getR2ClientActionDBmenus() - get R to client Actions DB menus
Returns:
list of menu entries

getR2ClientActionDBtypes

int[] getR2ClientActionDBtypes()
getR2ClientActionDBtypes() - get R to client Actions DB type values
Returns:
list of values

getProcessBitsDBnames

java.lang.String[] getProcessBitsDBnames()
getProcessBitsDBnames() - get Export/Import ProcessBits DB names
Returns:
list of names

getProcessBitsDBmenus

java.lang.String[] getProcessBitsDBmenus()
getProcessBitsDBmenus() - get Export/Import ProcessBits DB menus entries
Returns:
list of menu entries

getProcessBitsDBvalues

int[] getProcessBitsDBvalues()
getProcessBitsDBvalues() - get Export/Import ProcessBits DB values
Returns:
list of values

setRLOreportLoggingFlag

void setRLOreportLoggingFlag(boolean flag)
setRLOreportLoggingFlag() - set RLO Report logging flag for creating subdirectory in {project}/Report/{RLOname}-yymmdd.hhmmss/ to store the RLO output files copied to Report/

setDbugFlag

void setDbugFlag(boolean flag)
setDbugFlag() - set debugging flag to print to stdout if required

setupAllBasePaths

boolean setupAllBasePaths(java.lang.String clientPrjPath)
setupAllBasePaths() - generate all base paths of directories
 1. RbinBasePath is the executable bin directory for 
    running R in ,
 2. reportBasePath for saving reports in {project}/Report/, 
 3. RscriptBasePath is the {client installation}/R/
    for .R scripts, 
 4. tempBasePath is the {project directory}/Temp/ directory used for 
    R data input,
 5. clientRlibrBasePath is "/lib"
    dir where R project RLORlibr/ directory lives  
 
Parameters:
clientPrjPath - is the client project base path
Returns:
true if succeed
See Also:
setupRbinPath(boolean)

cvtBackslash2Fwdslash

private static java.lang.String cvtBackslash2Fwdslash(java.lang.String sInput)
cvtBackslash2Fwdslash() - convert '\\' to '/' in the string
Parameters:
sInput - is input string
return - converted string

simpleLookupRprogramPath

static java.lang.String simpleLookupRprogramPath()
simpleLookupRprogramPath() - lookup RbinBasePath by analyzing OS env vars and OS name.
Returns:
R bin path, else null if failed to find it in the obvious places

simpleLookupSPLUSprogramPath

static java.lang.String simpleLookupSPLUSprogramPath()
simpleLookupSPLUSprogramPath() - lookup SPlusBinBasePath by analyzing OS env vars and OS name.
Returns:
SPlus bin path, else null if failed to find it in the obvious places

sortArray

private static java.lang.String[] sortArray(java.lang.String[] data,
                                            boolean sortAscending)
sortArray() - bubble sort string array either ASCENDING or DESCENDING. This uses a bubble sort. eg. A1, A10, A2 should be sorted as A1, A2, A10. Should be able to use a RuleBasedCollator...
Parameters:
data - array of data to be sorted
sortAscending - direction of sort
Returns:
the sorted list.

cvtEnvPaths2Properties

private static boolean cvtEnvPaths2Properties()
cvtEnvPaths2Properties() - get all system ENV variables and set them as separate Java properties so we can get them individually from System.getProperty(var) calls.
Returns:
true if succeed

setupRbinPath

java.lang.String setupRbinPath(boolean promptIfNotFoundFlag)
setupRbinPath() - setup RbinBasePath by analyzing OS env vars and OS name. This is where we will put the batch script and will do the exec() of Rterm later.
Parameters:
promptIfNotFoundFlag - to ask user where installed if not found. If this flag is NOT set, return null if the R installation is not found.
Returns:
R bin path, else null if failed to setup correctly
See Also:
Util.cvtEnvPaths2Properties(), promptFileName(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
accept() - file browser filter used to test if file should be in directory list. NOTE: implements method for io.FilenameFilter.accept() Checks if the file extension is promptExt
Parameters:
dir - is the file directory
name - is the name of the file
Returns:
true if accept it
See Also:
promptFileName(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)

promptFileName

public java.lang.String promptFileName(java.lang.String msg,
                                       java.lang.String useDir,
                                       java.lang.String initialFile,
                                       java.lang.String subDir,
                                       java.lang.String fileExt,
                                       boolean saveMode,
                                       boolean useFileDialog)
promptFileName() - dialog prompt for file name. If useFileDialog is set use FileDialog else dialogQuery. Set promptFile, and promptDir.
Parameters:
msg - is the prompt msg
useDir - is the opt. dir to use
initialFile - is the opt. initial file
subDir - is the opt. subdir to use
fileExt - is the file extension
saveMode - is the mode. Save if true else Open
useFileDialog - if true else query dialog
Returns:
the file name.
See Also:
accept(java.io.File, java.lang.String)

runRscriptWithR

java.lang.String runRscriptWithR()
runRscriptWithR() - compute report string by running R script through R. Note: if S-Plus is to be used (and it exists on the system), then useSPlusFlag is true. The fullRunRfilePath and remapped Rscript will be set up to take this into account. We eval the script after prepping required data into Temp/ for the curAnalysis by exec'ing an R or S-Plus process. After it completes, we read the output files from Report/ required by the analyses[curAnalysis] specification.
Returns:
results of running R script
See Also:
createTempRscript(java.lang.String), createInputDataFiles(java.lang.String), #getRLOoutFile, getCurrentRLO(), setCurrentRLO(int)

execRscript

private java.lang.String execRscript()
execRscript() - exec R with cmd to process the .R script. Note: if S-Plus is to be used (and it exists on the system), then useSPlusFlag is true. The fullRunRfilePath and remapped Rscript will be set up to take this into account.

It uses a batch file to call R via the Rtermprogram. For S-Plus, the batch file calls splus or sqpe program.

The results from R are save to a file in the Reports/R-OutputFile.txt folder.

Returns:
stdout response from evaling .R script by R, null if failed.

getCurDateStr

private static java.lang.String getCurDateStr()
getCurDateStr() - return date string in the format of YYMMDDHHMMSS. Note: Adds "0" to first single digit if value is 1-9.

copyTempOutputFilesToReportDir

private void copyTempOutputFilesToReportDir()
copyTempOutputFilesToReportDir() - show plots generated if any with the last R eval. If there were no plots generated with the last Eval, then it is a no-op. Just say so in the msg area.

If the useRLOloggingFlag is set, then use RLO Report logging by creating subdirectory in {project}/Report/{RLOname}-yymmdd.hhmmss/ to store the RLO output files copied to Report/.

See Also:
RLO.getCurrentRLO()

createTempRscript

private java.lang.String createTempRscript(java.lang.String RscriptName)
createTempRscript() - create a copy of the .R script in /Temp/ for the current RLO database analysis currently selected. The .R script is always copied to the /Temp/ and a R command "setwd(" + tempBasePath +")" and "library("+RLORlibr+",lib.loc=\"" + clientRlibrBasePath + "\")" are prepended TO THE FRONT of the contents of the .R script to tell R to set the working direfory here. The script name has a "tmp-" prefix to the original RscriptName. We use the new .R script name in the fullRscriptInputPath.
Parameters:
RscriptName - is the name of the script to use
Returns:
null if ok, else contains error message

createRunRscript

private java.lang.String createRunRscript()
createRunRscript() - create startup script to run R that is OS specific
Returns:
startup script
See Also:
RLO.getCurrentRLO()

getNbrAnalyses

int getNbrAnalyses()
getNbrAnalyses() - get the number of analyses in the RLO DB
Returns:
# of analyses in the RLO DB

getListofRLOscriptNames

java.lang.String[] getListofRLOscriptNames()
getListofRLOscriptNames() - get list of all R script names
Returns:
list of RLO Rscript names

getListofRLOmenuNames

java.lang.String[] getListofRLOmenuNames()
getListofRLOmenuNames() - get list of all menuNames
Returns:
list of RLO menu names

newRLO

int newRLO()
newRLO() - create new empty R LayOut (RLO) instance to the RLO database.
Returns:
the id number

addRLO

int addRLO(java.lang.String menuName,
           java.lang.String menuStubName,
           java.lang.String RscriptName,
           java.lang.String[] inputDataFileNames,
           int[] inputDataTypes,
           int processBits,
           int genRbits,
           java.lang.String[] outputDataFileNames,
           int[] outputDataTypes,
           java.lang.String[] setR2ClientFileNames,
           java.lang.String[] setR2ClientObjNames,
           int[] setR2ClientObjTypes,
           java.lang.String scriptSpecificRoptions)
addRLO() - add new R LayOut (RLO) instance to the RLO database. The RLO is a meta-language for specifying the processing interaction between R and client.

E.g., the following is an example that exports various types (4) of client data, generates 4 types of output files, and sets the client state from 2 of those files.

[TODO] redo documentation ...

 String inFiles[]= { "R-InputFile-XY-classNames.txt",
                     "R-InputFile-X-sample-names.txt",
                     "R-InputFile-Y-sample-names.txt",
                     "R-InputFile-XY-sets-expr.txt" };
 int inTypes[]= { R_DATA_TYPE_XY_CLASSNAMES,
                  R_DATA_TYPE_HP_X_SET_SAMPLENAMES,
                  R_DATA_TYPE_HP_Y_SET_SAMPLENAMES,
                  R_DATA_TYPE_HP_XY_SETS };
 int processBits= (R_PB_USE_FILTER | R_PB_SAMPLES_HDR);
 int genRbits= (R_GENR_HIST | R_GENR_LOWESS | R_GENR_PLOT);    
 String outFiles[]= { "R-Stdout.txt", "R-OutputFile.pdf", 
                      "R-GeneSet.txt", "R-ConditionList.txt",
                      "R-LowessTbl.txt"};
 int outTypes[]= { R_FILE_TYPE_STDOUT, R_FILE_TYPE_PDF,
                   R_FILE_TYPE_TAB_DELIM_TBL, R_FILE_TYPE_TAB_DELIM_TBL,
                   R_FILE_TYPE_TAB_DELIM_TBL}; 
 String setR2ClientFiles[]= { "R-GeneSet.txt", "R-ConditionList.txt" };
 String setR2ClientObjs[]= { "Clustered-Genes", "Similar-Samples" };
 int setR2ClientType[]= { R_SET_R2CLIENT__GENE_SET, 
                          R_SET_R2CLIENT__CONDITION_LIST };
 String scriptSpecificRoptions= "--vsize=20M";

  addRLO( "Analyze HP-XY 'set' expression data", "Plugins:RLOmethods",
          "ClientAnalyzeXYsets.R",
          inFiles, inTypes, 
          processBits, genRbits,
          outFiles, outTypes,
          setR2ClientFiles, setR2ClientObjs, setR2ClientType,
          scriptSpecificRoptions );
Parameters:
menuName - text description of the RLO entry
menuStubName - used by client to put RLO menu entry in a particular menu.
RscriptName - is the name of the .R file
inputDataFileNames - opt. list of R input data file names
inputDataTypes - corresponding list of R input data file types
processBits - set used during eval
genRbits - set used during edit by R script GUI (0 if none)
outputDataFileNames - opt. list of R output data file names
outputDataTypes - corresponding list of R output data file types
setR2ClientFileNames - opt. list of file names to set R output data to client state objects
setR2ClientObjNames - opt. list of client object names to set R output data to client state objects
setR2ClientObjType - opt. list of client object types to set R output data to client state objects
scriptSpecificRoptions -  
Returns:
the id number

setRLO

boolean setRLO(int rloID,
               java.lang.String menuName,
               java.lang.String menuStubName,
               java.lang.String RscriptName,
               java.lang.String[] inputDataFileNames,
               int[] inputDataTypes,
               int processBits,
               int genRbits,
               java.lang.String[] outputDataFileNames,
               int[] outputDataTypes,
               java.lang.String[] setR2ClientFileNames,
               java.lang.String[] setR2ClientObjNames,
               int[] setR2ClientObjTypes,
               java.lang.String scriptSpecificRoptions)
setRLO() - set R LayOut (RLO) instance to the RLO database. The RLO is a meta-language for specifying the processing interaction between R and client.

E.g., the following is an example that exports various types (4) of client data, generates 4 types of output files, and sets the client state from 2 of those files.

[TODO] redo documentation ...

 int rloID= 10;
 String inFiles[]= { "R-InputFile-XY-classNames.txt",
                     "R-InputFile-X-sample-names.txt",
                     "R-InputFile-Y-sample-names.txt",
                     "R-InputFile-XY-sets-expr.txt" };
 int inTypes[]= { R_DATA_TYPE_XY_CLASSNAMES,
                  R_DATA_TYPE_HP_X_SET_SAMPLENAMES,
                  R_DATA_TYPE_HP_Y_SET_SAMPLENAMES,
                  R_DATA_TYPE_HP_XY_SETS };
 int processBits= (R_PB_USE_FILTER | R_PB_SAMPLES_HDR);
 int genRbits= (R_GENR_HIST | R_GENR_LOWESS | R_GENR_PLOT);
 String outFiles[]= { "R-Stdout.txt", "R-OutputFile.pdf",
                      "R-GeneSet.txt", "R-ConditionList.txt",
                      "R-LowessTbl.txt"};
 int outTypes[]= { R_FILE_TYPE_STDOUT, R_FILE_TYPE_PDF,
                   R_FILE_TYPE_TAB_DELIM_TBL, R_FILE_TYPE_TAB_DELIM_TBL,
                   R_FILE_TYPE_TAB_DELIM_TBL};
 String setR2ClientFiles[]= { "R-GeneSet.txt", "R-ConditionList.txt" };
 String setR2ClientObjs[]= { "Clustered-Genes", "Similar-Samples" };
 int setR2ClientType[]= { R_SET_R2CLIENT__GENE_SET,
                          R_SET_R2CLIENT__CONDITION_LIST };
 String scriptSpecificRoptions= "--vsize=20M";

   setRLO(rloID,
          "Analyze HP-XY 'set' expression data", "Plugins:RLOmethods",
          "ClientAnalyzeXYsets.R",
          inFiles, inTypes,
          processBits, genRbits,
          outFiles, outTypes,
          setR2ClientFiles, setR2ClientObjs, setR2ClientType,
          scriptSpecificRoptions );
Parameters:
rloID - is the RLO to assign new data
menuName - text description of the RLO entry
menuStubName - used by client to put RLO menu entry in a particular menu.
RscriptName - is the name of the .R file
inputDataFileNames - opt. list of R input data file names
inputDataTypes - corresponding list of R input data file types
processBits - set used during eval
genRbits - set used during edit by R script GUI (0 if none)
outputDataFileNames - opt. list of R output data file names
outputDataTypes - corresponding list of R output data file types
setR2ClientFileNames - opt. list of file names to set R output data to client state objects
setR2ClientObjNames - opt. list of client object names to set R output data to client state objects
setR2ClientObjType - opt. list of client object types to set R output data to client state objects
scriptSpecificRoptions -  
Returns:
true if succeed

rmvRLO

public final boolean rmvRLO(int rloIdToRemove)
rmvRLO() - remove the RLO from the analyses database
Parameters:
rloIdToRemove - to remove
Returns:
true if removed

clearRLOdb

public final void clearRLOdb()
clearRLOdb() - clear list of R LayOuts analyses in the database

getRLOidByRscriptName

public final int getRLOidByRscriptName(java.lang.String RscriptName)
getRLOidByRscriptName() - get the current RLO analysis method id by RscriptName
Parameters:
RscriptName - to lookup in the database
Returns:
current RLO object id, -1 if not found

getCurrentRLO

RLO getCurrentRLO()
getCurrentRLO() - get the current RLO analysis method object
Returns:
current RLO object

setCurrentRLO

void setCurrentRLO(int analysisNbr)
setCurrentRLO() - set the current RLO analysis method by id
Parameters:
analysisNbr - to set as the current analysis method

getInputDataFileNames

java.lang.String[] getInputDataFileNames()
getInputDataFileNames() - get current RLO list of input data file names
Returns:
current RLO list of output data file names

getInputDataTypes

int[] getInputDataTypes()
getInputDataTypes() - get current RLO list of input data file types
Returns:
current RLO list of input data file types

getOutputDataFileNames

java.lang.String[] getOutputDataFileNames()
getOutputDataFileNames() - get current RLO list of output data file names.
Returns:
current RLO list of output data file names

getOutputDataTypes

int[] getOutputDataTypes()
getOutputDataTypes() - get current RLO list of output data file types
Returns:
current RLO list of output data file types

getSetR2ClientFileNames

java.lang.String[] getSetR2ClientFileNames()
getSetR2ClientFileNames() - get current RLO list of R2Client data file names. Note the data file is also specified in the output file names.
Returns:
current RLO list of R2Client data file names

getSetR2ClientObjNames

java.lang.String[] getSetR2ClientObjNames()
getSetR2ClientObjNames() - get current RLO list of R2Client object names
Returns:
current RLO list of R2Client object names

getSetR2ClientObjTypes

int[] getSetR2ClientObjTypes()
getSetR2ClientObjTypes() - get current RLO list of R2Client object types
Returns:
current RLO list of R2Client object types

cvRLO2string

java.lang.String cvRLO2string(int rloID,
                              java.lang.String optProcessBitsStr,
                              java.lang.String optGenRbitsStr)
cvRLO2string() - create string representing the R LayOut (RLO) of the instance
Parameters:
rloID - is the index of the RLO to convert
optProcessBitsStr - optional ProcessBits string if computed elsewhere...
optGenRbitsStr - optional genRbits representation computed elsewhere.
Returns:
string representing the RLO

setInputFilesData

public final boolean setInputFilesData(java.lang.String[] fileNames,
                                       int[] dataTypes)
setInputFilesData() - set current RLO list of input data (fileName,dataType)
Parameters:
fileNames - - list of input files names
dataTypes - - list of input files data types
Returns:
true if succeed

setOutputFilesData

public final boolean setOutputFilesData(java.lang.String[] fileNames,
                                        int[] dataTypes)
setOutputFilesData() - set current RLO list of output data (fileName,dataType)
Parameters:
fileNames - - list of input files names
dataTypes - - list of input files data types
Returns:
true if succeed

setR2ClientFilesData

public final boolean setR2ClientFilesData(java.lang.String[] fileNames,
                                          java.lang.String[] objNames,
                                          int[] objTypes)
setR2ClientFilesData() - set cur. RLO list of R2Client (file,obj,type) data.
Parameters:
fileNames - - list of R2Client file names
objNames - - list of R2Client object names
objTypes - - list of R2Client object types
Returns:
true if succeed

getAllProcessBits

public final int getAllProcessBits()

setAllProcessBits

public final void setAllProcessBits(int bits)
setAllProcessBits() - set Process Bits using R_PB_xxxx bits for current RLO.
Parameters:
bits - to use in set in RLO process bits pattern

toString

java.lang.String toString(int rloID,
                          java.lang.String optProcessBitsStr,
                          java.lang.String optGenRbitsStr)
toString() - create string representing the R LayOut (RLO) of the RLO instance
Parameters:
rloID - is the index of the RLO to convert
optProcessBitsStr - optional ProcessBits string if computed elsewhere...
optGenRbitsStr - optional genRbits string if computed elsewhere...
Returns:
string representing the RLO

writePermanentRLOdatabase

boolean writePermanentRLOdatabase()
writePermanentRLOdatabase() - write RLO entries to the permanent /RLO/ database. Note: it does NOT write demo databases with the genRbit R_GENR_DEMO set.
Returns:
true if succeed

readPermanentRLOdatabase

boolean readPermanentRLOdatabase(boolean loadDemoRLOsFlag)
readPermanentRLOdatabase() - read RLO entries from the permanent /RLO/*.rlo file database.
Parameters:
loadDemoRLOsFlag - to read demo .rlo databases, else they are ignored.
Returns:
true if succeed

rmvRtnChars

private static java.lang.String rmvRtnChars(java.lang.String str)
rmvRtnChars() - remove return chars. Map '\r' or "\r\n" to '\n' chars.
Parameters:
String - str to process
Returns:
String with '\r' removed.

getNextStrNameValFromLine

private boolean getNextStrNameValFromLine(java.util.StringTokenizer parser)
getNextStrNameValFromLine() - get next line and parse 'name=value\n'. Return false if EOF. If fail, return null. The (parseName, parseValue, parseDelimChar) is saved in the global instance.
Parameters:
parser - is the string tokenizer
Returns:
true succeed

getStrValFromLine

private java.lang.String getStrValFromLine(java.lang.String key,
                                           java.util.StringTokenizer parser)
getStrValFromLine() - get line and parse value for key 'name=value\n'. If parser is not null, get data from parser else use global values for next (parseName,parseValue) data. The (parseName, parseValue, parseDelimChar) is saved in the global instance so it can be reparsed if need be.
Parameters:
key - is the key to use
parser - is the string tokenizer
Returns:
parseValue. If fail, return null.
See Also:
getNextStrNameValFromLine(java.util.StringTokenizer)

cvs2i

private static int cvs2i(java.lang.String str,
                         int defaultValue)
cvs2i() - convert String to int with default value
Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

readRLOfile

int readRLOfile(java.lang.String rloFileName,
                boolean allowDemoLoadFlag)
readRLOfile() - read RLO by .rlo file name into a new RLO (rloID). The file resides in {MAEsplorer installation}/RLO/*.rlo file
Parameters:
rloFileName - full path file name for .rlo file
allowDemoLoadFlag - to allow loading DEMO .rlo files
Returns:
the new RLO id generated by doing an addRLO(), else -1 if failed
See Also:
getNextStrNameValFromLine(java.util.StringTokenizer), getStrValFromLine(java.lang.String, java.util.StringTokenizer)

writeRLOfile

boolean writeRLOfile(java.lang.String rloBasePath,
                     int rloID)
writeRLOfile() - write RLO by .rlo file name for specified RLO (rloID). The file resides in {Client installation}/RLO/{rScriptName}.rlo file
Parameters:
rloBasePath - is the base path of the RLO/ directory
rloID - to save as .rlo file
Returns:
true if succeed
See Also:
FileIO.writeData(java.lang.String, java.lang.String, java.lang.String), Util.cvtSpacesToUnderscores(java.lang.String), Util.showMsg(java.lang.String)

popupDialog

abstract java.lang.String popupDialog(java.lang.String promptMsg,
                                      java.lang.String defaultAnswer)
popupDialog() prompt with message and return response.
Parameters:
promptMsg - is prompt message
default - if press cancel
Returns:
result

copyFile

abstract boolean copyFile(java.lang.String srcName,
                          java.lang.String dstName,
                          java.lang.String optUpdateMsg,
                          int optEstInputFileLth)
copyFile() - binary copy of one file or URL toa local file
Parameters:
srcName - is either a full path local file name or a http:// prefixed URL string of the source file.
dstName - is the full path of the local destination file name
optUpdateMsg - (opt) will display message in showMsg() and increasing ... in showMsg2(). One '.' for every 10K bytes read. This only is used when reading a URL. Set to null if not used.
optEstInputFileLth - is the estimate size of the in;ut file if known else 0. Used in progress bar.
Returns:
true if succeed.

deleteLocalFile

abstract boolean deleteLocalFile(java.lang.String fileName)
deleteLocalFile() - delete local file.
Parameters:
fileName - to be deleted on the local file system.
Returns:
false if failed.

showMsg

abstract void showMsg(java.lang.String msg)
showMsg() - display message in client GUI
Parameters:
msg - message to display

setWaitCursor

abstract void setWaitCursor(boolean flag)
setWaitCursor() - turn wait cursor on and off
Parameters:
flag - to turn wait cursor on or off

readTextFromFile

abstract java.lang.String readTextFromFile(java.lang.String fileName,
                                           java.lang.String loadingMsg)
readTextFromFile() - read text from text file.
Parameters:
fileName - full path name of text file
loadingMsg - to display while loading, null if no message
Returns:
text if suceed else null

writeTextToFile

abstract boolean writeTextToFile(java.lang.String textFileName,
                                 java.lang.String textReport)
writeTextToFile() - save text string as text file.
Parameters:
textFileName - full path name of text file
textReport - text to save in file
Returns:
true if succeed.

setRoutput2ClientObjects

abstract boolean setRoutput2ClientObjects()
setRoutput2ClientObjects() - copy data for any entries in the RLO. It will read R output files and convert them to analysis system dependent data structures and save into the state of that system.
Returns:
true if performed any R to system dependent conversions.

createInputDataFiles

abstract boolean createInputDataFiles(java.lang.String inputFilesBasePath)
createInputDataFiles() - create any input data files required for current analysis. Generate input files from data obtained by calling the client MJA API as required and saving the generated files in the inputFilesBasePath folder.
Parameters:
inputFilesBasePath - where to put generated files