-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.germline.sh
executable file
·81 lines (58 loc) · 2.56 KB
/
2.germline.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
#!/bin/bash
# Perform germline calling by sample/contig
# Configuration
source config.ini
# ******************
# Command line
BATCH="$1"
CMD="$2"
# ******************
BAMLIST=bamlist.${BATCH}
if [[ "$CMD" == "setup" ]] ; then
# Create job
LSF_OUTDIR=${MYSTORAGE}/LSF_logs/${STUDY}/germline_setup
mkdir -p ${LSF_OUTDIR}
LSF_STDOUT=${LSF_OUTDIR}/batch_${BATCH}.stdout
LSF_STDERR=${LSF_OUTDIR}/batch_${BATCH}.stderr
bsub -n 1 -J gl_setup.${BATCH} -g /${USER}/${LABNAME} -q ${QNAME} -R 'rusage[mem=16GB] span[hosts=1]' -a "docker(${IMAGE})" -o ${LSF_STDOUT} -e ${LSF_STDERR} "./gl_setup.sh ${BATCH}"
elif [[ "$CMD" == "run" ]] ; then
# Generate each command and submit
for samp in $(grep -v ^# ${BAMLIST} | cut -d, -f1 ) ; do
echo ""
echo "======== ${samp} ======="
DESTDIR=${SAMP_SCRATCHDIR}/samples.${BATCH}/${samp}
for c in $(seq 1 22) ; do
myscript=${DESTDIR}/Script/runGermline_chr${c}.sh
mylog=${DESTDIR}/mylogs/runGermline_chr${c}.log
mkdir -p ${DESTDIR}/mylogs
LSF_OUTDIR=${MYSTORAGE}/LSF_logs/${STUDY}/germline_run/samples.${BATCH}
mkdir -p ${LSF_OUTDIR}
LSF_STDOUT=${LSF_OUTDIR}/${samp}.chr${c}.stdout
LSF_STDERR=${LSF_OUTDIR}/${samp}.chr${c}.stderr
bsub -n 1 -J gl_run.${BATCH}.${samp}.chr${c} -g /${USER}/${LABNAME} -q ${QNAME} -R 'rusage[mem=32GB] span[hosts=1]' -a "docker(${IMAGE})" -o ${LSF_STDOUT} -e ${LSF_STDERR} "./gl_run.sh ${myscript} ${mylog}"
done
done
elif [[ "$CMD" == "merge" ]] ; then
for samp in $(grep -v ^# ${BAMLIST} | cut -d, -f1 ) ; do
LSF_OUTDIR=${MYSTORAGE}/LSF_logs/${STUDY}/germline_merge/merge.${BATCH}
mkdir -p ${LSF_OUTDIR}
LSF_STDOUT=${LSF_OUTDIR}/${samp}.stdout
LSF_STDERR=${LSF_OUTDIR}/${samp}.stderr
VCFDIR=${SAMP_SCRATCHDIR}/samples.${BATCH}/${samp}/germline
bsub -n 1 -J gl_merge.${BATCH}.${samp} -g /${USER}/${LABNAME} -q ${QNAME} -R 'rusage[mem=32GB] span[hosts=1]' -a "docker(${IMAGE})" -o ${LSF_STDOUT} -e ${LSF_STDERR} "./gl_merge_phased.sh ${VCFDIR} ${samp}"
done
elif [[ "$CMD" == "move" ]] ; then
mkdir -p ${SAMP_STORAGEDIR}/samples.${BATCH}
for samp in $(grep -v ^# ${BAMLIST} | cut -d, -f1 ) ; do
echo ${samp}
# Copy all
rsync -rlHtpgP ${SAMP_SCRATCHDIR}/samples.${BATCH}/${samp} ${SAMP_STORAGEDIR}/samples.${BATCH}
done
elif [[ "$CMD" == "tidy" ]] ; then
for samp in $(grep -v ^# ${BAMLIST} | cut -d, -f1 ) ; do
echo Removing ${SAMP_SCRATCHDIR}/samples.${BATCH}/${samp}/
rm -rf ${SAMP_SCRATCHDIR}/samples.${BATCH}/${samp}/
done
else
echo Command ${CMD} is unrecognized. Exiting...
fi