comparison r_wrapper.sh @ 1:dbcf9bc275e3 draft

planemo upload commit 063e049d569aeb45e1008cbf044f2dad850eca3d-dirty
author stevecassidy
date Wed, 07 Dec 2016 19:10:51 -0500
parents 6d6dc275b107
children
comparison
equal deleted inserted replaced
0:6d6dc275b107 1:dbcf9bc275e3
1 #!/bin/sh 1 #!/bin/sh
2 2
3 ### Run R providing the R script in $1 as standard input and passing 3 ### Run R providing the R script in $1 as standard input and passing
4 ### the remaining arguments on the command line 4 ### the remaining arguments on the command line
5 5
6 # Function that writes a message to stderr and exits 6 # Function that writes a message to stderr and exits
7 fail() 7 fail()
8 { 8 {
9 echo "$@" >&2 9 echo "$@" >&2
10 exit 1 10 exit 1
11 } 11 }
12 12
13 # Ensure R executable is found 13 # Ensure R executable is found
14 which R > /dev/null || fail "'R' is required by this tool but was not found on path" 14 which R > /dev/null || fail "'R' is required by this tool but was not found on path"
15
16 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
15 17
16 # Extract first argument 18 # Extract first argument
17 infile=$1; shift 19 infile=$1; shift
18 20
19 # Ensure the file exists 21 # Ensure the file exists
20 test -f $infile || fail "R input file '$infile' does not exist" 22 test -f $infile || fail "R input file '$infile' does not exist"
21 23
22 # Invoke R passing file named by first argument to stdin 24 # Invoke R passing file named by first argument to stdin
23 R --vanilla --slave $* < $infile 25 # add in the util.R file too containing common functions
26 cat $DIR/util.R $infile | R --vanilla --slave $*