PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 0ms 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. ### Run R providing the R script in $1 as standard input and passing
  3. ### the remaining arguments on the command line
  4. # Function that writes a message to stderr and exits
  5. function fail
  6. {
  7. echo "$@" >&2
  8. exit 1
  9. }
  10. # Ensure R executable is found
  11. which R > /dev/null || fail "'R' is required by this tool but was not found on path"
  12. # Extract first argument
  13. infile=$1; shift
  14. # Ensure the file exists
  15. test -f $infile || fail "R input file '$infile' does not exist"
  16. # Invoke R passing file named by first argument to stdin
  17. R --vanilla --slave $* < $infile