-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy_cluster_tut_qsub.sh
91 lines (75 loc) · 2.96 KB
/
py_cluster_tut_qsub.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
# This is a BIAC template script for jobs on the cluster
# You have to provide the Experiment on command line
# when you submit the job the cluster.
#
# > qsub -v EXPERIMENT=Dummy.01 script.sh args
#
# There are 2 USER sections
# 1. USER DIRECTIVE: If you want mail notifications when
# your job is completed or fails you need to set the
# correct email address.
#
# 2. USER SCRIPT: Add the user script in this section.
# Within this section you can access your experiment
# folder using $EXPERIMENT. All paths are relative to this variable
# eg: $EXPERIMENT/Data $EXPERIMENT/Analysis
# By default all terminal output is routed to the " Analysis "
# folder under the Experiment directory i.e. $EXPERIMENT/Analysis
# To change this path, set the OUTDIR variable in this section
# to another location under your experiment folder
# eg: OUTDIR=$EXPERIMENT/Analysis/GridOut
# By default on successful completion the job will return 0
# If you need to set another return code, set the RETURNCODE
# variable in this section. To avoid conflict with system return
# codes, set a RETURNCODE higher than 100.
# eg: RETURNCODE=110
# Arguments to the USER SCRIPT are accessible in the usual fashion
# eg: $1 $2 $3
# The remaining sections are setup related and don't require
# modifications for most scripts. They are critical for access
# to your data
# --- BEGIN GLOBAL DIRECTIVE --
#$ -S /bin/sh
#$ -o $HOME/$JOB_NAME.$JOB_ID.out
#$ -e $HOME/$JOB_NAME.$JOB_ID.out
# -- END GLOBAL DIRECTIVE --
# -- BEGIN PRE-USER --
#Name of experiment whose data you want to access
#EXPERIMENT=${EXPERIMENT:?"Experiment not provided"}
EXPERIMENT= #Put name of experiment
source /etc/biac_sge.sh
EXPERIMENT=`findexp $EXPERIMENT`
EXPERIMENT=${EXPERIMENT:?"Returned NULL Experiment"}
if [ $EXPERIMENT = "ERROR" ]
then
exit 32
else
#Timestamp
echo "----JOB [$JOB_NAME.$JOB_ID] START [`date`] on HOST [$HOSTNAME]----"
# -- END PRE-USER --
# **********************************************************
# -- BEGIN USER SCRIPT --
# User script goes here-
SUBJ=$1
EXPDIR=${EXPERIMENT}/Path/to/Study/Script/Folder
BASEDIR=${EXPERIMENT}/Path/to/Study/Folder/For/Each/${SUBJ}
# change directory into basedir
cd ${BASEDIR}
OUTDIR=${BASEDIR}
# call python, call EXPDIR which contains the python function you want, & then call the python script.
# --subj is a flag followed by the specific subject you want to be run in the python script.
python2.7 ${EXPDIR}/noddi_as_sept262017.py --subj ${SUBJ}
# make sure you have an output directory for log files so you can debug.
OUTDIR=${EXPDIR}/Logs
mkdir -p $OUTDIR
# -- END USER SCRIPT -- #
# **********************************************************
# -- BEGIN POST-USER --
echo "----JOB [$JOB_NAME.$JOB_ID] STOP [`date`]----"
#OUTDIR=${OUTDIR:-$EXPERIMENT/Analysis}
mv $HOME/$JOB_NAME.$JOB_ID.out $OUTDIR/$JOB_NAME.$JOB_ID.out
RETURNCODE=${RETURNCODE:-0}
exit $RETURNCODE
fi
# -- END POST USER--