forked from UW-GAC/analysis_pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunRscript.sh
More file actions
executable file
·41 lines (35 loc) · 765 Bytes
/
runRscript.sh
File metadata and controls
executable file
·41 lines (35 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /bin/bash
while getopts ":cs" opt; do
case $opt in
c)
TASK="--chromosome $SGE_TASK_ID"
;;
s)
TASK="--segment $SGE_TASK_ID"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift "$((OPTIND-1))"
if [ "$SGE_TASK_ID" == "undefined" ] || [ "$SGE_TASK_ID" == "" ]; then
TASK=""
fi
args=("$@") # all arguments
unset args[0] # remove first argument (R script name)
tb=`date`
echo ">>> Start job: $JOB_ID at $tb ... "
R -q --vanilla --args ${args[@]} $TASK < $1
export R_exit_code="$?"
if [ $R_exit_code -ne "0" ]
then
if [[ "$SGE_TASK_ID" -ne "" ]]; then
touch fail.${JOB_ID}.${SGE_TASK_ID}
else
touch fail.${JOB_ID}
fi
fi
te=`date`
echo ">>> End job: $JOB_ID at $te"
exit $R_exit_code