comparison rgToolFactory2.xml @ 0:c34063ab3735 draft

Initial commit of code in iuc github repository
author fubar
date Thu, 01 Jan 2015 21:58:00 -0500
parents
children 323982517b30
comparison
equal deleted inserted replaced
-1:000000000000 0:c34063ab3735
1 <tool id="rgTF2" name="Tool Factory Two" version="1.15">
2 <description>Scripts into tools</description>
3 <requirements>
4 <requirement type="package" version="9.10">ghostscript</requirement>
5 <requirement type="package" version="1.3.18">graphicsmagick</requirement>
6 </requirements>
7 <command interpreter="python">
8 #if ( $__user_email__ not in $__admin_users__ ):
9 rgToolFactory2.py --bad_user $__user_email__
10 #else:
11 rgToolFactory2.py --script_path "$runme" --interpreter "$interpreter"
12 --tool_name "$tool_name" --user_email "$__user_email__" --citations "$citeme"
13
14 #if $make_TAB.value=="yes":
15 --output_tab "$output1"
16 --output_format "$output_format"
17 #end if
18 #if $makeMode.make_Tool=="yes":
19 --make_Tool "$makeMode.make_Tool"
20 --tool_desc "$makeMode.tool_desc"
21 --tool_version "$makeMode.tool_version"
22 --new_tool "$new_tool"
23 --help_text "$helpme"
24 #if $make_HTML.value=="yes":
25 #if $makeMode.include_deps.value=="yes":
26 --include_dependencies "yes"
27 #end if
28 #end if
29 #end if
30 #if $additional_parameters != 'None':
31 #if $edit_params.value == "yes":
32 --edit_additional_parameters
33 #end if
34 #for i in $additional_parameters:
35 --additional_parameters "$i.param_name,$i.param_value,$i.param_label,$i.param_help,$i.param_type"
36 #end for
37 #end if
38 #if $make_HTML.value=="yes":
39 --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes"
40 #else:
41 --output_dir "."
42 #end if
43 #if $input_tab != 'None':
44 --input_formats "$input_formats"
45 #for intab in $input_tab:
46 --input_tab "$intab,$intab.name"
47 #end for
48 #end if
49 #end if
50 </command>
51 <inputs>
52 <param name="input_tab" type="data" label="Select one or more input file(s) from your history" optional="true" size="120" multiple="true"
53 help="Use the multiple input widget (above/right of input box) for multiple inputs - your script MUST be ready to parse the command line right - see samples below"/>
54 <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts as input"
55 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
56 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
57 <column name="value" index="0"/>
58 </options>
59 </param>
60 <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60"
61 help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">
62 <sanitizer invalid_char="">
63 <valid initial="string.letters,string.digits">
64 <add value="_"/>
65 </valid>
66 </sanitizer>
67 </param>
68 <conditional name="makeMode">
69 <param name="make_Tool" type="select" label="Generate new tool as a tar.gz file ready to upload to a toolshed repository"
70 help="Generate a toolshed archive - upload to a toolshed from where it can be auto-installed via the Galaxy admin functions"
71 size="60">
72 <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option>
73 <option value="" selected="true">No. Just run the script please</option>
74 </param>
75 <when value = "yes">
76 <param name="tool_version" label="Tool Version - bump this to warn users trying to redo old analyses" type="text" value="0.01"
77 help="If you change your script and regenerate the 'same' tool, you should inform Galaxy (and users) by changing (bumping is traditional) this number"/>
78 <param name="tool_desc" label="Tool Description" type="text" value="" size="40"
79 help="Supply a brief tool description for the Galaxy tool menu entry (optional - appears after the tool name)" />
80 <param name="help_text" label="Tool form documentation and help text for users" type="text" area="true"
81 size="8x120" value="**What it Does**"
82 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" >
83 <sanitizer>
84 <valid initial="string.printable">
85 </valid>
86 <mapping initial="none"/>
87 </sanitizer>
88 </param>
89 <repeat name="citations" title="Citation">
90 <conditional name="citation_type">
91 <param name="type" type="select" label="Citation Type">
92 <option value="doi">DOI</option>
93 <option value="bibtex">BibTeX</option>
94 </param>
95 <when value="doi">
96 <param name="doi" label="DOI" type="text" value=""
97 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." />
98 </when>
99 <when value="bibtex">
100 <param name="bibtex" label="BibTex" type="text" area="true" size="8x120"
101 help="Supply a BibTex entry that should be cited when this tool is used in published research." value="" >
102 <sanitizer>
103 <valid initial="string.printable">
104 </valid>
105 <mapping initial="none"/>
106 </sanitizer>
107 </param>
108 </when>
109 </conditional>
110 </repeat>
111 <param name="include_deps" type="select" label="Include ghostscript and graphicsmagick dependencies in generated tool" size="60"
112 help="If an HTML file is being created, including dependencies is recommended. Otherwise this setting has no effect">
113 <option value="">Rely on system ghostscript and graphicsmagick rather than include these as dependencies</option>
114 <option value="yes" selected="true">Include dependencies so target installations will always work if HTML is being generated</option>
115 </param>
116 </when>
117 <when value = "">
118 </when>
119 </conditional>
120 <param name="make_HTML" type="select" label="Create an HTML report with links to every output file your script writes to the current directory" size="60"
121 help="Recommended for presenting complex outputs in an accessible manner. Turn off for simple tools so they just create one output">
122 <option value="yes">Yes, arrange and link all output files written by my script to the current directory as an HTML page</option>
123 <option value="" selected="true">No, no HTML output file thanks</option>
124 </param>
125 <param name="make_TAB" type="select" label="Create a new (default tabular) history output with or without an HTML file specified above"
126 help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes">
127 <option value="yes" selected="true">My script writes to a new history output</option>
128 <option value="">I do not want a new history output file</option>
129 </param>
130 <param name="output_format" type="select" multiple="false" label="Select the datatype that your tool/script emits as output"
131 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
132 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
133 <column name="value" index="0"/>
134 </options>
135 </param>
136 <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host">
137 <option value="Rscript" selected="true">Rscript</option>
138 <option value="python">python</option>
139 <option value="perl">perl</option>
140 <option value="bash">bash</option>
141 <option value="sh">sh</option>
142 </param>
143 <param name="edit_params" type="select" label="Add all additional parameters to the generated tool form so they are user editable?"
144 help="If no (default), users will NOT be able to alter any additional parameters. If yes, these will appear on the tool form as text fields with no validation or sanitizing">
145 <option value="yes">Yes, allow user to edit all additional parameters on the generated tool form</option>
146 <option value="no" selected="true">No - use the fixed values for all additional parameters - no user editing</option>
147 </param>
148 <repeat name="additional_parameters" title="Pass additional parameters to the script"
149 help="See examples below to see how these can be parsed by scripts in the various languages">
150 <param name="param_name" type="text" value="parameter_name" label="Choose the name for this parameter" size="60">
151 <sanitizer invalid_char="">
152 <valid initial="string.letters,string.digits"/>
153 <mapping initial="none"/>
154 </sanitizer>
155 </param>
156 <param name="param_type" type="select" label="Select the type for this parameter">
157 <option value="text" selected="true">text</option>
158 <option value="integer">integer</option>
159 <option value="float">float</option>
160 <option value="file">file</option>
161 <option value="library_data">library_data</option>
162 </param>
163 <param name="param_value" type="text" value="parameter_value" label="Enter this parameter's default value" size="60"
164 help="Note that commas and double quotes cannot be used in this text field - please work around this technical limitation" >
165 <sanitizer invalid_char="">
166 <valid initial="string.printable"> <remove value=','/> <remove value='"'/> </valid>
167 <mapping initial="none"/>
168 </sanitizer>
169 </param>
170 <param name="param_label" type="text" value="parameter_label" label="Enter this parameter's label for the form" size="60"
171 help="Note that commas and double quotes cannot be used in this text field - please creatively work around this technical limitation" >
172 <sanitizer invalid_char="">
173 <valid initial="string.printable"> <remove value=','/> <remove value='"'/> </valid>
174 <mapping initial="none"/>
175 </sanitizer>
176 </param>
177 <param name="param_help" type="text" value="parameter_help" label="Help for this parameter"
178 help="Note that commas and double quotes cannot be used in this text field - please work around this technical limitation" size="60">
179 <sanitizer invalid_char="">
180 <valid initial="string.printable"> <remove value=','/> <remove value='"'/> </valid>
181 <mapping initial="none"/>
182 </sanitizer>
183 </param>
184 </repeat>
185 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="20x120"
186 help="Script must deal with three command line parameters: please cut and paste from examples below for the appropriate scripting language">
187 <sanitizer>
188 <valid initial="string.printable">
189 </valid>
190 <mapping initial="none"/>
191 </sanitizer>
192 </param>
193 </inputs>
194 <outputs>
195 <data name="output1" label="${tool_name}.${output_format}" format="tabular" metadata_source="input_tab">
196 <filter>make_TAB=="yes"</filter>
197 <actions>
198 <action type="format">
199 <option type="from_param" name="output_format" />
200 </action>
201 </actions>
202 </data>
203 <data format="html" name="html_file" label="${tool_name}.html">
204 <filter>make_HTML == "yes"</filter>
205 </data>
206 <data format="toolshed.gz" name="new_tool" label="${tool_name}.toolshed.gz">
207 <filter>makeMode['make_Tool'] == "yes"</filter>
208 </data>
209 </outputs>
210 <configfiles>
211 <configfile name="runme">$dynScript</configfile>
212 <configfile name="helpme">
213 #if $makeMode.make_Tool == "yes":
214 ${makeMode.help_text}
215 #end if
216 </configfile>
217 <configfile name="citeme">
218 #if $makeMode.make_Tool == "yes":
219 #for $citation in $makeMode.citations:
220 #if $citation.citation_type.type == "bibtex":
221 **ENTRY**bibtex
222 ${citation.citation_type.bibtex}
223 #else
224 **ENTRY**doi
225 ${citation.citation_type.doi}
226 #end if
227 #end for
228 #end if
229 </configfile>
230 </configfiles>
231 <tests>
232 <test>
233 <param name='input_tab' value='tf2_test_in.xls' ftype='tabular' />
234 <param name='tool_name' value='tf2_test' />
235 <param name='make_Tool' value='yes' />
236 <param name='tool_version' value='0.01' />
237 <param name="tool_desc" value='testing_tf2' />
238 <param name="help_text" value='help text goes here' />
239 <param name='include_deps' value='yes' />
240 <param name="make_HTML" value="yes" />
241 <param name="make_TAB" value="yes" />
242 <param name="output_format" value="tabular" />
243 <param name="input_formats" value="tabular" />
244 <param name="interpreter" value='python' />
245 <param name="runme" value="tf2_test_runme.py"/>
246 <output name='output1' file='tf2_test_out.xls' compare='diff' lines_diff = '10'/>
247 <output name='html_file' file="tf2_test.html" compare='diff' lines_diff = '10'/>
248 <output name='new_tool' file="tf2_test.toolshed.gz" compare="sim_size" delta="20" />
249 </test>
250 </tests>
251 <help>
252
253 .. class:: warningmark
254
255 **Details and attribution**
256 (see GTF_)
257
258 **Local Admins ONLY**
259 Only users whose IDs found in the local admin_user configuration setting in universe_wsgi.ini can run this tool.
260
261 **If you find a bug**
262 Please raise an issue at the bitbucket repository GTFI_
263
264 **What it does**
265 This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy passing
266 any number of input files and their metadata names to the script for use in (eg) summaries or reports.
267 This allows quick generation of tools capable of taking some arbitrary number of user selected inputs
268 for the "reduce" step of a map-reduce HPC model.
269
270 **Input options**
271 This version allows multiple input file selected from the history - their paths and metadata names
272 are provided to your script - see the examples below for each scripting language. Python uses argparse.
273 Rscript uses some code to create all the command line variables. Parameters are injected into the bash/sh
274 execution environment so they magically "appear" as $ prefixed variables and will also be found on the
275 command line as parameters to be parsed if that's your preference.
276 Note that additional parameters are NOT presented to the user of the generated tool but are frozen with the script.
277 If there's demand, it would not be too hard to add them to the generated script...
278
279 **Output options**
280 Optional script outputs include one single new history tabular file and for scripts that create multiple file reports
281 or analyses, an Html page linking every file and image created by the script can be automatically generated.
282
283 **Tool Generation option**
284 Once the script is working with test data, this tool will optionally generate a new Galaxy tool in a Tool Shed (gzip) repository file
285 ready to upload to your local toolshed for sharing and installation.
286 Provide a small sample input when you run generate the tool because it will become the input for the generated functional test.
287
288 .. class:: warningmark
289
290 **Note to system administrators**
291 This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.
292 Admin_users will have the power to do anything they want as the Galaxy user if you install this tool.
293
294 .. class:: warningmark
295
296 **Use on public servers** is STRONGLY discouraged for obvious reasons
297
298 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.
299 We recommend that you follow the good code hygiene practices associated with safe toolshed.
300
301 **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
302 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.
303 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.
304 This can be handy for complex scripts creating lots of output.
305
306 <![CDATA[
307
308 **Multiple inputs**
309
310 Your script will receive up to 3 named parameters
311 INPATHS is a comma separated list of input file paths
312 INNAMES is a comma separated list of input file names in the same order
313 OUTPATH is optional if a file is being generated, your script should write there
314 Your script should open and write files in the provided working directory if you are using the Html
315 automatic presentation option.
316
317 Python script command lines will have --INPATHS and --additional_arguments etc. to make it easy to use argparse
318
319 Rscript will need to use commandArgs(TRUE) - see the example below - additional arguments will
320 appear as themselves - eg foo="bar" will mean that foo is defined as "bar" for the script.
321
322 Bash and sh will see any additional parameters on their command lines and the 3 named parameters
323 in their environment magically - well, using env on the CL
324
325 ***python***::
326
327 # argparse for 3 possible comma separated lists
328 # additional parameters need to be parsed !
329 # then echo parameters to the output file
330 import sys
331 import argparse
332 argp=argparse.ArgumentParser()
333 argp.add_argument('--INNAMES',default=None)
334 argp.add_argument('--INPATHS',default=None)
335 argp.add_argument('--OUTPATH',default=None)
336 argp.add_argument('--additional_parameters',default=[],action="append")
337 argp.add_argument('otherargs', nargs=argparse.REMAINDER)
338 args = argp.parse_args()
339 f= open(args.OUTPATH,'w')
340 s = '### args=%s\n' % str(args)
341 f.write(s)
342 s = 'sys.argv=%s\n' % sys.argv
343 f.write(s)
344 f.close()
345
346
347
348 ***Rscript***::
349
350 # tool factory Rscript parser suggested by Forester
351 # http://www.r-bloggers.com/including-arguments-in-r-cmd-batch-mode/
352 # additional parameters will appear in the ls() below - they are available
353 # to your script
354 # echo parameters to the output file
355 ourargs = commandArgs(TRUE)
356 if(length(ourargs)==0){
357 print("No arguments supplied.")
358 }else{
359 for(i in 1:length(ourargs)){
360 eval(parse(text=ourargs[[i]]))
361 }
362 sink(OUTPATH)
363 cat('INPATHS=',INPATHS,'\n')
364 cat('INNAMES=',INNAMES,'\n')
365 cat('OUTPATH=',OUTPATH,'\n')
366 x=ls()
367 cat('all objects=',x,'\n')
368 sink()
369 }
370 sessionInfo()
371 print.noquote(date())
372
373
374 ***bash/sh***::
375
376 # tool factory sets up these environmental variables
377 # this example writes those to the output file
378 # additional params appear on command line
379 if [ ! -f "$OUTPATH" ] ; then
380 touch "$OUTPATH"
381 fi
382 echo "INPATHS=$INPATHS" >> "$OUTPATH"
383 echo "INNAMES=$INNAMES" >> "$OUTPATH"
384 echo "OUTPATH=$OUTPATH" >> "$OUTPATH"
385 echo "CL=$@" >> "$OUTPATH"
386
387 ***perl***::
388
389 (my $INPATHS,my $INNAMES,my $OUTPATH ) = @ARGV;
390 open(my $fh, '>', $OUTPATH) or die "Could not open file '$OUTPATH' $!";
391 print $fh "INPATHS=$INPATHS\n INNAMES=$INNAMES\n OUTPATH=$OUTPATH\n";
392 close $fh;
393
394
395 ]]>
396
397 **Citation**
398
399
400 Paper_ :
401
402 Creating re-usable tools from scripts: The Galaxy Tool Factory
403 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team
404 Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573
405
406
407 **Licensing**
408
409 Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012
410 All rights reserved.
411 Licensed under the LGPL_
412
413 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
414 .. _GTF: https://bitbucket.org/fubar/galaxytoolfactory
415 .. _GTFI: https://bitbucket.org/fubar/galaxytoolfactory/issues
416 .. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&amp;keytype=ref
417
418
419 </help>
420
421 </tool>
422
423