-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixMultiInDel.sh
More file actions
executable file
·81 lines (69 loc) · 1.71 KB
/
Copy pathfixMultiInDel.sh
File metadata and controls
executable file
·81 lines (69 loc) · 1.71 KB
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
#!/bin/bash
SDIR="$( cd "$( dirname "$0" )" && pwd )"
NORM_EXTRA_OPTS=""
NUMARGS=$#
if [ $NUMARGS -lt 1 ] || [ $NUMARGS -gt 3 ]; then
echo
echo "ERROR: Too many/few arugments"
echo "usage: fixMultiInDel.sh [-a] INPUT_VCF [OUTPUT_VCF]"
echo " -a : output all variants when fixing multi indels"
echo
exit
fi
while getopts :a FLAG; do
case $FLAG in
a)
NORM_EXTRA_OPTS="-a"
;;
\?) #unrecognized option
echo
echo "ERROR: Unrecognized arugment: $OPTARG"
echo "usage: fixMultiInDel.sh [-a] INPUT_VCF [OUTPUT_VCF]"
echo " -a : output all variants when fixing multi indels"
echo
exit
;;
esac
done
shift $((OPTIND-1))
case $# in
2)
HVCF=$1
OUTFILE=$2
;;
1)
HVCF=$1
OUTFILE=$(basename $HVCF | sed 's/.vcf$/___FixInDels.vcf/')
;;
*)
echo
echo "ERROR: Cannot find input file in command line"
echo "usage: fixMultiInDel.sh -a INPUT_VCF [OUTPUT_VCF]"
echo " -a : output all variants when fixing multi indels"
echo
exit
;;
esac
#
# Haplotype does not set the correct FORMAT
# header for AD
#
# FORMAT=<ID=AD,Number=.,
#
# needs to be changed to
#
# FORMAT=<ID=AD,Number=R,
#
# for the splitter to correctly reassign AD but
# then need to undo this for downstream steps to work
#
# Also need to sort VCF since normalize will change
# position of SNP's when it de-pads them.
#
cat $HVCF \
| sed 's/FORMAT=<ID=AD,Number=.,/FORMAT=<ID=AD,Number=R,/' \
| bcftools norm -m- \
| $SDIR/bin/normalizeInDels.py $NORM_EXTRA_OPTS \
| bedtools sort -i - -header \
| sed 's/FORMAT=<ID=AD,Number=R,/FORMAT=<ID=AD,Number=.,/' \
> $OUTFILE