-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnextseq_bcl2fq.sh
executable file
·82 lines (62 loc) · 1.86 KB
/
nextseq_bcl2fq.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
#$ -S /bin/bash
#$ -j y
## covert nextseqR bcl2fq and merge fq
if [ $# -lt 1 ]
then
echo "Usage: `basename $0` <runDir> [outDir]"
exit 65
fi
cwd=`pwd`
runDir=$1
run=`basename ${runDir}`
flowcell=${run##*_}
runDate1=${run%%_*}
runDate="20${runDate1:0:2}-${runDate1:2:2}-${runDate1:4:2}"
## outDir
if [ $# -gt 1 ]
then
outDir=$2
else
outDir="/home/analysis/Solexa/fastq"
fi
if [ ! -d $outDir ]; then
mkdir $outDir
fi
tmpDir=${runDir}/Data/Intensities/BaseCalls/fastq
if [ ! -d $tmpDir ]; then
mkdir $tmpDir
fi
cd $tmpDir
## move SampleSheet.csv
if [ -f ${runDir}/SampleSheet.csv ]; then
mv ${runDir}/SampleSheet.csv ${runDir}/SampleSheet_backup.csv
fi
## determine read number
nReads=`grep "<Read Number=" ${runDir}/RunInfo.xml | wc -l`
if [ $nReads -eq 2 ];then
maskStr='y*,y*'
elif [ $nReads -eq 3 ];then
maskStr='y*,y*,y*'
elif [ $nReads -eq 4 ];then
maskStr='y*,y*,y*,y*'
fi
bcl2fastq -R ${runDir} -o $tmpDir -l WARNING -p 32 --create-fastq-for-index-reads --no-lane-splitting --use-bases-mask $maskStr --mask-short-adapter-reads 6
if [ -f Undetermined_S0_R1_001.fastq.gz ];then
mv Undetermined_S0_R1_001.fastq.gz ${outDir}/X_1_${flowcell}.NEXTSEQ-${runDate}.fq.gz
else
mail -s "No fastq files generated from bcl2fastq: $run" [email protected] <<< ""
exit 65
fi
if [ -f Undetermined_S0_R2_001.fastq.gz ];then
mv Undetermined_S0_R2_001.fastq.gz ${outDir}/X_2_${flowcell}.NEXTSEQ-${runDate}.fq.gz
fi
if [ -f Undetermined_S0_R3_001.fastq.gz ];then
mv Undetermined_S0_R3_001.fastq.gz ${outDir}/X_3_${flowcell}.NEXTSEQ-${runDate}.fq.gz
fi
if [ -f Undetermined_S0_R4_001.fastq.gz ];then
mv Undetermined_S0_R4_001.fastq.gz ${outDir}/X_4_${flowcell}.NEXTSEQ-${runDate}.fq.gz
fi
## remove the fastq folder
#rm -rf $tmpDir
mail -s "bcl2f done: $run" [email protected],[email protected] <<< ""
#mail -s "bcl2f done: $run" [email protected] <<< ""