-
Notifications
You must be signed in to change notification settings - Fork 2
/
05_indel_realign.sh
executable file
·61 lines (51 loc) · 1.17 KB
/
05_indel_realign.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
#!/bin/sh
source ./fold.settings
# NOTE: -Xmx parameter is per thread
java="java -Xmx2g"
gdir=$EBROOTGATK
gatk="$java -jar $gdir/GenomeAnalysisTK.jar"
indel_realign() {
pfx=$1
pfx_out=${pfx}.realigned.calmd
bam_in=${pfx}.bam
if [ ! -f "$bam_in" ]; then
die "${pfx}: cannot file ${bam_in}"
fi
# train realigner
$gatk \
-T RealignerTargetCreator \
-nt $realigner_threads_per_sample \
-R $ref \
-I $bam_in \
-o ${pfx}.intervals \
|| die "${pfx}: RealignerTargetCreator"
# do indel realignment
$gatk \
-T IndelRealigner \
-R $ref \
--bam_compression 0 \
--disable_bam_indexing \
-targetIntervals ${pfx}.intervals \
-I $bam_in \
-o ${pfx}.realigned.bam \
|| die "${pfx}: IndelRealigner"
# regenerate MD tag to match the indel realignment
samtools calmd \
-b \
${pfx}.realigned.bam \
$ref \
> ${pfx}.realigned.calmd.bam \
|| die "${pfx}: samtools calmd"
samtools index \
${pfx}.realigned.calmd.bam \
|| die "${pfx}: samtools index"
rm ${pfx}.intervals ${pfx}.realigned.bam
}
for sample in $samples; do
for ref in $refs; do
refname=$(basename $ref)
refname=${refname%.fasta}
indel_realign ${sample}.${refname}.dedup #&
done
done
#wait