-
Notifications
You must be signed in to change notification settings - Fork 0
/
bam_improvement.sh
98 lines (76 loc) · 1.84 KB
/
bam_improvement.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
#$ -cwd
#$ -S /bin/bash
#$ -N bamimp
#$ -o bamimp_out
#$ -e bamimp_err
# #$ -l mem_free=2G
#$ -V
#$ -q !gbs
#$ -t 1-5:1
# Note that the Broad no longer recommends indel realignment.
# As such, this script may be considered deprecated.
#
# https://software.broadinstitute.org/gatk/gatkdocs/org_broadinstitute_gatk_tools_walkers_indels_RealignerTargetCreator.php
echo "SGE_TASK_ID: "
echo $SGE_TASK_ID
echo
i=$(expr $SGE_TASK_ID - 1)
PATH=~/bin/gatk/:$PATH
PATH=~/bin/samtools-1.1:$PATH
GATK="/home/bpp/knausb/bin/gatk/GenomeAnalysisTK.jar"
SAMT="~/bin/samtools-1.1/samtools"
export _JAVA_OPTIONS="-XX:ParallelGCThreads=1"
BAM=( `cat "./bams.txt" `)
IFS=';' read -a arr <<< "${BAM[$i]}"
REF="/home/bpp/knausb/Grunwald_Lab/home/knausb/bjk_pinf_ref/pinf_super_contigs.fa"
echo -n "Running on: "
hostname
echo "SGE job id: $JOB_ID"
echo "SGE_TASK_ID: $SGE_TASK_ID"
date
echo
echo "Path:"
echo $PATH
echo
echo "Sample name 0: "
echo ${arr[0]}
echo "Input bam file 1: "
echo ${arr[1]}
echo
echo
# https://www.broadinstitute.org/gatk/guide/article?id=38
CMD="/home/bpp/knausb/bin/javadir/jre1.7.0_71/bin/java -Xmx1g \
-jar $GATK \
-T RealignerTargetCreator \
# --fix_misencoded_quality_scores \ # For non-Sanger encoded qualities.
-R $REF \
-I ${arr[1]} \
-o bams/${arr[0]}.intervals \
-known ./pitg_indels.vcf"
echo $CMD
date
eval $CMD
date
echo
CMD="/home/bpp/knausb/bin/javadir/jre1.7.0_71/bin/java -Xmx4g \
-Djava.io.tmpdir=/data \
-jar $GATK \
-T IndelRealigner \
-R $REF \
-I ${arr[1]} \
-targetIntervals bams/${arr[0]}.intervals \
-o bams/${arr[0]}_realigned.bam \
--consensusDeterminationModel USE_READS -LOD 0.4"
echo $CMD
date
eval $CMD
date
echo
CMD="$SAMT calmd -Erb bams/${arr[0]}_realigned.bam $REF > bams/${arr[0]}_calmd.bam"
echo $CMD
date
eval $CMD
date
echo
# EOF