-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathRshell
executable file
·75 lines (67 loc) · 1.3 KB
/
Rshell
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -o pipefail
RCMD="Rscript"
NAME="R"
TMPDIR="$HOME/share/tmp"
QUEUE="jrf.q"
LOGDIR=.
MEM="1G"
PARALLEL=1
QSUB="perl scripts/qsub.pl"
while getopts "e:sm:n:l:p:" opt; do
case $opt in
l)
LOGDIR=$OPTARG
;;
e)
R=$OPTARG
;;
m)
MEM=$OPTARG
;;
p)
PARALLEL=$OPTARG
;;
n)
NAME=$OPTARG
;;
s)
SGE=true
;;
\:)
echo "Argument missing: -$OPTARG" >&2
exit -1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit -1
;;
esac
done
echo "#---------------------------------";
if [[ $PARALLEL -gt 1 ]]; then
PE="-pe smp $PARALLEL"
fi
umask 002
mkdir -p $LOGDIR
if [[ -n "$R" ]]; then
TMP=$(mktemp --tmpdir=${TMPDIR})
#TMP=$(mktemp -t x)
trap "{ rm -f ${TMP}; exit 255; }" SIGINT
echo "Sys.umask('002')" > ${TMP}
echo "${R}" >> ${TMP}
echo "${R}" > $LOGDIR/$NAME.R
if [[ -n "$SGE" ]]; then
mkdir -p $LOGDIR
echo "umask 002; ${RCMD} ${TMP}" | $QSUB -- -cwd -V -now n -q $QUEUE -N X$NAME $PE -l virtual_free=$MEM,h_vmem=$MEM -o $LOGDIR/$NAME.log -j y -b n
RET_CODE=$?
else
$RCMD ${TMP} | tee -a $LOGDIR/$NAME.log
RET_CODE=$?
fi
rm -f ${TMP}
exit ${RET_CODE}
else
echo "Undefined script" >&2
exit -1
fi