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