OpenMS  2.8.0
Static Public Member Functions | List of all members
RWrapper Class Reference

R-Wrapper Class. More...

#include <OpenMS/SYSTEM/RWrapper.h>

Static Public Member Functions

static String findScript (const String &script_file, bool verbose=true)
 Look for an R script in the share/OpenMS/SCRIPT folder. More...
static bool findR (const QString &executable=QString("Rscript"), bool verbose=true)
 Check for presence of 'Rscript'. More...
static bool runScript (const String &script_file, const QStringList &cmd_args, const QString &executable=QString("Rscript"), bool find_R=false, bool verbose=true)
 Run an R script with certain arguments on the command line. More...

Detailed Description

R-Wrapper Class.

Call R scripts from OpenMS, mainly to produce plots.

Member Function Documentation

◆ findR()

static bool findR ( const QString &  executable = QString("Rscript"),
bool  verbose = true 

Check for presence of 'Rscript'.

verbosePrint failure information?
Success status

◆ findScript()

static String findScript ( const String script_file,
bool  verbose = true 

Look for an R script in the share/OpenMS/SCRIPT folder.

The script filename can be an absolute filename (in which case the filename is returned unchanged), or a relative filename or just a filename. In the latter cases, the script will be searched in the OpenMS 'SCRIPTS' path (share/OpenMS/SCRIPTS) and the full filename will be returned.

An exception will be thrown if the file cannot be found.

script_fileName of the R script
verbosePrint error message to OPENMS_LOG_ERROR upon FileNotFound
Full filename with absolute path

◆ runScript()

static bool runScript ( const String script_file,
const QStringList &  cmd_args,
const QString &  executable = QString("Rscript"),
bool  find_R = false,
bool  verbose = true 

Run an R script with certain arguments on the command line.

The following checks are done before running the script: 1) [optional] 'Rscript' executable is searched (see findR() – set find_R to true) 2) The script_file is searched in 'OpenMS/share/SCRIPTS' (see findScript()). 3) The script is run as $ Rscript <path/to/script> <arg1> <arg2> ...

If any of the above steps fail, an error message is printed and false is returned.

The 'cmd_args' are passed via commandline and should be read by the R script using R' commandArgs() function. Usually, the args are input and output filenames.

script_fileFilename of the R script
cmd_argsCommand line arguments to the script
find_RRun findR()? May be skipped if runScript() is run repeatedly
verbosePrint status information; also passed internally to findR() and findScript().
Success status