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