-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapply1000GenomeFilter.sh
executable file
·68 lines (60 loc) · 2 KB
/
apply1000GenomeFilter.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
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#################### Help Message ####################
Help()
{
# Display help message
echo "This script will submit a SLURM batch job that apply a mask filter to a variant callset"
echo
echo "Usage:"
echo ' ./apply1000GenomeFilter.sh [filterScript] [variantCalls] [filterName] [filterFile]'
echo
echo "Argument Descriptions:"
echo " [-h] Print this message"
echo " [filterScript] The name of the specific R script to execute the filtering: 1000GenomeRegionVariantFilter.R or strictMaskFilter.R"
echo " [variantCalls] The user-defined text file containing variant callset to be filtered"
echo " [filterName] The name of the filter being applied, will be used in output filename, see filters directory"
echo " [filterFile] The BED file for the filter being applied, see filters directory"
echo
echo "Usage Example:"
echo ' ./apply1000GenomeFilter.sh 1000GenomeRegionVariantFilter.R variantCalls.basefilter.txt LRC data/filters/LCR-hg38.bed'
echo
}
while getopts ":h" option;
do
case $option in
h) # Show help message
Help
exit;;
\?) # Reject other passed options
echo "Invalid option"
exit;;
esac
done
############################################################
# Debugging settings
set -euo pipefail
# User defined filter script (1000 Genome Region or Strict Mask), variant call set, filter
# name, and filter file
filterScript=${1}
variantCalls=${2}
filterName=${3}
filterFile=${4}
# Set chromosome list
declare -a chromList=("chr1" "chr2" "chr3" "chr4" "chr5"
"chr6" "chr7" "chr8" "chr9" "chr10"
"chr11" "chr12" "chr13" "chr14" "chr15"
"chr16" "chr17" "chr18" "chr19" "chr20"
"chr21" "chr22" "chrX" "chrY")
# Loop through the chromosome list and submit a batch command to run the filter script
for chrom in "${chromList[@]}"
do
batchCommand="
sbatch \
--job-name=${filterName}_${chrom} \
${filterScript} \
${variantCalls} \
${filterName} \
${filterFile} \
${chrom}"
eval "$batchCommand"
done