annotate kmersvm/r_wrapper.sh @ 0:7fe1103032f7 draft

Uploaded
author cafletezbrant
date Mon, 20 Aug 2012 18:07:22 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
1 #!/bin/sh
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
2
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
3 ### Run R providing the R script in $1 as standard input and passing
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
4 ### the remaining arguments on the command line
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
5
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
6 # Function that writes a message to stderr and exits
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
7 fail()
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
8 {
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
9 echo "$@" >&2
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
10 exit 1
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
11 }
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
12
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
13 # Ensure R executable is found
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
14 which R > /dev/null || fail "'R' is required by this tool but was not found on path"
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
15
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
16 # Extract first argument
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
17 infile=$1; shift
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
18
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
19 # Ensure the file exists
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
20 test -f $infile || fail "R input file '$infile' does not exist"
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
21
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
22 # Invoke R passing file named by first argument to stdin
7fe1103032f7 Uploaded
cafletezbrant
parents:
diff changeset
23 R --vanilla --slave $* < $infile