annotate MUMmer/mummer_tool.sh @ 0:59f302448cf6

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author abossers
date Tue, 07 Jun 2011 17:22:27 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
1 #!/bin/bash
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
3
59f302448cf6 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)
59f302448cf6 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
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
7 ##
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
8 ## Sep 2010
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
9 ##
59f302448cf6 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
59f302448cf6 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)
59f302448cf6 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)
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
13 ##
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
15 ##
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
16 ##
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
17 ## INPUT args:
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
22 ##
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
23
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
28
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
30 args=("$@")
59f302448cf6 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
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
37 logfile="${args[5]}"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
38 algorithm="${args[6]}"
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 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]}"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
44
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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"
59f302448cf6 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"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
49 else
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
51 logfile_c="2>&-"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
52 logfile_a="2>&-"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
53 fi
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
54
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
56
59f302448cf6 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?
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
59 options=" --coords"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
60 fi
59f302448cf6 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!
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
63 if [ "$options" == "" ]; then
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
64 options=" $cmd_extra"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
65 else
59f302448cf6 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"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
67 fi
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
68 fi
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
69
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
70 # run nucmer/promer
59f302448cf6 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"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
72
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
78
59f302448cf6 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
59f302448cf6 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"
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
84 rm out.gp
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
85 else
59f302448cf6 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!"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
87 fi
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
88
59f302448cf6 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
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
90 rm out.fplot
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
91 rm out.rplot
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
92
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
93 fi
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
94
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
98 else
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
99 rm out.delta
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
100 fi
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
101
59f302448cf6 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
59f302448cf6 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
59f302448cf6 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"
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
105 fi
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
106
59f302448cf6 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
abossers
parents:
diff changeset
107 # end script