annotate tools/human_genome_variation/BEAM2_wrapper.sh @ 2:c2a356708570

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