-
Notifications
You must be signed in to change notification settings - Fork 2
/
phyloSI-RakaiAgeGender-run_phyloflows-hpc.bash
executable file
·108 lines (84 loc) · 2.89 KB
/
phyloSI-RakaiAgeGender-run_phyloflows-hpc.bash
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# use as:
# phyloSI-RakaiAgeGende-run_phyloflows-hpc.bash JOBNAME="jobname"
# Flags:
# STAN_MODEL : stan model to be run
# JOBNAME : name of the job
# INDIR : directory where github directory is located
# OUTDIR : directory where output will be saved
# ENVNAME : name of the conda environment to be used
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
KEY_LENGTH=${#KEY}
VALUE="${ARGUMENT:$KEY_LENGTH+1}"
echo "export $KEY=$VALUE"
export "$KEY"="$VALUE"
done
# default options
STAN_MODEL="${STAN_MODEL:-gp_230602}"
JOBNAME="${JOBNAME:-central}"
INDIR="${INDIR:-/home/andrea/git/phyloflows}"
OUTDIR="${OUTDIR:-/home/andrea/git/phyloflows/output}"
ENVNAME="${ENVNAME:-phylowSI-RakaiAgeGender}"
echo "Selected options:"
echo "STAN_MODEL = $STAN_MODEL"
echo "JOBNAME = $JOBNAME"
echo "INDIR = $INDIR"
echo "OUTDIR = $OUTDIR"
echo "ENVNAME = $ENVNAME"
# if ENVNAME is not-empty, need to add a line to both scripts below
if [ ! -z "$ENVNAME" ]
then
ENVNAME="source activate $ENVNAME"
fi
#
mkdir $OUTDIR
cat > $OUTDIR/bash_$STAN_MODEL-$JOBNAME.pbs <<EOF
#!/bin/sh
#PBS -l walltime=72:00:00
#PBS -l select=1:ncpus=10:ompthreads=1:mem=240gb
#PBS -j oe
module load anaconda3/personal
$ENVNAME
JOB_TEMP=\${EPHEMERAL}/\${PBS_JOBID}
mkdir -p \$JOB_TEMP
cd \$JOB_TEMP
PWD=\$(pwd)
INDIR=$INDIR
OUTDIR=$OUTDIR
STAN_MODEL=$STAN_MODEL
JOBNAME=$JOBNAME
# main directory
CWD=\$PWD/\$STAN_MODEL-\$JOBNAME
mkdir \$CWD
mkdir \$CWD/figures
Rscript \$INDIR/src/transmission_flows/run_stan.R -indir \$INDIR -outdir \$CWD -stan_model \$STAN_MODEL -jobname \$JOBNAME
cp -R --no-preserve=mode,ownership \$PWD/* \$OUTDIR
cd \$OUTDIR
qsub bash_$STAN_MODEL-$JOBNAME-postprocessing.pbs
EOF
cat > $OUTDIR/bash_$STAN_MODEL-$JOBNAME-postprocessing.pbs <<EOF
#!/bin/sh
#PBS -l walltime=24:00:00
#PBS -l select=1:ncpus=10:ompthreads=1:mem=480gb
#PBS -j oe
module load anaconda3/personal
$ENVNAME
INDIR=$INDIR
OUTDIR=$OUTDIR
STAN_MODEL=$STAN_MODEL
JOBNAME=$JOBNAME
# main directory
CWD=\$OUTDIR/\$STAN_MODEL-\$JOBNAME
# directories for figure and table
mkdir \$CWD/figures
mkdir \$CWD/tables
Rscript \$INDIR/src/transmission_flows/postprocessing_assess_mixing.R -indir \$INDIR -outdir \$CWD -stan_model \$STAN_MODEL -jobname \$JOBNAME
Rscript \$INDIR/src/transmission_flows/postprocessing_figures.R -indir \$INDIR -outdir \$CWD -stan_model \$STAN_MODEL -jobname \$JOBNAME
Rscript \$INDIR/src/transmission_flows/postprocessing_figure_time_trends_sources.R -indir \$INDIR -outdir \$CWD -stan_model \$STAN_MODEL -jobname \$JOBNAME
Rscript \$INDIR/src/transmission_flows/postprocessing_figure_contribution_sexual_contact.R -indir \$INDIR -outdir \$CWD -stan_model \$STAN_MODEL -jobname \$JOBNAME
Rscript \$INDIR/src/transmission_flows/postprocessing_figure_counterfactual.R -indir \$INDIR -outdir \$CWD -stan_model \$STAN_MODEL -jobname \$JOBNAME
EOF
cd $OUTDIR
qsub bash_$STAN_MODEL-$JOBNAME.pbs