comparison rgToolFactory.xml @ 22:4e3aa95ed3ac draft

Uploaded
author fubar
date Mon, 02 Mar 2015 05:14:05 -0500
parents
children
comparison
equal deleted inserted replaced
21:71b85c322600 22:4e3aa95ed3ac
1 <tool id="rgTF" name="Tool Factory" version="1.12">
2 <description>Makes scripts into tools</description>
3 <requirements>
4 <requirement type="package" version="9.10">ghostscript</requirement>
5 <requirement type="package" version="1.3.20">graphicsmagick</requirement>
6 </requirements>
7 <command interpreter="python">
8 #if ( $__user_email__ not in $__admin_users__ ):
9 rgToolFactory.py --bad_user $__user_email__
10 #else:
11 rgToolFactory.py --script_path "$runme" --interpreter "$interpreter"
12 --tool_name "$tool_name" --user_email "$__user_email__"
13 #if str($make_TAB)=="yes":
14 --output_tab "$tab_file"
15 --output_format "$output_format"
16 #end if
17 #if str($makeMode.make_Tool) == "yes":
18 --make_Tool "yes"
19 --tool_desc "$makeMode.tool_desc"
20 --tool_version "$makeMode.tool_version"
21 --new_tool "$new_tool"
22 --help_text "$helpme"
23 --citations "$citeme"
24 --include_dependencies "yes"
25 #end if
26
27 #if str($make_HTML)=="yes":
28 --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes"
29 #else:
30 --output_dir "."
31 #end if
32 #if str($input1) != 'None':
33 --input_tab "$input1"
34 --input_formats "$input_formats"
35 #end if
36 #end if
37 </command>
38 <inputs>
39 <param name="input1" type="data" label="Select an input file from your history" optional="true" size="120"
40 help="Most scripts will need an input - your script MUST be ready for whatever format you choose"/>
41 <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts as input"
42 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
43 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
44 <column name="value" index="0"/>
45 </options>
46 </param>
47 <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60"
48 help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">
49 <sanitizer invalid_char="">
50 <valid initial="string.letters,string.digits"/>
51 </sanitizer>
52 </param>
53 <conditional name="makeMode">
54 <param name="make_Tool" type="select" label="Create a tar.gz file ready for local toolshed entry" help="Ready to deploy securely!" size="60">
55 <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option>
56 <option value="" selected="true">No. Just run the script please</option>
57 </param>
58 <when value = "yes">
59 <param name="tool_version" label="Tool Version - bump this to warn users trying to redo old analyses" type="text" value="0.01"
60 help="If you change your script and regenerate the 'same' tool, you should inform Galaxy (and users) by changing (bumping is traditional) this number"/>
61 <param name="tool_desc" label="Tool Description" type="text" value="" size="40"
62 help="Supply a brief tool description for the Galaxy tool menu entry (optional - appears after the tool name)" />
63 <param name="help_text" label="Tool form documentation and help text for users" type="text" area="true"
64 size="8x120" value="**What it Does**"
65 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" >
66 <sanitizer>
67 <valid initial="string.printable"/>
68 <mapping initial="none"/>
69 </sanitizer>
70 </param>
71 <param name="include_deps" type="select" label="Include ghostscript and graphicsmagick dependencies in generated tool" size="60"
72 help="If an HTML file is being created, including dependencies is recommended. Otherwise this setting has no effect">
73 <option value="">Rely on system ghostscript and graphicsmagick rather than include these as dependencies</option>
74 <option value="yes" selected="true">Include dependencies so target installations will always work if HTML is being generated</option>
75 </param>
76 <repeat name="citations" title="Citation">
77 <conditional name="citation_type">
78 <param name="type" type="select" label="Citation Type">
79 <option value="doi">DOI</option>
80 <option value="bibtex">BibTeX</option>
81 </param>
82 <when value="doi">
83 <param name="doi" label="DOI" type="text" value=""
84 help="Supply a DOI (e.g. 10.1111/j.1740-9713.2007.00258.x) that should be cited when this tool is used in published research." />
85 </when>
86 <when value="bibtex">
87 <param name="bibtex" label="BibTex" type="text" area="true" size="8x120"
88 help="Supply a BibTex entry that should be cited when this tool is used in published research." value="" >
89 <sanitizer>
90 <valid initial="string.printable"/>
91 <mapping initial="none"/>
92 </sanitizer>
93 </param>
94 </when>
95 </conditional>
96 </repeat>
97 </when>
98 <when value = "">
99 </when>
100 </conditional>
101 <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"
102 help="Recommended for presenting complex outputs in an accessible manner. Turn off for simple tools so they just create one output">
103 <option value="yes">Yes, arrange all outputs produced by my script as an HTML output</option>
104 <option value="" selected="true">No, no HTML output file thanks</option>
105 </param>
106 <param name="make_TAB" type="select" label="Create a new (default tabular) history output with or without an HTML file specified above"
107 help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes">
108 <option value="yes" selected="true">My script writes to a new history output</option>
109 <option value="">I do not want a new history output file</option>
110 </param>
111 <param name="output_format" type="select" label="Select the datatype for the file your tool/script will write"
112 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
113 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
114 <column name="value" index="0"/>
115 </options>
116 </param>
117 <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host">
118 <option value="Rscript" selected="true">Rscript</option>
119 <option value="python">python</option>
120 <option value="perl">perl</option>
121 <option value="bash">bash</option>
122 <option value="sh">sh</option>
123 </param>
124 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="8x120"
125 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').">
126 <sanitizer>
127 <valid initial="string.printable">
128 </valid>
129 <mapping initial="none"/>
130 </sanitizer>
131 </param>
132 </inputs>
133 <outputs>
134 <data format="input" name="tab_file" label="${tool_name}.${output_format}">
135 <filter>make_TAB == "yes"</filter>
136 <actions>
137 <action type="format">
138 <option type="from_param" name="output_format" />
139 </action>
140 </actions>
141 </data>
142 <data format="html" name="html_file" label="${tool_name}.html">
143 <filter>make_HTML == "yes"</filter>
144 </data>
145 <data format="toolshed.gz" name="new_tool" label="${tool_name}.toolshed.gz">
146 <filter>makeMode['make_Tool'] == "yes"</filter>
147 </data>
148 </outputs>
149 <configfiles>
150 <configfile name="runme">$dynScript</configfile>
151 <configfile name="helpme">
152 #if $makeMode.make_Tool == "yes":
153 $makeMode.help_text
154 #end if
155 </configfile>
156 <configfile name="citeme">
157 #if $makeMode.make_Tool == "yes":
158 #for $citation in $makeMode.citations:
159 #if $citation.citation_type.type == "bibtex":
160 **ENTRY**bibtex
161 ${citation.citation_type.bibtex}
162 #else:
163 **ENTRY**doi
164 ${citation.citation_type.doi}
165 #end if
166 #end for
167 #end if
168 </configfile>
169 </configfiles>
170 <help>
171
172 .. class:: warningmark
173
174 **Details and attribution** GTF_
175
176 **Local Admins ONLY** Only users whose IDs found in the local admin_user configuration setting in universe_wsgi.ini can run this tool.
177
178 **If you find a bug** please raise an issue at the bitbucket repository GTFI_
179
180 **What it does** This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy.
181
182 **Input options** This version is limited to simple transformation or reporting requiring only a single input file selected from the history.
183
184 **Output options** Optional script outputs include one single new history tabular file, or for scripts that create multiple outputs,
185 a new HTML report linking all the files and images created by the script can be automatically generated.
186
187 **Tool Generation option** Once the script is working with test data, this tool will optionally generate a new Galaxy tool in a gzip file
188 ready to upload to your local toolshed for sharing and installation. Provide a small sample input when you run generate the tool because
189 it will become the input for the generated functional test.
190
191 .. class:: warningmark
192
193 **Note to system administrators** This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.
194 Admin_users will have the power to do anything they want as the Galaxy user if you install this tool.
195
196 .. class:: warningmark
197
198 **Use on public servers** is STRONGLY discouraged for obvious reasons
199
200 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.
201 We recommend that you follow the good code hygiene practices associated with safe toolshed.
202
203 **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
204 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.
205 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.
206 This can be handy for complex scripts creating lots of output.
207
208 **Examples**
209
210 <![CDATA[
211 Each of these following trivial examples can be cut and pasted into the script box for testing.
212 Please make sure you choose the appropriate interpreter and upload and select a suitable small matching test data input
213
214 A simple Rscript "filter" showing how the command line parameters can be handled, takes an input file, does something (transpose in this case) and
215 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
216 as a string::
217
218 # transpose a tabular input file and write as a tabular output file
219 ourargs = commandArgs(TRUE)
220 inf = ourargs[1]
221 outf = ourargs[2]
222 inp = read.table(inf,head=F,row.names=NULL,sep='\t',colClasses="character")
223 outp = t(inp)
224 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F)
225
226 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
227 given input file type(s) specified when the tool is generated ::
228
229 # use p.adjust - assumes a HEADER row and column 1 - please fix for any real use
230 column = 1 # adjust if necessary for some other kind of input
231 ourargs = commandArgs(TRUE)
232 inf = ourargs[1]
233 outf = ourargs[2]
234 inp = read.table(inf,head=T,row.names=NULL,sep='\t')
235 p = inp[,column]
236 q = p.adjust(p,method='BH')
237 outp = cbind(inp,'BH Adjusted p-value'=q)
238 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=T)
239
240
241 A demonstration Rscript example takes no input file but generates some random data based pdf images
242 You must make sure the option to create an HTML output file is
243 turned on for this to work. Images (pdf) are linked via thumbnails and
244 all files have a link on the resulting HTML page::
245
246 # note this script takes NO input or output because it generates random data
247 for (i in 1:10) {
248 foo = runif(100)
249 bar = rnorm(100)
250 bar = foo + 0.05*bar
251 pdf(paste('yet',i,"anotherplot.pdf",sep='_'))
252 plot(foo,bar,main=paste("Foo by Bar plot #",i),col="maroon", pch=3,cex=0.6)
253 dev.off()
254 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
255 bar = as.matrix(foo)
256 pdf(paste('yet',i,"anotherheatmap.pdf",sep='_'))
257 heatmap(bar,main='Random Heatmap')
258 dev.off()
259 }
260
261 A slight variation taking an input tabular file from which we read the first number as nreps::
262
263 # note this script takes a single parameter
264 # number of replicates
265 ourargs = commandArgs(TRUE)
266 infname = ourargs[1]
267 nreps = read.table(infname,head=F)
268 nreps = unlist(nreps)[1]
269 nreps = max(c(1,nreps))
270 nreps = min(c(20,nreps))
271 print(paste("Using nreps=",nreps))
272 for (i in 1:nreps) {
273 foo = runif(100)
274 bar = rnorm(100)
275 bar = foo + 0.2*bar
276 pdf(paste("yet",i,"anotherplot.pdf",sep="_"))
277 plot(foo,bar,main=paste("Foo by Bar plot ",i),col="maroon", pch=3,cex=0.6)
278 dev.off()
279 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
280 bar = as.matrix(foo)
281 pdf(paste("yet",i,"anotherheatmap.pdf",sep="_"))
282 heatmap(bar,main="Random Heatmap")
283 dev.off()
284 }
285
286 A Python example that reverses each row of a tabular file (you'll need to remove the leading spaces
287 for this to work if cut and pasted into the script box)::
288
289 # reverse order of columns in a tabular file
290 import sys
291 inp = sys.argv[1]
292 outp = sys.argv[2]
293 i = open(inp,'r')
294 o = open(outp,'w')
295 for row in i:
296 rs = row.rstrip().split('\t')
297 rs.reverse()
298 o.write('\t'.join(rs))
299 o.write('\n')
300 i.close()
301 o.close()
302
303 A trivial shell script example to show that it works::
304
305 #!/bin/bash
306 INF=$1
307 OUTF=$2
308 cut -c2,4,6,8,10,12 $INF > $OUTF
309
310 A trivial perl script example to show that even perl works::
311
312 #
313 # change all occurances of a string in a file to another string
314 #
315 $oldfile = $ARGV[0];
316 $newfile = $ARGV[1];
317 $old = "gene";
318 $new = "foo";
319 open(OF, $oldfile);
320 open(NF, ">$newfile");
321 # read in each line of the file
322 while ($line = <OF>) {
323 $line =~ s/$old/$new/;
324 print NF $line;
325 }
326 close(OF);
327 close(NF);
328
329 ]]>
330
331
332 **Citation**
333
334
335 Paper_ :
336
337 Creating re-usable tools from scripts: The Galaxy Tool Factory
338 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team
339 Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573
340
341
342 **Licensing**
343
344 Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012
345 All rights reserved.
346 Licensed under the LGPL_
347
348 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
349 .. _GTF: https://bitbucket.org/fubar/galaxytoolfactory
350 .. _GTFI: https://bitbucket.org/fubar/galaxytoolfactory/issues
351 .. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&amp;keytype=ref
352
353
354 </help>
355 <citations>
356 <citation type="doi">10.1093/bioinformatics/bts573</citation>
357 </citations>
358 </tool>
359
360