0
|
1 #!/usr/bin/env bash
|
|
2 #
|
|
3 # Galaxy wrapper for Yu Zhang's BEAM2 adds two new options
|
|
4 # significance=foo renames significance.txt to foo after BEAM2 is run
|
|
5 # posterior=bar renames posterior.txt to bar after BEAM2 is run
|
|
6 #
|
|
7
|
|
8 set -e
|
|
9
|
|
10 export PATH=$PATH:$(dirname $0)
|
|
11
|
|
12 ## options
|
|
13 significance=
|
|
14 posterior=
|
|
15 new_args=
|
|
16 map=
|
|
17 ped=
|
|
18
|
|
19 TFILE="/tmp/BEAM2.$$.tmp"
|
|
20
|
|
21 ## separate significance and posterior arguments from arguments to BEAM2
|
|
22 until [ $# -eq 0 ]
|
|
23 do
|
|
24 case $1 in
|
|
25 significance=*)
|
|
26 significance=${1#significance=}
|
|
27 ;;
|
|
28 posterior=*)
|
|
29 posterior=${1#posterior=}
|
|
30 ;;
|
|
31 map=*)
|
|
32 map=${1#map=}
|
|
33 ;;
|
|
34 ped=*)
|
|
35 ped=${1#ped=}
|
|
36 ;;
|
|
37 *)
|
|
38 if [ -z "$new_args" ]; then
|
|
39 new_args=$1
|
|
40 else
|
|
41 new_args="$new_args $1"
|
|
42 fi
|
|
43 ;;
|
|
44 esac
|
|
45
|
|
46 shift
|
|
47 done
|
|
48
|
|
49 ## convert input for use with BEAM2
|
|
50 lped_to_geno.pl $map $ped > $TFILE
|
|
51 if [ $? -ne 0 ]; then
|
|
52 echo "failed: lped_to_geno.pl $map $ped > $TFILE"
|
|
53 exit 1
|
|
54 fi
|
|
55
|
|
56 ## run BEAM2
|
|
57 BEAM2 $TFILE $new_args 1>/dev/null
|
|
58 if [ $? -ne 0 ]; then
|
|
59 echo "failed: BEAM2 $TFILE $new_args"
|
|
60 exit 1
|
|
61 fi
|
|
62
|
|
63 mergeSnps.pl significance.txt $TFILE
|
|
64 if [ $? -ne 0 ]; then
|
|
65 echo "failed: mergeSnps.pl significance.txt $TFILE"
|
|
66 exit 1
|
|
67 fi
|
|
68
|
|
69 ## move output files
|
|
70 mv significance.txt $significance
|
|
71 mv posterior.txt $posterior
|
|
72
|
|
73 ## cleanup
|
|
74 rm -f $TFILE
|
|
75
|