-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_bam.sh
executable file
·41 lines (33 loc) · 1.14 KB
/
index_bam.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
#!/bin/bash
#PBS -l mem=1gb,nodes=1:ppn=8,walltime=6:00:00
#PBS -m abe
#PBS -M [email protected]
#PBS -q lab
set -e
set -u
set -o pipefail
# Define usage message
# Note: The following paths to arguments will need to be hardcoded \n\
# 1. [bamFile_list] is a list of bam files to be indexed
# 2. [bamFile_dir] is where our BAM files are located
# Dependencies
module load samtools
module load parallel
# Function to index bam files
function indexBAM() {
local BAMFile="$1"
local out_dir="$2"
# Sample name
sampleName=`basename "${BAMFile}" .bam`
# Create BAI index for BAM file
samtools index -b "${out_dir}/${sampleName}.bam"
}
# Export function
export -f indexBAM
# Arguments provided by user
# list of bam files
BAM_LIST=/panfs/roc/scratch/liux1299/WBDC_Inversions_Project/seq_handling_parts_ref/WBDC_LianaPop/SAM_Processing/SAMtools/WBDC_LianaPop_Finished_BAM_list.txt
# where are our BAM files located?
OUT_DIR=/panfs/roc/scratch/liux1299/WBDC_Inversions_Project/seq_handling_parts_ref/WBDC_LianaPop/SAM_Processing/SAMtools/Finished
# Do the work
parallel indexBAM {} "${OUT_DIR}" :::: "${BAM_LIST}"