comparison fubar-galaxytoolfactory-58871556de57/rgToolFactory.xml @ 6:cb4937b0c21d draft

This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
author fubar
date Sun, 24 Feb 2013 17:15:29 -0500
parents
children
comparison
equal deleted inserted replaced
5:a90a05c309d3 6:cb4937b0c21d
1 <tool id="rgTF" name="Tool Factory" version="0.10">
2 <description>Makes scripts into tools</description>
3 <command interpreter="python">
4 #if ( $__user_email__ not in $__admin_users__ ):
5 rgToolFactory.py --bad_user $__user_email__
6 #else:
7 rgToolFactory.py --script_path "$runme" --interpreter "$interpreter"
8 --tool_name "$tool_name" --user_email "$__user_email__"
9 #if $make_TAB.value=="yes":
10 --output_tab "$tab_file"
11 #end if
12 #if $makeMode.make_Tool=="yes":
13 --make_Tool "$makeMode.make_Tool"
14 --tool_desc "$makeMode.tool_desc"
15 --tool_version "$makeMode.tool_version"
16 --new_tool "$new_tool"
17 --help_text "$helpme"
18 #end if
19 #if $make_HTML.value=="yes":
20 --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes"
21 #end if
22 #if $input1 != 'None':
23 --input_tab "$input1"
24 #end if
25 #end if
26 </command>
27 <inputs>
28 <param name="input1" type="data" label="Select an input file from your history" optional="true" size="120"
29 help="Most scripts will need an input - your script MUST be ready for whatever format you choose"/>
30 <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60"
31 help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">
32 <sanitizer invalid_char="">
33 <valid initial="string.letters,string.digits"/>
34 </sanitizer>
35 </param>
36 <conditional name="makeMode">
37 <param name="make_Tool" type="select" label="Create a tar.gz file ready for local toolshed entry" help="Ready to deploy securely!" size="60">
38 <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option>
39 <option value="" selected="true">No. Just run the script please</option>
40 </param>
41 <when value = "yes">
42 <param name="tool_version" label="Tool Version - bump this to warn users trying to redo old analyses" type="text" value="0.01"
43 help="If you change your script and regenerate the 'same' tool, you should inform Galaxy (and users) by changing (bumping is traditional) this number"/>
44 <param name="tool_desc" label="Tool Description" type="text" value="" size="40"
45 help="Supply a brief tool description for the Galaxy tool menu entry (optional - appears after the tool name)" />
46 <param name="help_text" label="Tool form documentation and help text for users" type="text" area="true"
47 size="8x120" value="**What it Does**"
48 help="Supply the brief user documentation to appear on the new tool form as reStructured text - http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html" >
49 <sanitizer>
50 <valid initial="string.printable">
51 </valid>
52 <mapping initial="none"/>
53 </sanitizer>
54 </param>
55 </when>
56 <when value = "">
57 </when>
58 </conditional>
59 <param name="make_HTML" type="select" label="Create an HTML report with links to all output files and thumbnail links to PDF images" size="60"
60 help="Recommended for presenting complex outputs in an accessible manner. Turn off for simple tools so they just create one output">
61 <option value="yes">Yes, arrange all outputs in an HTML output</option>
62 <option value="" selected="true">No, no HTML output file thanks</option>
63 </param>
64
65
66 <param name="make_TAB" type="select" label="Create a new (default tabular) history output"
67 help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes">
68 <option value="yes" selected="true">My script writes to a new history output</option>
69 <option value="">I only want an HTML output file</option>
70 </param>
71 <param name="out_format" type="select" label="Galaxy datatype for your tool's output file" help="You may need to edit the xml to extend this list">
72 <option value="tabular" selected="true">Tabular</option>
73 <option value="interval">Interval</option>
74 <option value="gz">gz</option>
75 <option value="text">text</option>
76 </param>
77 <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host">
78 <option value="Rscript" selected="true">Rscript</option>
79 <option value="python">python</option>
80 <option value="perl">perl</option>
81 <option value="sh">sh</option>
82 </param>
83 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="8x120"
84 help="Script must deal with two command line parameters: Path to input tabular file path (or 'None' if none selected) and path to output tabular history file (or 'None').">
85 <sanitizer>
86 <valid initial="string.printable">
87 </valid>
88 <mapping initial="none"/>
89 </sanitizer>
90 </param>
91 </inputs>
92 <outputs>
93 <data format="tabular" name="tab_file" label="${tool_name}.${out_format}">
94 <filter>make_TAB=="yes"</filter>
95 <change_format>
96 <when input="out_format" value="interval" format="interval" />
97 <when input="out_format" value="gz" format="gz" />
98 <when input="out_format" value="text" format="text" />
99 </change_format>
100 </data>
101 <data format="html" name="html_file" label="${tool_name}.html">
102 <filter>make_HTML == "yes"</filter>
103 </data>
104 <data format="toolshed.gz" name="new_tool" label="${tool_name}.toolshed.gz">
105 <filter>makeMode['make_Tool'] == "yes"</filter>
106 </data>
107 </outputs>
108 <configfiles>
109 <configfile name="runme">$dynScript</configfile>
110 <configfile name="helpme">
111 #if $makeMode.make_Tool == "yes":
112 ${makeMode.help_text}
113 #end if
114 </configfile>
115 </configfiles>
116 <help>
117
118 .. class:: warningmark
119
120 **Details and attribution** GTF_
121
122 **Local Admins ONLY** Only users whose IDs found in the local admin_user configuration setting in universe_wsgi.ini can run this tool.
123
124 **If you find a bug** please raise an issue at the bitbucket repository GTFI_
125
126 **What it does** This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy.
127
128 **Input options** This version is limited to simple transformation or reporting requiring only a single input file selected from the history.
129
130 **Output options** Optional script outputs include one single new history tabular file, or for scripts that create multiple outputs,
131 a new HTML report linking all the files and images created by the script can be automatically generated.
132
133 **Tool Generation option** Once the script is working with test data, this tool will optionally generate a new Galaxy tool in a gzip file
134 ready to upload to your local toolshed for sharing and installation. Provide a small sample input when you run generate the tool because
135 it will become the input for the generated functional test.
136
137 .. class:: warningmark
138
139 **Note to system administrators** This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.
140 Admin_users will have the power to do anything they want as the Galaxy user if you install this tool.
141
142 .. class:: warningmark
143
144 **Use on public servers** is STRONGLY discouraged for obvious reasons
145
146 The tools generated by this tool will run just as securely as any other normal installed Galaxy tool but like any other new tools, should always be checked carefully before installation.
147 We recommend that you follow the good code hygiene practices associated with safe toolshed.
148
149 **Scripting conventions** The pasted script will be executed with the path to the (optional) input tabular data file path or NONE if you do not select one, and the path to the optional
150 output file or None if none is wanted, as the first and second command line parameters. The script must deal appropriately with these - see Rscript examples below.
151 Note that if an optional HTML output is selected, all the output files created by the script will be nicely presented as links, with pdf images linked as thumbnails in that output.
152 This can be handy for complex scripts creating lots of output.
153
154 **Examples**
155 <![CDATA[
156
157 Each of these following trivial examples can be cut and pasted into the script box for testing.
158 Please make sure you choose the appropriate interpreter and upload and select a suitable small matching test data input
159
160 A simple Rscript "filter" showing how the command line parameters can be handled, takes an input file, does something (transpose in this case) and
161 writes the results to a new tabular file. Note the use of colClasses to ensure that no fiddling takes place with numeric values by treating everything
162 as a string::
163
164 # transpose a tabular input file and write as a tabular output file
165 ourargs = commandArgs(TRUE)
166 inf = ourargs[1]
167 outf = ourargs[2]
168 inp = read.table(inf,head=F,row.names=NULL,sep='\t',colClasses="character")
169 outp = t(inp)
170 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F)
171
172 Calculate a multiple test adjusted p value from a column of p values - for this script to be useful, it needs the right column for the input to be specified in the code for the
173 given input file type(s) specified when the tool is generated ::
174
175 # use p.adjust - assumes a HEADER row and column 1 - please fix for any real use
176 column = 1 # adjust if necessary for some other kind of input
177 ourargs = commandArgs(TRUE)
178 inf = ourargs[1]
179 outf = ourargs[2]
180 inp = read.table(inf,head=T,row.names=NULL,sep='\t')
181 p = inp[,column]
182 q = p.adjust(p,method='BH')
183 outp = cbind(inp,'BH Adjusted p-value'=q)
184 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=T)
185
186
187 A demonstration Rscript example takes no input file but generates some random data based pdf images
188 You must make sure the option to create an HTML output file is
189 turned on for this to work. Images (pdf) are linked via thumbnails and
190 all files have a link on the resulting HTML page::
191
192 # note this script takes NO input or output because it generates random data
193 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
194 bar = as.matrix(foo)
195 pdf( "heattest.pdf" )
196 heatmap(bar,main='Random Heatmap')
197 dev.off()
198 for (i in 1:49) {
199 foo = runif(100)
200 bar = rnorm(100)
201 pdf(paste('yet',i,"anotherplot.pdf",sep='_'))
202 plot(foo,bar,main=paste("Foo by Bar plot #",i),col="maroon", pch=3,cex=0.6)
203 dev.off()
204 }
205
206 A Python example that reverses each row of a tabular file (you'll need to remove the leading spaces
207 for this to work if cut and pasted into the script box)::
208
209 # reverse order of columns in a tabular file
210 import sys
211 inp = sys.argv[1]
212 outp = sys.argv[2]
213 i = open(inp,'r')
214 o = open(outp,'w')
215 for row in i:
216 rs = row.rstrip().split('\t')
217 rs.reverse()
218 o.write('\t'.join(rs))
219 o.write('\n')
220 i.close()
221 o.close()
222
223 A trivial shell script example to show that it works::
224
225 #!/bin/bash
226 INF=$1
227 OUTF=$2
228 cut -c2,4,6,8,10,12 $INF > $OUTF
229
230 A trivial perl script example to show that even perl works::
231
232 #
233 # change all occurances of a string in a file to another string
234 #
235 $oldfile = $ARGV[0];
236 $newfile = $ARGV[1];
237 $old = "gene";
238 $new = "foo";
239 open(OF, $oldfile);
240 open(NF, ">$newfile");
241 # read in each line of the file
242 while ($line = <OF>) {
243 $line =~ s/$old/$new/;
244 print NF $line;
245 }
246 close(OF);
247 close(NF);
248
249 ]]>
250
251 **Citation**
252
253
254 Paper_ :
255
256 Creating re-usable tools from scripts: The Galaxy Tool Factory
257 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team
258 Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573
259
260
261 **Licensing**
262
263 Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012
264 All rights reserved.
265 Licensed under the LGPL_
266
267 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
268 .. _GTF: https://bitbucket.org/fubar/galaxytoolfactory
269 .. _GTFI: https://bitbucket.org/fubar/galaxytoolfactory/issues
270 .. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&amp;keytype=ref
271
272
273 </help>
274
275 </tool>
276
277