-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvcfcmp.sc
executable file
·72 lines (56 loc) · 1.13 KB
/
vcfcmp.sc
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
#!/bin/bash
usage () {
echo "Usage: $0 ref.vcf var1.vcf var2.vcf ..."
echo " e.g.: $0 WT.vcf MU.vcf"
exit 1
}
if [ $# -lt 2 ] ; then
usage
fi
if [ $1 == "-h" ] ; then
usage
fi
ref=$1
shift
if [ ! -f $ref ]; then
echo "Reference VCF file ($ref) does not exist."
usage
fi
# ref
if [ ! -f $ref.gz ]; then
bgzip $ref
fi
if [ ! -f $ref.gz.csi ]; then
bcftools index $ref.gz
fi
mkdir -p ${PWD}/sector
# var
for var in $@; do
if [ ! -f $var ]; then
echo "Mutant VCF file ($var) does not exist."
usage
fi
# Use bcftools to subtract background
echo "Removing background variants in $var ..."
if [ ! -f $var.gz ]; then
bgzip $var
fi
if [ ! -f $var.gz.csi ]; then
bcftools index $var.gz
fi
bcftools isec $ref.gz $var.gz -p filtered
# Restore original VCF file
gunzip $var.gz
rm -rf $var.gz.csi
# Use filter_vcf.pl to filter and annotate VCF file
filter_vcf.sc.pl filtered/0001.vcf
# Prepare out vcf
vcf=`basename $var`
mv ${PWD}/filtered/0001.filtered.ann.vcf ${PWD}/sector/$vcf
rm -rf filtered
done
# Restore ref.vcf
gunzip $ref.gz
rm -rf $ref.gz.csi
echo "Sector VCF files are available at ${PWD}/sector/"
echo "Done"