From 9f6d0f8f5dbfb7501e70666215e4ffeafa633938 Mon Sep 17 00:00:00 2001
From: Brandi Cantarel <brandi.cantarel@utsouthwestern.edu>
Date: Tue, 16 Apr 2019 09:26:11 -0500
Subject: [PATCH] adding rmdup bamqc

---
 alignment/bamqc.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/alignment/bamqc.sh b/alignment/bamqc.sh
index 029a921..91ddb95 100644
--- a/alignment/bamqc.sh
+++ b/alignment/bamqc.sh
@@ -8,11 +8,12 @@ usage() {
   echo "-n  --NucType"
   echo "-p  --Prefix for output file name"
   echo "-c  --Capture Bedfile"
+  echo "-d  --RemoveDuplicates 1=yes, 0=no default=no"
   echo "Example: bash bamqc.sh -p prefix -r /project/shared/bicf_workflow_ref/human/GRCh38 -b SRR1551047.bam  -n dna -c target.bed"
   exit 1
 }
 OPTIND=1 # Reset OPTIND
-while getopts :r:b:c:n:p:h opt
+while getopts :r:b:c:n:p:d:h opt
 do
     case $opt in
         r) index_path=$OPTARG;;
@@ -20,6 +21,7 @@ do
         c) bed=$OPTARG;;
         n) nuctype=$OPTARG;;
         p) pair_id=$OPTARG;;
+	d) dedup=$OPTARG;;
         h) usage;;
     esac
 done
@@ -42,6 +44,12 @@ then
     SLURM_CPUS_ON_NODE=1
 fi
 
+if [[ $dedup == 1 ]]
+then
+    mv $sbam ori.bam
+    samtools view -@ $SLURM_CPUS_ON_NODE -F 1024 -b -o ${sbam} ori.bam
+fi
+
 if [[ $nuctype == 'dna' ]]; then
     module load bedtools/2.26.0 picard/2.10.3
     samtools view -@ $SLURM_CPUS_ON_NODE -b -L ${bed} -o ${pair_id}.ontarget.bam ${sbam}
-- 
GitLab