-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfingerprint.sh
89 lines (74 loc) · 1.72 KB
/
fingerprint.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
#!/bin/bash
# This scrip will parse a vcf file and replace the individual ID
#
# Once generated it can be used to compare any other samples from this platform.
#
# @params
# i Input VCF file
# f Generic Identity (defaults to "FingerPrint"
# o Output VCF file
#
echo "Generate generic fingerprint VCF that can be compared to any other."
echo ""
echo "INFO: Commandline: ${0} ${@}"
echo ""
usage() {
cat << EOF
This scrip will parse a vcf file and replace the individual ID
Once generated it can be used to compare any other samples from this platform.
usage: $0 options
Options:
-i Source VCF file
-f Generic Identity
-o Ouput VCF file
EOF
}
INPUT_FILE=
FINGERPRINT="Individual"
OUTPUT_FILE=
while getopts "i:f:o:" OPTION
do
case $OPTION in
i)
if [[ -e ${OPTARG} ]]
then
INPUT_FILE=${OPTARG}
else
echo "FAILURE: Input file \"${OPTARG}\" does not exist."
fi
;;
f)
FINGERPRINT=${OPTARG}
;;
o)
if [[ -e ${OPTARG} ]]
then
echo "WARNING: Output file \"${OPTARG}\" already exists and will be overwritten!"
fi
OUTPUT_FILE=${OPTARG}
;;
?)
usage
exit 1
;;
esac
done
if [[ -z ${INPUT_FILE} ]] || [[ -z ${OUTPUT_FILE} ]]
then
usage
exit 1
fi
echo Input VCF File: ${INPUT_FILE}
echo Output VCF File: ${OUTPUT_FILE}
echo Generic Identity:${FINGERPRINT}
OUTPUT_DIR=$(dirname ${OUTPUT_FILE})
if mkdir -p ${OUTPUT_DIR}
then
if sed '/#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT/c\#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT '${FINGERPRINT} ${INPUT_FILE} > ${OUTPUT_FILE}
then
echo "SUCCESS: Fingerprint file \"${OUTPUT_FILE}\" created with Generic ID \"${FINGERPRINT}\""
exit 0
fi
fi
echo "FAILURE: Unable to replace identifier in \"${INPUT_FILE}\""
exit 1