-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExmAdHoc.2.GetQualityMetricsSBam.sh
56 lines (45 loc) · 1.72 KB
/
ExmAdHoc.2.GetQualityMetricsSBam.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
#!/bin/bash
#$ -l mem=8G,time=4:: -N GetMetricsSB -cwd
#Provide a settings file containing the following variables:
# REF - Reference sequence fasta file
# PICARD - path to picard
# JAVA7BIN - path to java
while getopts i:s:l: opt; do
case "$opt" in
i) SamFil="$OPTARG";; #sam or bam file to be reordered
s) Settings="$OPTARG";; # settings file
l) LogFil="$OPTARG";; #log file to output to - optional
esac
done
#Load settings file
. $Settings
#Set local variables
TmpDir=temp.$SamFil.QCtempdir
mkdir -p $TmpDir
TmpLog=$TmpDir/$SamFil.QualMetrics.log
if [[ ! $LogFil ]]; then
LogFil=$SamFil.QualMetrics.log
fi
OutFil=${SamFil%.*}.qualitymetrics
#Start Log
uname -a >> $TmpLog
echo "Start Get Quality Metrics from SAM/BAM using PICARD - $0:`date`" >> $TmpLog
echo " Job name: "$JOB_NAME >> $TmpLog
echo " Job ID: "$JOB_ID >> $TmpLog
#Quality Score Distribution
echo "- Get Quality Score Distribution from BAM file using PICARD `date`..." >> $TmpLog
cmd="$JAVA7BIN -Xmx4G -Djava.io.tmpdir=$TmpDir -jar $PICARD/QualityScoreDistribution.jar CHART_OUTPUT=$OutFil.QualityScoreDistr.pdf INPUT=$SamFil OUTPUT=$OutFil REFERENCE_SEQUENCE=$REF"
echo " "$cmd >> $TmpLog
$cmd
if [[ $? == 1 ]]; then
echo "----------------------------------------------------------------" >> $TmpLog
echo "Get Quality Score Distribution from SAM/BAM using PICARD failed `date`" >> $TmpLog
qstat -j $JOB_ID | grep -E "usage" >> $TmpLog
exit 1
fi
echo "End Get Quality Metrics from SAM/BAM using PICARD $0:`date`" >> $TmpLog
qstat -j $JOB_ID | grep -E "usage" >> $TmpLog
echo "===========================================================================================" >> $TmpLog
echo "" >> $TmpLog
cat $TmpLog >> $LogFil
rm -r $TmpDir $TmpLog