|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--RevalBase
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/.
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 |
(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 |
(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 |
(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 |
|
Field Detail |
static final boolean REB_DBUG
java.lang.String clientName
java.lang.String r2ClientPrefix
java.lang.String promptFile
java.lang.String promptDir
java.lang.String promptExt
private java.lang.String parseName
private java.lang.String parseValue
private int parseDelimChar
boolean dbugFlag
boolean useSPlusFlag
boolean useRLOloggingFlag
java.lang.String rloReportLoggingFile
java.lang.String timeStampReportDir
static java.lang.String javaHome
static java.lang.String osName
static java.lang.String fileSeparator
static java.lang.String userDir
static boolean isWindowsFlag
static final java.lang.String RLO_VERSION
static final int MAX_ANALYSES
static RLO[] analyses
static int nAnalyses
static int maxRLO
static int curAnalysis
private static final java.lang.String DEFAULT_R_OUTPUT_FILE
private static final java.lang.String NO_R_INSTALLED
static java.lang.String reportBasePath
static java.lang.String RscriptBasePath
static java.lang.String RLObasePath
static java.lang.String tempBasePath
static java.lang.String clientRlibrBasePath
static java.lang.String RLORlibr
static java.lang.String RbinBasePath
static java.lang.String SPlusBinBasePath
static java.lang.String RuserBasePath
static java.lang.String RbasePath
static java.lang.String SPlusBasePath
static boolean quoteRunPathFlag
static java.lang.String inputRscriptFileName
static java.lang.String startupRscriptFileName
static java.lang.String reportFileName
static java.lang.String fullRunRfilePath
static java.lang.String fullRscriptInputPath
java.lang.String fullRoutputFilePath
java.lang.String specificCreateInputFileProblem
static java.lang.String[] rDataTypeName
static java.lang.String[] rDataTypeMenu
static int[] rDataTypeVal
static int nRdataTypes
static java.lang.String[] rOfileTypeName
static java.lang.String[] rOfileTypeMenu
static int[] rOfileTypeVal
static int nOfileTypes
static int rOfileTypeStdOut
static java.lang.String[] r2ClientActionName
static java.lang.String[] r2ClientActionMenu
static int[] r2ClientActionVal
static int nR2ClientActions
static java.lang.String[] rProcessBitName
static java.lang.String[] rProcessBitMenu
static int[] rProcessBitVal
static int nProcessBits
static int rPB_useVanillaBit
RLO rlo
java.lang.String rReport
java.lang.String rStdout
Constructor Detail |
RevalBase(java.lang.String clientName, java.lang.String r2ClientPrefix, java.lang.String RLORlibr, int maxAnalyses)
clientName
- is the name of the client that is calling usr2ClientPrefix
- is the name of the client that is calling usRLORlibr
- is the name of the client's R library, it defaults
to "RLORlibr" if not specified.maxAnalyses
- to set up the databaseMethod Detail |
boolean setRdataTypeDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
names
- is list of file names output by client and read by Rmenus
- is list of menu entriesvalues
- is list of corresponding valuesboolean setOfileTypeDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
names
- is list of file names output by Rmenus
- is list of menu entriesvalues
- is list of corresponding valuesboolean setR2ClientActionDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
names
- is list of names of actionsmenus
- is list of menu entriesvalues
- is list of corresponding type valuesboolean setProcessBitsDB(java.lang.String[] names, java.lang.String[] menus, int[] values)
names
- is list of namesmenus
- is list of menu entriesvalues
- is list of corresponding valuesjava.lang.String lookupRdataTypeDBmenu(java.lang.String name)
name
- is the file name to lookupjava.lang.String lookupRdataTypeDBmenu(int val)
value
- is the file name to lookupint lookupRdataTypeDBvalue(java.lang.String name)
name
- is the file name to lookupjava.lang.String lookupOfileTypeDBmenu(java.lang.String name)
name
- is the file name to lookupjava.lang.String lookupOfileTypeDBmenu(int val)
val
- is the entry valueint lookupOfileTypeDBvalue(java.lang.String name)
name
- is the file name to lookupjava.lang.String lookupR2ClientActionDBMenu(java.lang.String name)
name
- is the name of entryjava.lang.String lookupR2ClientActionDBMenu(int val)
value
- is of the actionint lookupR2ClientActionDBvalue(java.lang.String name)
name
- is the name of entryjava.lang.String lookupProcessBitsDBmenu(int i, int val)
i
- is ith process bitvalue
- is of the process bitint lookupR2ClientActionDBtype(java.lang.String name)
name
- is name of the actionint lookupProcessBitsDBvalue(java.lang.String name)
name
- is the name to lookupjava.lang.String cvtInputType2Str(int val)
val
- to convertjava.lang.String cvtOutType2Str(int val)
val
- to convertjava.lang.String cvtR2ClientType2Str(int val)
val
- to convertjava.lang.String[] getRdataTypeDBnames()
java.lang.String[] getRdataTypeDBmenus()
int[] getRdataTypeDBtypes()
java.lang.String[] getOfileTypeDBnames()
java.lang.String[] getOfileTypeDBmenus()
int[] getOfileTypeDBtypes()
java.lang.String[] getR2ClientActionDBnames()
java.lang.String[] getR2ClientActionDBmenus()
int[] getR2ClientActionDBtypes()
java.lang.String[] getProcessBitsDBnames()
java.lang.String[] getProcessBitsDBmenus()
int[] getProcessBitsDBvalues()
void setRLOreportLoggingFlag(boolean flag)
void setDbugFlag(boolean flag)
boolean setupAllBasePaths(java.lang.String clientPrjPath)
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
clientPrjPath
- is the client project base pathsetupRbinPath(boolean)
private static java.lang.String cvtBackslash2Fwdslash(java.lang.String sInput)
sInput
- is input stringreturn
- converted stringstatic java.lang.String simpleLookupRprogramPath()
static java.lang.String simpleLookupSPLUSprogramPath()
private static java.lang.String[] sortArray(java.lang.String[] data, boolean sortAscending)
data
- array of data to be sortedsortAscending
- direction of sortprivate static boolean cvtEnvPaths2Properties()
java.lang.String setupRbinPath(boolean promptIfNotFoundFlag)
promptIfNotFoundFlag
- to ask user where installed if not found.
If this flag is NOT set, return null if the R installation is
not found.Util.cvtEnvPaths2Properties()
,
promptFileName(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
public boolean accept(java.io.File dir, java.lang.String name)
dir
- is the file directoryname
- is the name of the filepromptFileName(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
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)
msg
- is the prompt msguseDir
- is the opt. dir to useinitialFile
- is the opt. initial filesubDir
- is the opt. subdir to usefileExt
- is the file extensionsaveMode
- is the mode. Save if true else OpenuseFileDialog
- if true else query dialogaccept(java.io.File, java.lang.String)
java.lang.String runRscriptWithR()
createTempRscript(java.lang.String)
,
createInputDataFiles(java.lang.String)
,
#getRLOoutFile
,
getCurrentRLO()
,
setCurrentRLO(int)
private java.lang.String execRscript()
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.
private static java.lang.String getCurDateStr()
private void copyTempOutputFilesToReportDir()
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/.
RLO.getCurrentRLO()
private java.lang.String createTempRscript(java.lang.String RscriptName)
RscriptName
- is the name of the script to useprivate java.lang.String createRunRscript()
RLO.getCurrentRLO()
int getNbrAnalyses()
java.lang.String[] getListofRLOscriptNames()
java.lang.String[] getListofRLOmenuNames()
int newRLO()
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)
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 );
menuName
- text description of the RLO entrymenuStubName
- used by client to put RLO menu entry in a
particular menu.RscriptName
- is the name of the .R fileinputDataFileNames
- opt. list of R input data file namesinputDataTypes
- corresponding list of R input data file typesprocessBits
- set used during evalgenRbits
- set used during edit by R script GUI (0 if none)outputDataFileNames
- opt. list of R output data file namesoutputDataTypes
- corresponding list of R output data file typessetR2ClientFileNames
- opt. list of file names to set R output
data to client state objectssetR2ClientObjNames
- opt. list of client object names to
set R output data to client state objectssetR2ClientObjType
- opt. list of client object types
to set R output data to client state objectsscriptSpecificRoptions
- 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)
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 );
rloID
- is the RLO to assign new datamenuName
- text description of the RLO entrymenuStubName
- used by client to put RLO menu entry in a
particular menu.RscriptName
- is the name of the .R fileinputDataFileNames
- opt. list of R input data file namesinputDataTypes
- corresponding list of R input data file typesprocessBits
- set used during evalgenRbits
- set used during edit by R script GUI (0 if none)outputDataFileNames
- opt. list of R output data file namesoutputDataTypes
- corresponding list of R output data file typessetR2ClientFileNames
- opt. list of file names to set R output
data to client state objectssetR2ClientObjNames
- opt. list of client object names to
set R output data to client state objectssetR2ClientObjType
- opt. list of client object types
to set R output data to client state objectsscriptSpecificRoptions
- public final boolean rmvRLO(int rloIdToRemove)
rloIdToRemove
- to removepublic final void clearRLOdb()
public final int getRLOidByRscriptName(java.lang.String RscriptName)
RscriptName
- to lookup in the databaseRLO getCurrentRLO()
void setCurrentRLO(int analysisNbr)
analysisNbr
- to set as the current analysis methodjava.lang.String[] getInputDataFileNames()
int[] getInputDataTypes()
java.lang.String[] getOutputDataFileNames()
int[] getOutputDataTypes()
java.lang.String[] getSetR2ClientFileNames()
java.lang.String[] getSetR2ClientObjNames()
int[] getSetR2ClientObjTypes()
java.lang.String cvRLO2string(int rloID, java.lang.String optProcessBitsStr, java.lang.String optGenRbitsStr)
rloID
- is the index of the RLO to convertoptProcessBitsStr
- optional ProcessBits string if computed
elsewhere...optGenRbitsStr
- optional genRbits representation computed
elsewhere.public final boolean setInputFilesData(java.lang.String[] fileNames, int[] dataTypes)
fileNames
- - list of input files namesdataTypes
- - list of input files data typespublic final boolean setOutputFilesData(java.lang.String[] fileNames, int[] dataTypes)
fileNames
- - list of input files namesdataTypes
- - list of input files data typespublic final boolean setR2ClientFilesData(java.lang.String[] fileNames, java.lang.String[] objNames, int[] objTypes)
fileNames
- - list of R2Client file namesobjNames
- - list of R2Client object namesobjTypes
- - list of R2Client object typespublic final int getAllProcessBits()
public final void setAllProcessBits(int bits)
bits
- to use in set in RLO process bits patternjava.lang.String toString(int rloID, java.lang.String optProcessBitsStr, java.lang.String optGenRbitsStr)
rloID
- is the index of the RLO to convertoptProcessBitsStr
- optional ProcessBits string if
computed elsewhere...optGenRbitsStr
- optional genRbits string if computed elsewhere...boolean writePermanentRLOdatabase()
boolean readPermanentRLOdatabase(boolean loadDemoRLOsFlag)
loadDemoRLOsFlag
- to read demo .rlo databases, else they are
ignored.private static java.lang.String rmvRtnChars(java.lang.String str)
String
- str to processprivate boolean getNextStrNameValFromLine(java.util.StringTokenizer parser)
parser
- is the string tokenizerprivate java.lang.String getStrValFromLine(java.lang.String key, java.util.StringTokenizer parser)
key
- is the key to useparser
- is the string tokenizergetNextStrNameValFromLine(java.util.StringTokenizer)
private static int cvs2i(java.lang.String str, int defaultValue)
str
- to convertdefaultValue
- if bad numeric stringint readRLOfile(java.lang.String rloFileName, boolean allowDemoLoadFlag)
rloFileName
- full path file name for .rlo fileallowDemoLoadFlag
- to allow loading DEMO .rlo filesgetNextStrNameValFromLine(java.util.StringTokenizer)
,
getStrValFromLine(java.lang.String, java.util.StringTokenizer)
boolean writeRLOfile(java.lang.String rloBasePath, int rloID)
rloBasePath
- is the base path of the RLO/ directoryrloID
- to save as .rlo fileFileIO.writeData(java.lang.String, java.lang.String, java.lang.String)
,
Util.cvtSpacesToUnderscores(java.lang.String)
,
Util.showMsg(java.lang.String)
abstract java.lang.String popupDialog(java.lang.String promptMsg, java.lang.String defaultAnswer)
promptMsg
- is prompt messagedefault
- if press cancelabstract boolean copyFile(java.lang.String srcName, java.lang.String dstName, java.lang.String optUpdateMsg, int optEstInputFileLth)
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 nameoptUpdateMsg
- (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.abstract boolean deleteLocalFile(java.lang.String fileName)
fileName
- to be deleted on the local file system.abstract void showMsg(java.lang.String msg)
msg
- message to displayabstract void setWaitCursor(boolean flag)
flag
- to turn wait cursor on or offabstract java.lang.String readTextFromFile(java.lang.String fileName, java.lang.String loadingMsg)
fileName
- full path name of text fileloadingMsg
- to display while loading, null if no messageabstract boolean writeTextToFile(java.lang.String textFileName, java.lang.String textReport)
textFileName
- full path name of text filetextReport
- text to save in fileabstract boolean setRoutput2ClientObjects()
abstract boolean createInputDataFiles(java.lang.String inputFilesBasePath)
inputFilesBasePath
- where to put generated files
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |