PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/plotting/r_wrapper.sh

https://bitbucket.org/cistrome/cistrome-harvard/
Shell | 23 lines | 9 code | 6 blank | 8 comment | 2 complexity | 2356646c39c774d7d3717a7f68d9b6e3 MD5 | raw file
 1#!/bin/sh
 2
 3### Run R providing the R script in $1 as standard input and passing 
 4### the remaining arguments on the command line
 5
 6# Function that writes a message to stderr and exits
 7function fail
 8{
 9    echo "$@" >&2
10    exit 1
11}
12
13# Ensure R executable is found
14which R > /dev/null || fail "'R' is required by this tool but was not found on path" 
15
16# Extract first argument
17infile=$1; shift
18
19# Ensure the file exists
20test -f $infile || fail "R input file '$infile' does not exist"
21
22# Invoke R passing file named by first argument to stdin
23R --vanilla --slave $* < $infile