-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_blocks.sh
executable file
·66 lines (55 loc) · 2.17 KB
/
check_blocks.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
#!/bin/bash
source /projects/uoo00032/Resources/bin/NeSI_2FastqToCall/baserefs.sh
SAMPLE=${1}
READGROUP=${2}
READNUM=${3}
BLOCK=${4}
NEXT=${5}
ALIGNARR=${6}
MERGEARR=${7}
ZPADBLOCK=$(printf "%0${FASTQ_MAXZPAD}d" $BLOCK)
#ZPADNEXT=$(printf "%0${FASTQ_MAXZPAD}d" $NEXT)
curRead1File=blocks/${READGROUP}_R1_${ZPADBLOCK}.fastq.gz
curRead2File=blocks/${READGROUP}_R2_${ZPADBLOCK}.fastq.gz
IDN=$(echo ${SAMPLE} | awk -F'[[:blank:]_]' '{print $1}')
DNA=$(echo ${SAMPLE} | awk -F'[[:blank:]_]' '{print $2}')
LIB=$(echo ${SAMPLE} | awk -F'[[:blank:]_]' '{print $3}')
RUN=$(echo ${SAMPLE} | awk -F'[[:blank:]_]' '{print $4}')
PLATFORM=Genomic
function spoolAlign {
alignBlockOutput=split/contig_split_${ZPADBLOCK}.done
mkdir -p $(dirname ${alignBlockOutput})
printf "%-16s" "Alignment"
if [ ! -e ${alignBlockOutput} ]; then
scontrol update JobId=${ALIGNARR}_${BLOCK} StartTime=now Dependency=
if [ $? -ne 0 ]; then
printf "FAILED!\n"
exit 1
else
printf "%s\n" ${ALIGNARR}_${BLOCK}
fi
else
printf "done\n"
fi
if [ "$BLOCK" == "$NEXT" ]; then # This is the final chunk so we can spool up the next step
echo "CB: $BLOCK of $NEXT block$([ $NEXT -gt 1 ] && echo -ne "s") completed!"
purgeList="$((${NEXT}+1))-$FASTQ_MAXJOBZ"
# Purge extra align and sort array elements.
scancel ${ALIGNARR}_[${purgeList}] && echo "CB: Purged ${ALIGNARR}_[${purgeList}]!"
fi
}
if [ "$READNUM" == "R1" ]; then # BLOCK Read1 has completed!
if [ -e ${curRead2File}.done ]; then # NEXT Read2 exists so BLOCK Read2 has completed!
echo "CB: Both R1 and R2 ${BLOCK} completed!" #| tee -a check_${BLOCK}.txt
spoolAlign
# else # NEXT Read2 doesn't exist yet so BLOCK Read2 hasn't completed!
# echo "CB: R1 ${BLOCK} completed but R2 not done yet!" #| tee -a check_${BLOCK}.txt
fi
elif [ "$READNUM" == "R2" ]; then # BLOCK Read2 has completed!
if [ -e ${curRead1File}.done ]; then # NEXT Read1 exists so BLOCK Read1 has completed!
echo "CB: Both R1 and R2 ${BLOCK} completed!" #| tee -a check_${BLOCK}.txt
spoolAlign
# else # NEXT Read1 doesn't exist yet so BLOCK Read1 hasn't completed!
# echo "CB: R2 ${BLOCK} complete but R1 not done yet!" #| tee -a check_${BLOCK}.txt
fi
fi