-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstep10-region_cuts.sh
executable file
·94 lines (71 loc) · 1.64 KB
/
step10-region_cuts.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
92
93
94
#!/bin/sh
## Usage
# sh step10-region_cuts.sh brainspan
# Define variables
EXPERIMENT=$1
SHORT="regCuts-${EXPERIMENT}"
# Directories
ROOTDIR=/dcl01/lieber/ajaffe/derRuns/derSupplement
MAINDIR=${ROOTDIR}/${EXPERIMENT}
WDIR=${MAINDIR}/regionMatrix
if [[ "${EXPERIMENT}" == "brainspan" ]]
then
echo ""
else
echo "Specify a valid experiment: brainspan"
fi
# Construct shell files
for chrnum in 22 21 Y 20 19 18 17 16 15 14 13 12 11 10 9 8 X 7 6 5 4 3 2 1
do
chr="chr${chrnum}"
sname="${SHORT}-${chr}"
echo "Creating script ${sname}"
cat > ${ROOTDIR}/.${sname}.sh <<EOF
#!/bin/bash
#$ -cwd
#$ -m e
#$ -l mem_free=70G,h_vmem=90G,h_fsize=30G
#$ -N ${sname}
#$ -hold_jid fullCov-${EXPERIMENT}
echo "**** Job starts ****"
date
# Make logs directory
mkdir -p ${WDIR}/logs
# Load coverage & get regions
cd ${WDIR}
module load R/3.3
Rscript ${ROOTDIR}/step10-region_cuts.R -m "${MAINDIR}" -c "${chr}"
## Move log files into the logs directory
mv ${ROOTDIR}/${sname}.* ${WDIR}/logs/
echo "**** Job ends ****"
date
EOF
call="qsub .${sname}.sh"
echo $call
$call
done
sname="${SHORT}-merge"
echo "Creating script for merging the region_cuts results"
cat > ${ROOTDIR}/.${sname}.sh <<EOF
#!/bin/bash
#$ -cwd
#$ -m e
#$ -l mem_free=100G,h_vmem=120G,h_fsize=40G
#$ -N ${sname}
#$ -hold_jid ${SHORT}-chr*
echo "**** Job starts ****"
date
# Make logs directory
mkdir -p ${WDIR}/logs
# Combine regions
cd ${WDIR}
module load R/3.3
Rscript ${ROOTDIR}/step10b-region_cuts-merge.R
## Move log files into the logs directory
mv ${ROOTDIR}/${sname}.* ${WDIR}/logs/
echo "**** Job ends ****"
date
EOF
call="qsub .${sname}.sh"
echo $call
$call