This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
181 lines (160 loc) · 7.07 KB
/
run.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
set -ei
# This function only changes echo headers
# for user's sake.
function message() {
# Define local variables
local status=${1} # Either INFO, CMD, ERROR or DOC
local message="${2:-1}" # Your message
# Classic switch based on status
if [ ${status} = INFO ]; then
echo -e "\033[1;36m@INFO:\033[0m ${message}"
elif [ ${status} = WARNING ]; then
echo -e "\033[1;33m@WARNING:\033[0m ${message}"
elif [ ${status} = ERROR ]; then
echo -e "\033[41m@ERROR:\033[0m ${message}"
elif [ ${status} = DOC ]; then
echo -e "\033[0;33m@DOC:\033[0m ${message}"
else
error_handling ${LINENO} 1 "Unknown message type"
fi
}
# This function will take error messages and exit the program
function error_handling() {
# Geathering input parameter (message, third parameter is optionnal)
echo -ne "\n"
local parent_lineno="$1"
local code="$2"
local message="${3:-1}"
# Checking the presence or absence of message
if [[ -n "$message" ]] ; then
# Case message is present
message ERROR "Error on or near line ${parent_lineno}:\n ${message}"
message ERROR "Exiting with status ${code}"
else
# Case message is not present
message ERROR "Error on or near line ${parent_lineno}"
message ERROR "Exiting with status ${code}"
fi
# Exiting with given error code
exit "${code}"
}
function help_message() {
message DOC "Hi, I'm functionnal only at IGR's Flamingo. Do not try to run "
message DOC "me elsewhere. I won't work."
echo ""
message DOC "Thanks for using me as your script for running "
message DOC "vcf-annotate-snpeff-snpsift. I'm very proud to be your script "
message DOC "today, and I hope you'll enjoy working with me."
echo ""
message DOC "Every time you'll see a line starting with '@', "
message DOC "it will be because I speak."
message DOC "In fact, I always start my speech with :"
message DOC "'\033[0;33m@DOC:\033[0m' when i't about my functions,"
message DOC "'\033[1;36m@INFO:\033[0m' when it's about my intentions, "
message DOC "'\033[1;33m@WARNING:\033[0m' for non-critical issues, "
message DOC "'\033[41m@ERROR:\033[0m', I tell you when things go wrong."
echo ""
message DOC "I understand very fiew things, and here they are:"
message DOC "-h | --help Print this help message, then exit."
message DOC "--vcf-dir Path to VCF files (default: .)"
message DOC "--hg19 Use GRCh37 annotations, instead of GRCh38.86"
message DOC "--mm10 Use GRCm38 annotations, instead of GRCh38.86"
message DOC "--mm9 Use GRCm37 annotations, instead of GRCh38.86"
message DOC "Otherwise, run me without any arguments and I'll do magic."
echo ""
message DOC "A typical command line would be:"
message DOC "bash /path/to/run.sh"
exit 0
}
function export_hg37 {
message INFO "Using HG19 annotations"
declare -x GWASCAT_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.gwascat.tsv"
declare -x DBNSFP_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.dbNSFP.vcf.gz"
declare -x DBSNP_PATH="/mnt/beegfs/database/bioinfo/Index_DB/dbsnp.vcf"
declare -x GENESETS_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.gmt"
declare -x COSMIC_PATH="/mnt/beegfs/database/bioinfo/Index_DB/Cosmic.vcf"
declare -x KAVIAR_PATH="/mnt/beegfs/database/bioinfo/Index_DB/kaviar.vcf"
declare -x CLINVAR_PATH="/mnt/beegfs/database/bioinfo/Index_DB/clinvar.vcf"
declare -x KGENOME_PATH="/mnt/beegfs/database/bioinfo/Index_DB/1000g.vcf"
declare -x SNPEFF_DB_PATH="/mnt/beegfs/database/bioinfo/Index_DB/snpeff/data/GRCtest/"
export GWASCAT_PATH DBNSFP_PATH DBSNP_PATH GENESETS_PATH COSMIC_PATH KAVIAR_PATH CLINVAR_PATH KGENOME_PATH SNPEFF_DB_PATH
}
function export_mm10 {
message INFO "Using MM10 annotations"
declare -x GWASCAT_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.gwascat.tsv"
declare -x DBNSFP_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.dbNSFP.vcf.gz"
declare -x DBSNP_PATH="/mnt/beegfs/database/bioinfo/Index_DB/dbsnp.vcf"
declare -x GENESETS_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.gmt"
declare -x COSMIC_PATH="/mnt/beegfs/database/bioinfo/Index_DB/Cosmic.vcf"
declare -x KAVIAR_PATH="/mnt/beegfs/database/bioinfo/Index_DB/kaviar.vcf"
declare -x CLINVAR_PATH="/mnt/beegfs/database/bioinfo/Index_DB/clinvar.vcf"
declare -x KGENOME_PATH="/mnt/beegfs/database/bioinfo/Index_DB/1000g.vcf"
declare -x SNPEFF_DB_PATH="/mnt/beegfs/database/bioinfo/Index_DB/snpeff/data/GRCtest/"
export GWASCAT_PATH DBNSFP_PATH DBSNP_PATH GENESETS_PATH COSMIC_PATH KAVIAR_PATH CLINVAR_PATH KGENOME_PATH SNPEFF_DB_PATH
}
function export_mm9 {
message INFO "Using MM9 annotations"
declare -x GWASCAT_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.gwascat.tsv"
declare -x DBNSFP_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.dbNSFP.vcf.gz"
declare -x DBSNP_PATH="/mnt/beegfs/database/bioinfo/Index_DB/dbsnp.vcf"
declare -x GENESETS_PATH="/mnt/beegfs/database/bioinfo/Index_DB/test.gmt"
declare -x COSMIC_PATH="/mnt/beegfs/database/bioinfo/Index_DB/Cosmic.vcf"
declare -x KAVIAR_PATH="/mnt/beegfs/database/bioinfo/Index_DB/kaviar.vcf"
declare -x CLINVAR_PATH="/mnt/beegfs/database/bioinfo/Index_DB/clinvar.vcf"
declare -x KGENOME_PATH="/mnt/beegfs/database/bioinfo/Index_DB/1000g.vcf"
declare -x SNPEFF_DB_PATH="/mnt/beegfs/database/bioinfo/Index_DB/snpeff/data/GRCtest/"
export GWASCAT_PATH DBNSFP_PATH DBSNP_PATH GENESETS_PATH COSMIC_PATH KAVIAR_PATH CLINVAR_PATH KGENOME_PATH SNPEFF_DB_PATH
}
VCF_DIR="${PWD}"
ANNOT="hg38"
while [[ $# -gt 0 ]]; do
case "${1}" in
-h|--help)
help_message
;;
--vcf-dir)
VCF_DIR="${2}"
shift 2
;;
--hg19)
ANNOT="hg19"
shift
;;
--mm10)
ANNOT="mm10"
shift
;;
--mm9)
ANNOT="mm9"
shift
;;
*)
error_handling ${LINENO} 1 "Unknown argument ${1}"
shift
;;
esac
done
if [ ANNOT = hg19 ]; then
export_hg19
elif [ ANNOT = mm10 ]; then
export_mm10
elif [ ANNOT = mm9 ]; then
export_mm9
else
message INFO "Using HG38 annotations"
fi
CONDA='conda'
CONDA_VERSION="$(conda --version)"
CONDA_ENV="/mnt/beegfs/pipelines/rna-count-salmon/env"
[ "${CONDA_VERSION:?}" = "conda 4.9.2" ] || message WARNING "Your version of conda might not be up to date. Trying anyway with the rest of the pipeline."
which mamba > /dev/null 2>&1 && CONDA="mamba" || message WARNING "Mamba not found, falling back to conda."
# Loading conda
message INFO "Sourcing conda for users who did not source it before."
source "$(conda info --base)/etc/profile.d/conda.sh" && conda activate || exit error_handling "${LINENO}" 1 "Could not source conda environment."
# Check on environment variables: if env are missing
message INFO "Loading 'vcf-annotate-snpeff-snpsift' environment"
conda activate ${CONDA_ENV} || error_handling "${LINENO}" 2 "Could not activate the environment for vcf-annotate-snpeff-snpsift."
# then installation process did not work properly
message INFO "Running pipeline if and only if it is possible"
$(export -p | grep "ANNOT_LAUNCHER" --quiet) && python3 ${ANNOT_LAUNCHER:?} flamingo --vcf_dir ${VCF_DIR} || error_handling ${LINENO} 3 "Error while running: ${ANNOT_LAUNCHER}"