-
Notifications
You must be signed in to change notification settings - Fork 0
/
BND.sh
52 lines (46 loc) · 2 KB
/
BND.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
# write BND mates
VCF_SNF="/media/eservant/HDD_12To_31/Promethion/SQK-LSK114_062023/dorado3.0/vc/sniffles/17CY001482_sniffles2_t2t.vcf"
BASE="/media/eservant/HDD_12To_31/Promethion/SQK-LSK114_062023/dorado3.0"
FLAGS_sample="17CY001482_t2t"
echo "writing BND mates..."
echo "grepping..."
grep '\[N' $VCF_SNF > grep.txt
while read -r line;
do
pos=`echo $line | awk -v OFS='\t' '{print substr($5, 2, length($5) - 3)}' | tr ":" "\t"`
var=`echo $line | awk -v OFS='\t' '{print $3, $4, "[" $1 ":" $2 "[N", $6, $7, $8, $9, $10}'`
echo -e "$pos" '\t' "$var" >> BND.txt ;
done < grep.txt
grep '\]N' $VCF_SNF > grep.txt
while read -r line;
do
pos=`echo $line | awk -v OFS='\t' '{print substr($5, 2, length($5) - 3)}' | tr ":" "\t"`
var=`echo $line | awk -v OFS='\t' '{print $3, $4, "N[" $1 ":" $2 "[", $6, $7, $8, $9, $10}'`
echo -e "$pos" '\t' "$var" >> BND.txt ;
done < grep.txt
grep 'N\]' $VCF_SNF > grep.txt
while read -r line;
do
pos=`echo $line | awk -v OFS='\t' '{print substr($5, 3, length($5) - 3)}' | tr ":" "\t"`
var=`echo $line | awk -v OFS='\t' '{print $3, $4, "N]" $1 ":" $2 "]", $6, $7, $8, $9, $10}'`
echo -e "$pos" '\t' "$var" >> BND.txt ;
done < grep.txt
grep 'N\[' $VCF_SNF > grep.txt
while read -r line;
do
pos=`echo $line | awk -v OFS='\t' '{print substr($5, 3, length($5) - 3)}' | tr ":" "\t"`
var=`echo $line | awk -v OFS='\t' '{print $3, $4, "]" $1 ":" $2 "]N", $6, $7, $8, $9, $10}'`
echo -e "$pos" '\t' "$var" >> BND.txt ;
done < grep.txt
if [ -s BND.txt ]; then echo "BNDs in BND.txt"; fi
cat $VCF_SNF BND.txt > unsorted.txt
grep -v '#' unsorted.txt | sort -k1,1V -k2,2n > sorted.txt
grep '#' unsorted.txt > header.txt
#echo '##BND mates lines added' >> header.txt
cat header.txt sorted.txt > $BASE/vc/sniffles/${FLAGS_sample}_sniffles_BND.vcf
if [ -s $BASE/vc/sniffles/${FLAGS_sample}_sniffles_BND.vcf ]; then echo "BND mating succesful."; else echo "WARNING: BND mating not successful";fi
# rm header.txt
# rm unsorted.txt
# rm BND.txt
# rm grep.txt
# rm sorted.txt