3
|
1 #!/bin/bash
|
|
2
|
|
3 tool_path=$(dirname $0)
|
|
4
|
|
5 filein=$1
|
|
6 fileout_label=$(date "+%Y%m%d%H%M%S")
|
4
|
7 window=$2
|
|
8 filelog=$3
|
|
9 fileout_taj=$4
|
|
10 fileout_tstv=$5
|
|
11 fileout_windowed=$6
|
|
12 fileout_snp=$7
|
|
13 group=$8
|
3
|
14 if [ "$group" != "none" ]
|
4
|
15 then fileout_fst=${9}
|
|
16 fileout_fst_marker=${10}
|
|
17 fileout_taj_combined=${11}
|
|
18 fileout_windowed_combined=${12}
|
7
|
19 fileout_tstv_combined=${13}
|
|
20 fileout_snp_combined=${14}
|
3
|
21 fi
|
|
22
|
|
23
|
|
24 cp $filein ${filein}.vcf
|
|
25 if [ "$group" != "none" ]
|
8
|
26 then
|
|
27 if [ $(sort -k2,2 -t ';' -u $group | cut -f2 -d ';' |wc -l) -ge 3 ]
|
|
28 then
|
|
29 echo 'ERROR: it only works with 2 groups. There is too many groups in your file.' >&2
|
|
30 exit 1
|
|
31 else
|
|
32 perl $tool_path/VCFToolsSlidingWindow.pl --input ${filein}.vcf --out $fileout_label --window $window --group $group
|
|
33 fi
|
|
34
|
|
35
|
4
|
36 else perl $tool_path/VCFToolsSlidingWindow.pl --input ${filein}.vcf --out $fileout_label --window $window
|
3
|
37 fi
|
|
38
|
|
39 mv ${fileout_label}.vcftools.log $filelog
|
|
40 mv ${fileout_label}.Tajima.D ${fileout_taj}
|
|
41 mv ${fileout_label}.TsTv ${fileout_tstv}
|
|
42 mv ${fileout_label}.windowed.pi ${fileout_windowed}
|
|
43 mv ${fileout_label}.snpden ${fileout_snp}
|
|
44
|
|
45 if [ "$group" != "none" ]
|
|
46 then mv ${fileout_label}.fst.txt ${fileout_fst}
|
|
47 mv ${fileout_label}.fst.by_marker.genes.txt ${fileout_fst_marker}
|
|
48 mv ${fileout_label}.combined.dtajima.txt ${fileout_taj_combined}
|
|
49 mv ${fileout_label}.combined.pi.txt ${fileout_windowed_combined}
|
7
|
50 paste ${fileout_label}.Pop1.TsTv ${fileout_label}.Pop2.TsTv | column -s $'\t' -t | awk '{OFS="\t"; print $1,$2,$4,$8} ' | awk 'NR==1{$3="Pop1";$4="Pop2"}1' > ${fileout_tstv_combined}
|
|
51 paste ${fileout_label}.Pop1.snpden ${fileout_label}.Pop2.snpden | column -s $'\t' -t | awk '{OFS="\t"; print $1,$2,$4,$8} ' | awk 'NR==1{$3="Pop1";$4="Pop2"}1' > ${fileout_snp_combined}
|
3
|
52 fi
|
|
53
|
|
54 rm -f ${filein}.vcf ${filein}.vcf.*
|
|
55
|