Class RSConnection
java.lang.Object
fr.ens.biologie.genomique.eoulsan.util.r.RSConnection
This class define an enhanced connection to RServe.
- Since:
- 1.2
- Author:
- Laurent Jourdren, Marion Gaussen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDestroy the connection to the Rserve server.voidExecute a R code.voidexecuteRCode(String source) Execute a R code.voidexecuteRnwCode(String source) Execute a R Sweave code.voidexecuteRnwCode(String source, String latexOutput) Execute a R Sweave code.voidgetAllFiles(Path outPath) Get all the file on the Rserve server.voidGet a file from the RServer.byte[]getFileAsArray(String filename) Get a file as a byte array.getFileInputStream(String filename) Create an inputStream on a file on RServer.getFileOutputStream(String filename) Create an outputStream on a file on RServer.voidgetFilesIntoZip(List<String> rServeFilenames, Path zipFile) Get a list of files from the RServer.org.rosuda.REngine.Rserve.RConnectionGet the R connection.Get the name of the Rserve server.List files on Rserve server.Load an image.org.rosuda.REngine.Rserve.RFileInputStreamOpen a file to read on Rserve server.voidputFile(InputStream is, String rServeFilename) Put a file from the RServer.voidPut a file from the RServer.voidRemove all the files of the working directory.voidremoveFile(String filename) Remove a file on the RServer.voidsetCommandArgs(List<String> arguments) Override the commandArg() R function.voidwriteStringAsFile(String outputFilename, String value) Write a file to the RServer.
-
Constructor Details
-
RSConnection
public RSConnection()Default constructor. Connect to the localhost. -
RSConnection
Public constructor.- Parameters:
serverName- RServe server to use
-
-
Method Details
-
getRConnection
public org.rosuda.REngine.Rserve.RConnection getRConnection() throws org.rosuda.REngine.REngineExceptionGet the R connection.- Returns:
- Returns the RConnection
- Throws:
org.rosuda.REngine.REngineException- if an error occurs while connecting to the server
-
getServerName
Get the name of the Rserve server.- Returns:
- the name of the Rserve server
-
writeStringAsFile
public void writeStringAsFile(String outputFilename, String value) throws org.rosuda.REngine.REngineException Write a file to the RServer.- Parameters:
outputFilename- the filenamevalue- The content of the file- Throws:
org.rosuda.REngine.REngineException- if an error occurs while writing the file
-
getFileInputStream
Create an inputStream on a file on RServer.- Parameters:
filename- Name of the file on RServer to load- Returns:
- an inputStream
- Throws:
org.rosuda.REngine.REngineException- if an exception occurs while reading file
-
getFileOutputStream
Create an outputStream on a file on RServer.- Parameters:
filename- Name of the file on RServer to write- Returns:
- an outputStream
- Throws:
org.rosuda.REngine.REngineException- if an exception occurs while reading file
-
putFile
public void putFile(Path inputFile, String rServeFilename) throws org.rosuda.REngine.REngineException Put a file from the RServer.- Parameters:
inputFile- input file of the file to putrServeFilename- filename of the file to put- Throws:
org.rosuda.REngine.REngineException- if an error occurs while downloading the file
-
putFile
public void putFile(InputStream is, String rServeFilename) throws org.rosuda.REngine.REngineException Put a file from the RServer.- Parameters:
is- input stream of the file to putrServeFilename- filename of the file to put- Throws:
org.rosuda.REngine.REngineException- if an error occurs while downloading the file
-
getFile
public void getFile(String rServeFilename, Path outputFile) throws org.rosuda.REngine.REngineException Get a file from the RServer.- Parameters:
rServeFilename- filename of the file to retrieveoutputFile- output file of the file to retrieve- Throws:
org.rosuda.REngine.REngineException- if an error occurs while downloading the file
-
getFilesIntoZip
public void getFilesIntoZip(List<String> rServeFilenames, Path zipFile) throws org.rosuda.REngine.REngineException Get a list of files from the RServer.- Parameters:
rServeFilenames- list of filenames of the files to retrievezipFile- zip output file for the files to retrieve- Throws:
org.rosuda.REngine.REngineException- if an error occurs while downloading the file
-
removeFile
Remove a file on the RServer.- Parameters:
filename- File to remove- Throws:
org.rosuda.REngine.REngineException- if connection cannot be established
-
removeAllFiles
public void removeAllFiles() throws org.rosuda.REngine.REngineException, org.rosuda.REngine.REXPMismatchExceptionRemove all the files of the working directory.- Throws:
org.rosuda.REngine.REngineException- if an error occurs while removing the fileorg.rosuda.REngine.REXPMismatchException- if an error occurs while removing the file
-
setCommandArgs
Override the commandArg() R function.- Parameters:
arguments- the arguments- Throws:
org.rosuda.REngine.REngineException- if an error occurs while executing R code
-
executeRCode
Execute a R code.- Parameters:
source- code to execute- Throws:
org.rosuda.REngine.REngineException- if an error while executing the code
-
executeR
Execute a R code.- Parameters:
code- code to execute- Throws:
org.rosuda.REngine.REngineException- if an error while executing the code
-
executeRnwCode
Execute a R Sweave code.- Parameters:
source- code to execute- Throws:
org.rosuda.REngine.REngineException- if an error while executing the code
-
executeRnwCode
public void executeRnwCode(String source, String latexOutput) throws org.rosuda.REngine.REngineException Execute a R Sweave code.- Parameters:
source- code to executelatexOutput- output latex filename- Throws:
org.rosuda.REngine.REngineException- if an error while executing the code
-
loadImage
Load an image.- Parameters:
filename- filename of the image on the server- Returns:
- an Image object
- Throws:
org.rosuda.REngine.REngineException- if an error while loading the image
-
getFileAsArray
Get a file as a byte array.- Parameters:
filename- filename of the file on the server- Returns:
- a byte array
- Throws:
org.rosuda.REngine.REngineException- if an error while loading the file
-
openFile
public org.rosuda.REngine.Rserve.RFileInputStream openFile(String filename) throws org.rosuda.REngine.REngineException Open a file to read on Rserve server.- Parameters:
filename- the filename- Returns:
- an input stream
- Throws:
org.rosuda.REngine.REngineException- if an error occurs while creating the input stream
-
getAllFiles
public void getAllFiles(Path outPath) throws org.rosuda.REngine.REngineException, org.rosuda.REngine.REXPMismatchException Get all the file on the Rserve server.- Parameters:
outPath- the output path- Throws:
org.rosuda.REngine.REngineException- if an error occurs while retrieving the filesorg.rosuda.REngine.REXPMismatchException- if an error occurs while retrieving the files
-
listFiles
public List<String> listFiles() throws org.rosuda.REngine.REngineException, org.rosuda.REngine.REXPMismatchExceptionList files on Rserve server.- Returns:
- files a String list of files names
- Throws:
org.rosuda.REngine.REngineException- if an error occurs with the serverorg.rosuda.REngine.REXPMismatchException- if an error occurs with the server
-
disConnect
public void disConnect()Destroy the connection to the Rserve server.
-