annotate MUMmer/mummer_tool.sh @ 0:61f30d177448 default tip

initial commit on Mummer toolsuite on toolshed
author eric
date Tue, 31 Mar 2015 14:19:49 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
1 #!/bin/bash
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
2 ## use #!/bin/bash -x for debugging
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
3
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
4 ## Galaxy wrapper for MUMmer (nucmer/promer)
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
5 ## Alex Bossers, CVI of Wageningen UR, NL
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
6 ## alex_dot_bossers_at_wur_dot_nl
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
7 ##
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
8 ## Sep 2010
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
9 ##
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
10 ## Wrapper runs MUMmer nucmer/promer and additional args
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
11 ## Calculates the comparison scores (delta and optional coords file)
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
12 ## Generates the optional STATIC comparison mummerplot to png (from delta file)
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
13 ##
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
14 ## finally the script renames (optional) output files to outfiles expected by Galaxy
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
15 ##
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
16 ##
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
17 ## INPUT args:
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
18 ## nucmer_tool.sh $input_ref $input_query $out_delta $out_coords $out_png $logfile
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
19 ## @0 @1 @2 @3 @4 @5
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
20 ## $algorithm $keep_delta $make_coords $keep_log $make_image $cmd_extra
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
21 ## @6 @7 @8 @9 @10 @11
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
22 ##
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
23
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
24 # Function to send error messages.
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
25 log_err() { echo "$@" 1>&2; }
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
26 # path to where mummer suite is installed
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
27 # adjust this for your machine
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
28 # If mummer is available in system path, leave empty
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
29 # when using different path make sure the trailing slash is added.
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
30 # mum_path = /opt/Mummer23/Mummer/
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
31 mum_path=""
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
32 tmp_path="/tmp/mummertmp/"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
33
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
34 if [ $num_path"$(which mummer)" == "" ] && [ "$num_path" == "" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
35 log_err "mummer is not available in system path and not declarated in mum_path. Please install mummer."
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
36 exit 127
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
37 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
38
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
39 # since we have more than 9 arguments we need to shift the sections or use own array
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
40 args=("$@")
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
41 # to keep things readible assign vars
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
42 input_ref="${args[0]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
43 input_query="${args[1]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
44 out_delta="${args[2]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
45 out_coords="${args[3]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
46 out_png="${args[4]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
47 logfile="${args[5]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
48 algorithm="${args[6]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
49 keep_delta="${args[7]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
50 make_coords="${args[8]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
51 keep_log="${args[9]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
52 make_image="${args[10]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
53 cmd_extra="${args[11]}"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
54
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
55 [ -d $tmp_path ] || mkdir $tmp_path
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
56 cd $tmp_path
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
57
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
58 # enable/disable the STDOUT log file
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
59 if [ "$keep_log" == "yes" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
60 logfile_c="2>$logfile"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
61 logfile_a="2>>$logfile"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
62 else
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
63 #dump to dev/null
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
64 logfile_c="2>&-"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
65 logfile_a="2>&-"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
66 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
67
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
68 # extra mummer cmd line options
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
69
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
70 ## generate coords file on the fly?
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
71 if [ "$make_coords" == "yes" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
72 options=" --coords"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
73 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
74 ## extra cmd line args to be concatenated in options? We need to prevent extra spaces!
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
75 if [ "$cmd_extra" != "" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
76 if [ "$options" == "" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
77 options=" $cmd_extra"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
78 else
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
79 options="$options $cmd_extra"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
80 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
81 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
82
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
83 # run nucmer/promer
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
84 # May only run Promer and Nucmer
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
85 echo $algorithm
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
86 if [[ $algorithm =~ ...mer$ ]]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
87 eval "$mum_path$algorithm$options $input_ref $input_query $logfile_c"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
88 else
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
89 log_err 'ERROR, algorithm does not conform to ...mer'
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
90 exit 1
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
91 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
92
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
93
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
94 ## generate large png if option make_image = yes
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
95 ## suppress error from mummerplot since some is deprecated but not a real error
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
96 ## error can be easily avoided by modifying the source of mummerplot... just in case
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
97 ## however we need to check if a valid png was generated. This is not the case is alignment is none
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
98 ## 1 is stderr and 2 stdout. redirect to dev/null
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
99 if [ "${make_image}" == "yes" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
100 eval "$mum_path mummerplot --large --png out.delta 1>&- $logfile_a"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
101 if [ -f "out.png" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
102 mv out.png $out_png
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
103 #cleanup temp gnuplot file
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
104 rm out.gp
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
105 else
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
106 log_err "not exist the req png file!"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
107 exit 1
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
108 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
109
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
110 ## clean up remaining files
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
111 rm out.fplot
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
112 rm out.rplot
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
113
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
114 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
115
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
116 # keep/rename or delete delta file
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
117 if [ "$keep_delta" == "yes" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
118 mv out.delta "$out_delta"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
119 else
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
120 rm out.delta
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
121 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
122
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
123 # keep/rename coords file if it was created
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
124 if [ "$make_coords" == "yes" ]; then
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
125 mv out.coords "$out_coords"
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
126 fi
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
127 # end script
61f30d177448 initial commit on Mummer toolsuite on toolshed
eric
parents:
diff changeset
128 exit 0