annotate MUMmer/mummer_tool.sh @ 0:6753195df9e0 default tip

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author abossers
date Tue, 07 Jun 2011 17:49:58 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
1 #!/bin/bash
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
2 ## use #!/bin/bash -x for debugging
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
3
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
4 ## Galaxy wrapper for MUMmer (nucmer/promer)
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
5 ## Alex Bossers, CVI of Wageningen UR, NL
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
6 ## alex_dot_bossers_at_wur_dot_nl
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
7 ##
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
8 ## Sep 2010
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
9 ##
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
10 ## Wrapper runs MUMmer nucmer/promer and additional args
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
11 ## Calculates the comparison scores (delta and optional coords file)
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
12 ## Generates the optional STATIC comparison mummerplot to png (from delta file)
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
13 ##
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
14 ## finally the script renames (optional) output files to outfiles expected by Galaxy
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
15 ##
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
16 ##
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
17 ## INPUT args:
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
18 ## nucmer_tool.sh $input_ref $input_query $out_delta $out_coords $out_png $logfile
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
19 ## @0 @1 @2 @3 @4 @5
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
20 ## $algorithm $keep_delta $make_coords $keep_log $make_image $cmd_extra
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
21 ## @6 @7 @8 @9 @10 @11
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
22 ##
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
23
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
24 # path to where mummer suite is installed
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
25 # adjust this for your machine
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
26 # this is the only hard coded path in the scripts
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
27 mum_path="/opt/MUMmer/MUMmer"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
28
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
29 # since we have more than 9 arguments we need to shift the sections or use own array
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
30 args=("$@")
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
31 # to keep things readible assign vars
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
32 input_ref="${args[0]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
33 input_query="${args[1]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
34 out_delta="${args[2]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
35 out_coords="${args[3]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
36 out_png="${args[4]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
37 logfile="${args[5]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
38 algorithm="${args[6]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
39 keep_delta="${args[7]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
40 make_coords="${args[8]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
41 keep_log="${args[9]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
42 make_image="${args[10]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
43 cmd_extra="${args[11]}"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
44
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
45 # enable/disable the STDOUT log file
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
46 if [ "$keep_log" == "yes" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
47 logfile_c="2>$logfile"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
48 logfile_a="2>>$logfile"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
49 else
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
50 #dump to dev/null
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
51 logfile_c="2>&-"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
52 logfile_a="2>&-"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
53 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
54
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
55 # extra mummer cmd line options
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
56
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
57 ## generate coords file on the fly?
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
58 if [ "$make_coords" == "yes" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
59 options=" --coords"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
60 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
61 ## extra cmd line args to be concatenated in options? We need to prevent extra spaces!
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
62 if [ "$cmd_extra" != "" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
63 if [ "$options" == "" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
64 options=" $cmd_extra"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
65 else
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
66 options="$options $cmd_extra"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
67 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
68 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
69
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
70 # run nucmer/promer
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
71 eval "$mum_path/$algorithm$options $input_ref $input_query $logfile_c"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
72
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
73 ## generate large png if option make_image = yes
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
74 ## suppress error from mummerplot since some is deprecated but not a real error
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
75 ## error can be easily avoided by modifying the source of mummerplot... just in case
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
76 ## however we need to check if a valid png was generated. This is not the case is alignment is none
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
77 ## 1 is stderr and 2 stdout. redirect to dev/null
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
78
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
79 if [ "${make_image}" == "yes" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
80 eval "$mum_path/mummerplot --large --png out.delta 1>&- $logfile_a"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
81 if [ -f "out.png" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
82 mv out.png $out_png
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
83 #cleanup temp gnuplot file
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
84 rm out.gp
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
85 else
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
86 echo "not exist the req png file!"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
87 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
88
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
89 ## clean up remaining files
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
90 rm out.fplot
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
91 rm out.rplot
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
92
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
93 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
94
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
95 # keep/rename or delete delta file
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
96 if [ "$keep_delta" == "yes" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
97 mv out.delta "$out_delta"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
98 else
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
99 rm out.delta
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
100 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
101
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
102 # keep/rename coords file if it was created
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
103 if [ "$make_coords" == "yes" ]; then
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
104 mv out.coords "$out_coords"
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
105 fi
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
106
6753195df9e0 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
107 # end script