forked from AG-Boerries/MIRACUM-Pipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateSet.sh
executable file
·203 lines (168 loc) · 5.2 KB
/
createSet.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
# script to create working directory and qsub job submissions for the WES samples
# Version 08.10.2018
########################
## Example run script ##
########################
# example
# ./createSet.sh somaticGermline ID 'folder/containing/germline' 'folder/containing/tumor' filename_germline_without_file_extension filename_tumor_without_file_extension XY
# examples for paired-end fastq files (AS-258824-LR-37679_R1.fastq.gz and AS-258824-LR-37679_R2.fastq.gz)
# filename_germline_without_file_extension: AS-258824-LR-37679_R
# somatic: do not do call germline varaints only use germline for identifying somatic variants
# somaticGermline: call somatic variants as well as germline variants
case=$1; # somatic or somaticGermline
num=$2; # Patient ID
xx1=$3; # folder/containing/germline
xx2=$4; # folder/containing/tumor
f1=$5; # filename_germline_without_file_extension ## Inputf1=$homedata/ngs/$xx1/fastq/$f1 -> R1,R2
f2=$6; # filename_tumor_without_file_extension ## Inputf2=$homedata/ngs/$xx2/fastq/$f2 -> R1,R2
sex=$7; # gender
##################################################################################################################
## Parameters which need to be adjusted to the local environment
mtb="/path/to/output/folder/${case}_${num}" # path to output folder, subfolder with type of analysis and ID is automatically created
wes="${mtb}/WES" # subfolder containing the alignemnt, coverage, copy number variation and variant calling results
ana="${mtb}/Analysis" # subfolder containing PDF Report, annotated copy number variations and annotated variants
##################################################################################################################
##########
## MAIN ##
##########
pathtothis="."
if [ ! -d ${mtb} ]; then
mkdir ${mtb}
cp ${pathtothis}/make_alignment_VC_CNV.sh ${mtb}
mkdir ${wes}
mkdir ${ana}
cp ${pathtothis}/RScripts/Main.R ${ana}
cp ${pathtothis}/RScripts/Report.Rnw ${ana}
fi
# cycle on tasks
for d in GD TD VC CNV Report
do
# create sh scripts
dname=${case}_${num}_${d}
runname=${mtb}/run_${dname}.sh
cat > ${runname} <<EOI
#!/bin/bash
#PBS -S /bin/bash
#PBS -k o
#PBS -l nodes=1:ppn=12,walltime=400:00:00
#PBS -m a
#PBS -N $dname
#PBS -e ${mtb}/err.${dname}.log
#PBS -o ${mtb}/out.${dname}.log
#PBS -d ${mtb}/
EOI
# create sh run scripts
case ${d} in
GD)
echo "bash ${mtb}/make_alignment_VC_CNV.sh ${case} ${d} ${num} ${xx1} ${f1} " >> ${runname}
;;
TD)
echo "bash ${mtb}/make_alignment_VC_CNV.sh ${case} ${d} ${num} ${xx2} ${f2} " >> $runname
;;
VC)
echo "bash ${mtb}/make_alignment_VC_CNV.sh ${case} ${d} ${num} " >> ${runname}
;;
CNV)
echo "bash ${mtb}/make_alignment_VC_CNV.sh ${case} ${d} ${num} ${sex}" >> ${runname}
;;
Report)
echo "bash ${mtb}/make_alignment_VC_CNV.sh ${case} ${d} ${num} ${f1} ${f2} ${mtb} " >> ${runname}
;;
esac
chmod a+x ${runname}
done
# cycle on d
# create jobs submissions script
cat > ${mtb}/run_jobs.sh <<EOI2
#!/bin/bash
maxhours=400
# -------------------------------------------
date
echo "Submitting GD TD"
for task in GD TD; do
dname=${case}_${num}_\${task}
cd $mtb
if [ -f .STARTING_MARKER_\${task} ]; then
exit "Previous job uncompleted. Aborting!"
else
echo "STARTING \$dname"; echo "\$dname" > .STARTING_MARKER_\${task}
qsub run_\${dname}.sh
fi
done
echo "Waiting for GD TD"
# wait no more than maxhours
count=1
while [ \${count} -lt \${maxhours} ]; do
if [ -e ${mtb}/.STARTING_MARKER_GD ] || [ -e ${mtb}/.STARTING_MARKER_TD ]; then
sleep 1h
date
(( count++ ))
else
break
fi
done
if [ \${count} -ge \${maxhours} ]; then
date
echo "Waited to long for job results for GD TD; exiting"
exit
fi
echo "Finished GD TD"
# -------------------------------------------
date
echo "Submitting VC CNV"
for task in VC CNV; do
dname=${case}_${num}_\${task}
cd ${mtb}
if [ -f .STARTING_MARKER_\${task} ]; then
exit "Previous job uncompleted. Aborting!"
else
echo "STARTING \$dname"; echo "\$dname" > .STARTING_MARKER_\${task}
qsub run_\${dname}.sh
fi
done
echo "Waiting for VC CNV"
count=1
while [ \${count} -lt \${maxhours} ]; do
if [ -e ${mtb}/.STARTING_MARKER_VC ] || [ -e ${mtb}/.STARTING_MARKER_CNV ]; then
sleep 1h
date
(( count++ ))
else
break
fi
done
echo "Finished VC CNV"
# -------------------------------------------
date
echo "Submitting Report"
for task in Report; do
dname=${case}_${num}_\${task}
cd $mtb
if [ -f .STARTING_MARKER_\${task} ]; then
exit "Previous job uncompleted. Aborting!"
else
echo "STARTING \${dname}"; echo "\${dname}" > .STARTING_MARKER_\${task}
qsub run_\${dname}.sh
fi
done
echo "Waiting for Report"
count=1
while [ \${count} -lt \${maxhours} ]; do
if [ -e ${mtb}/.STARTING_MARKER_Report ]; then
sleep 1h
date
(( count++ ))
else
break
fi
done
echo "Finished Report"
date
echo "Finished all jobs for $num "
# -------------------------------------------
exit
EOI2
chmod a+x ${mtb}/run_jobs.sh
exit
# --------------------------------------------------------------------------------------------------------