-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathCADD.sh
executable file
·163 lines (136 loc) · 4.14 KB
/
CADD.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
#!/bin/bash
usage="$(basename "$0") [-o <outfile>] [-g <genomebuild>] [-v <caddversion>] [-a] <infile> -- CADD version 1.7
where:
-h show this help text
-o out tsv.gz file (generated from input file name if not set)
-g genome build (supported are GRCh37 and GRCh38 [default: GRCh38])
-v CADD version (only v1.7 possible with this set of scripts [default: v1.7])
-a include annotation in output
input vcf of vcf.gz file (required)
-m use conda only (no apptainer/singularity)
-r singularity/apptainer arguments, e.g. \"--bind /data/mnt/x --nv\" [default \"\" but will always add \"--bind $TMP_DIR\"]
-q print basic information about snakemake run
-p print full information about the snakemake run
-d do not remove temporary directory for debug puroposes
-c number of cores that snakemake is allowed to use [default: 1]
"
unset OPTARG
unset OPTIND
export LC_ALL=C
GENOMEBUILD="GRCh38"
ANNOTATION=false
CONDAONLY=false
OUTFILE=""
VERSION="v1.7"
SIGNULARITYARGS=""
VERBOSE="-q"
CORES="1"
RM_TMP_DIR=true
while getopts ':ho:g:v:c:amr:qpd' option; do
case "$option" in
h) echo "$usage"
exit
;;
o) OUTFILE=$OPTARG
;;
g) GENOMEBUILD=$OPTARG
;;
v) VERSION=$OPTARG
;;
c) CORES=$OPTARG
;;
a) ANNOTATION=true
;;
m) CONDAONLY=true
;;
r) SIGNULARITYARGS=$OPTARG
;;
q) VERBOSE=""
;;
p) VERBOSE="-p"
;;
d) RM_TMP_DIR=false
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
shift $((OPTIND-1))
INFILE=$1
echo "CADD-v1.7 (c) University of Washington, Hudson-Alpha Institute for Biotechnology and Berlin Institute of Health at Charite - Universitatsmedizin Berlin 2013-2024. All rights reserved."
set -ueo pipefail
# check if input file does exist
if [ "$INFILE" == "" ]
then
echo "No input file specified. To run CADD, a list of variants has to be provided in a vcf or vcf.gz file."
exit 1
elif [ ! -f "$INFILE" ]
then
echo "Input file $INFILE does not exist."
exit 1
fi
### Configuring all the paths
FILENAME=$(basename $INFILE)
NAME=${FILENAME%\.vcf*}
FILEDIR=$(dirname $INFILE)
FILEFORMAT=${FILENAME#$NAME\.}
SCRIPT=$(readlink -f "$0")
export CADD=$(dirname "$SCRIPT")
if [ "$FILEFORMAT" != "vcf" ] && [ "$FILEFORMAT" != "vcf.gz" ]
then
echo "Unknown file format $FILEFORMAT. Make sure you provide a *.vcf or *.vcf.gz file."
exit 1
fi
if [ "$OUTFILE" == "" ]
then
OUTFILE=$FILEDIR/$NAME.tsv.gz
fi
if [ "$GENOMEBUILD" != "GRCh38" ] && [ "$GENOMEBUILD" != "GRCh37" ]
then
echo "Unknown/Unsupported genome build $GENOMEBUILD. CADD currently only supports GRCh37 and GRCh38."
exit 1
fi
if [ "$VERSION" != "v1.7" ]
then
echo "Unknown/Unsupported CADD version $VERSION. This set of script currently only supports v1.7."
echo "If you want to score another version of CADD, please download the accordingly tagged version of the scripts"
exit 1
fi
if [ "$ANNOTATION" = 'true' ]
then
CONFIG=$CADD/config/config_${GENOMEBUILD}_${VERSION}.yml
else
CONFIG=$CADD/config/config_${GENOMEBUILD}_${VERSION}_noanno.yml
fi
# Setup temporary folder that is removed reliably on exit and is outside of
# the CADD-scripts directory.
TMP_FOLDER=$(mktemp -d)
if [ "$RM_TMP_DIR" = 'true' ]
then
trap "rm -rf $TMP_FOLDER" ERR EXIT
fi
# Temp files
TMP_INFILE=$TMP_FOLDER/$NAME.$FILEFORMAT
TMP_OUTFILE=$TMP_FOLDER/$NAME.tsv.gz
cp $INFILE $TMP_INFILE
# setup bindings of singularity args
if [ "$CONDAONLY" = 'true' ]
then
SIGNULARITYARGS=""
else
SIGNULARITYARGS="apptainer --apptainer-prefix $CADD/envs/apptainer --singularity-args \"--bind ${TMP_FOLDER} ${SIGNULARITYARGS}\""
fi
echo "Running snakemake pipeline:"
command="snakemake $TMP_OUTFILE \
--sdm conda $SIGNULARITYARGS --conda-prefix $CADD/envs/conda \
--cores $CORES --configfile $CONFIG \
--snakefile $CADD/Snakefile $VERBOSE"
echo -e $command
eval $command
mv $TMP_OUTFILE $OUTFILE
rm $TMP_INFILE # is in temp folder, should not be necessary
OUTFILE=$(echo $OUTFILE | sed 's/^\.\///')
echo -e "\nCADD scored variants written to file: $OUTFILE"
exit 0