-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgatk_depthofcoverage.scr
executable file
·89 lines (76 loc) · 2.01 KB
/
gatk_depthofcoverage.scr
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
#!/bin/sh
#$ -cwd
# -l mem=6G,time=8::
# This step in the pipeline computes the depth of coverage.
GLOBAL="global_config.sh"
if [[ -e $GLOBAL ]]
then
. $GLOBAL
else
echo "Global config file not found. Exiting."
exit 1
fi
USAGE="Usage: $0 -I <Input bam file> -R <Reference fasta> [-L \"#:#-#\"] [-E <ExonFile>]"
while getopts I:L:E:R:h o
do case "$o" in
I) INP="$OPTARG";;
L) List="$OPTARG";;
R) REF="$OPTARG";;
E) ExonFile="$OPTARG";;
h) echo $USAGE
exit 1;;
esac
done
if [[ $INP == "" || $REF == "" ]]
then
echo $USAGE
exit 1
fi
# Specify either the chromosome range or the exon region list. If neither or both are specified,
# we do not know what to do.
if [[ $List == "" && $ExonFile == "" || $List != "" && $ExonFile != "" ]]
then
echo $EXONUSAGE
exit 1
fi
# Obtain the chromosome naming convention.
CHR_NAME=`$SAMTOOLS idxstats $INP | grep chr`
# If exon region list is specified, modify the file format to the following form: "<chr#>:low-high"
# If chromosome range is specified, just check for the naming convention.
if [[ $ExonFile != "" ]]
then
if [[ -n $CHR_NAME ]]
then
cat $ExonFile | awk '{split($1,a,"chr"); print "chr" a[2] ":" $2 "-" $3}' > "${ExonFile}.list"
echo non-zero ${ExonFile}.list
else
cat $ExonFile | awk '{split($1,a,"chr"); print a[2] ":" $2 "-" $3}' > "${ExonFile}.list"
echo zero ${ExonFile}.list
fi
CHR="${ExonFile}.list"
else
if [[ `grep chr $CHR` == "" && -n $CHR_NAME ]]
then
CHR="chr${List}"
else
CHR="${List}"
fi
echo CHR is $CHR
fi
$GATK \
-T DepthOfCoverage \
-L $CHR \
-R $REF \
-I $INP \
-o $INP.coverage
if [[ $? != 0 || `grep "$ERRORMESSAGE" "$DATAPATH"/depthofcoverage.output "$DATAPATH"/pipeline.output` != "" ]]
then
echo "Depth of coverage FAILED"
exit 1
fi
chmod g=rw $DATAPATH/*
# Could possibly include these
#-omitBaseOutput \
#-omitLocusTable \
#-omitIntervals \
#-omitSampleSummary \