forked from ISUgenomics/common_analyses
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GATK_01_RunBWA.sh
executable file
·31 lines (28 loc) · 1002 Bytes
/
GATK_01_RunBWA.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
#!/bin/bash
# perfomrs mapping of reads to the indexed reference genome
# uses the options specified in "best practices"
#command genomeModule READ1 READ2
module load picard/2.4.1
module load java
module load bwa/0.7.12
module load samtools
module load $1
REF="$GENOMEDIR/$GNAME"
# this option might be the frequetly changed, hence not it's a variable
THREADS="16"
# if the reads are paired then use -p option
if [ "$#" -eq 3 ]; then
READ1="$2"
READ2="$3"
OUTNAME=$(basename ${READ1%.*} | cut -f 1-2 -d "_")
bwa mem -M -x ont2d -t ${THREADS} ${REF} ${READ1} ${READ2} | samtools view -buS - > ${OUTNAME}.bam
# if not just use the reads as single reads
elif [ "$#" -eq 1 ]; then
READ1="$2"
OUTNAME=$(basename ${READ1%.*} | cut -f 1-2 -d "_")
bwa mem -M -x ont2d -t ${THREADS} ${REF} ${READ1} | samtools view -buS - > ${OUTNAME}.bam
# if number of arguments do not match, raise error
else
echo "ERROR: INVALID NUMBER OF ARGUMENTS"
echo "GATK_01_RunBWA.sh genomeModule READ1 READ2"
fi