-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPPrunflk.sh
executable file
·62 lines (44 loc) · 1.53 KB
/
PPrunflk.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
#!/bin/bash
#PoolParty v0.81
#PPrunflk
BASEDIR=$(dirname "$0")
if [[ ${BASEDIR} != *poolparty* ]];then
SLOC=$(readlink -f "$0")
BASEDIR=${SLOC%/*}
fi
set -o pipefail
#pass an analyzed allele frequency table to FLK R script
#Define arguments
while getopts ":o:i:g:h:" opt; do
case $opt in
o) output="$OPTARG"
;;
i) input="$OPTARG"
;;
g) outgroup="$OPTARG"
;;
h) help="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&4
;;
esac
done
#help
if [ -z "$output" ] || [ -z "$input" ] ; then
printf "\nPPrunflk : Runs FLK script using an allele frequency table (.fz) \n \n"
printf "Usage: PPrunflk -i [input] -o [output name] -g [outgroup] ] \n"
printf "\n Argument Description Default\n \n"
printf " - i [input] : Input file in PP .fz format [REQUIRED] \n"
printf " - o [output name] : Prefix for output name [REQUIRED] \n"
printf " - g [outgroup] : Specify an outgroup if desired (population integer) [FALSE] \n"
exit
fi
[ -z "$outgroup" ] && outgroup=NULL
echo "$outgroup"
Rscript $BASEDIR/rscripts/r_FLKu.R $input $output $outgroup
if [[ ! -s ${output}_flk_results.txt ]] ; then
echo "ERROR: FLK failed, ensure you have > 2 populations"
exit
fi
awk '{print $1,$2,NR, $7}' ${output}_flk_results.txt | awk '{if (NR!=1) {print}}' > ${output}.flk
echo "ALERT: Done"