-
Notifications
You must be signed in to change notification settings - Fork 6
/
bamtofastq.sh
33 lines (32 loc) · 873 Bytes
/
bamtofastq.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
#!/bin/bash
#
# converts a BAM back to FASTQ
# This approach allows downsampling to use the same set of reads as BWA alignment
# so all callers get the same set of input reads
#
. common.sh
module add bedtools
for BAM in $DATA_DIR/*.sq.bam ; do
echo Processing $BAM
cx_load $BAM
if [[ "$CX_ALIGNER" != "$2" ]] ; then
echo -n #continue
fi
# unset context added by aligner in alignbam.sh
unset CX_FQ1
unset CX_FQ2
unset CX_ALIGNER
unset CX_ALIGNER_MODE
unset CX_ALIGNER_SOFTCLIP
unset CX_ALIGNER_VERSION
cx_save
XC_OUTPUT=$CX.1.fq.gz
XC_SCRIPT="
# FU=$CX.u.fq.tmp # shouldn't have any unpaired, and if so, we can't handle downstream
#SamToFastq VALIDATION_STRINGENCY=SILENT INPUT=$BAM F=$CX.1.fq.tmp F2=$CX.2.fq.tmp
bedtools bamtofastq -i $BAM -fq $CX.1.fq.tmp -fq2 $CX.2.fq.tmp &&
mv $CX.1.fq.tmp $CX.1.fq &&
mv $CX.2.fq.tmp $CX.2.fq
"
xc_exec
done