comparison toolfactory/rgToolFactory2.xml @ 28:ad564ab3cf7b draft

Uploaded
author fubar
date Fri, 31 Jul 2020 23:00:31 -0400
parents
children
comparison
equal deleted inserted replaced
27:c4e3cf28545f 28:ad564ab3cf7b
1 <tool id="rgTF2" name="toolfactory" version="2.00">
2 <description>Scripts into tools</description>
3 <macros>
4 <xml name="addpar">
5 <param name="edit_params" type="select" display="radio" label="Add all additional parameters to the generated tool form so they are user editable?"
6 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">
7 <option value="yes">Yes, allow user to edit all additional parameters on the generated tool form</option>
8 <option value="no" selected="true">No - use the fixed values for all additional parameters - no user editing</option>
9 </param>
10 <repeat name="additional_history_inputs" title="Additional Current history data files to pass in to the script - Use the '+' button to add as many as needed"
11 help="Each of these will become a history item selector as input for users of the new tool you are making">
12 <param name="input_files" type="data" format="data" label="Select an input file from your history" optional="true" size="120" multiple="false"
13 help=""/>
14 <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts as input"
15 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml" value="tabular">
16 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
17 <column name="value" index="0"/>
18 </options>
19 </param>
20 <param name="param_label" type="text" value="" label="This will become the user prompt for the form so please make it informative" size="60"
21 help="Note that '~~~' is an internal delimiter so must not appear in this text field - please work around this technical limitation" >
22 <sanitizer invalid_char="">
23 <valid initial="string.printable"> <remove value='~~~'/> </valid>
24 <mapping initial="none"/>
25 </sanitizer>
26 </param>
27 <param name="param_help" type="text" value="parameter_help" label="This will become help text on the form."
28 help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation" size="60">
29 <sanitizer invalid_char="">
30 <valid initial="string.printable"> <remove value='~~~'/> </valid>
31 <mapping initial="none"/>
32 </sanitizer>
33 </param>
34 <param name="CL" type="text" size="60" label="Positional: ordinal integer. Argparse: argument name."
35 help="If you will pass positional parameters, enter the integer ordinal for this parameter. If Argparse style, '--' will be prepended or '-' if single character" value="">
36 </param>
37 </repeat>
38 <repeat name="additional_parameters" title="Pass additional parameters to the script"
39 help="See examples below to see how these can be parsed by scripts in the various languages">
40 <param name="param_name" type="text" value="parameter_name" label="Choose the name for this parameter" size="60">
41 <sanitizer invalid_char="">
42 <valid initial="string.letters,string.digits"/>
43 <mapping initial="none"/>
44 </sanitizer>
45 </param>
46 <param name="param_type" type="select" label="Select the type for this parameter">
47 <option value="text" selected="true">text</option>
48 <option value="integer">integer</option>
49 <option value="float">float</option>
50 </param>
51 <param name="param_value" type="text" value="parameter_value" label="Enter this parameter's default value" size="60"
52 help="Note that '~~~' is an internal delimiter must not appear in this text field - please work around this technical limitation" >
53 <sanitizer invalid_char="">
54 <valid initial="string.printable"> <remove value='~~~'/> </valid>
55 <mapping initial="none"/>
56 </sanitizer>
57 </param>
58 <param name="param_label" type="text" value="parameter_label" label="Enter this parameter's label for the form" size="60"
59 help="Note that '~~~' is an internal delimiter so must not appear in this text field - please work around this technical limitation" >
60 <sanitizer invalid_char="">
61 <valid initial="string.printable"> <remove value='~~~'/> </valid>
62 <mapping initial="none"/>
63 </sanitizer>
64 </param>
65 <param name="param_help" type="text" value="parameter_help" label="Help for this parameter"
66 help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation" size="60">
67 <sanitizer invalid_char="">
68 <valid initial="string.printable"> <remove value='~~~'/> </valid>
69 <mapping initial="none"/>
70 </sanitizer>
71 </param>
72 <param name="CL" type="text" size="60" label="Positional order (must be integer > 1) or Argument name to be prefixed with '--' or '-' if single letter"
73 help="Using positional parameters, enter the integer ordinal for this parameter on the command line. Using Argparse style, '--' will be prepended on the CL" value="">
74 </param>
75 </repeat>
76 </xml>
77 <xml name="builtin_dynpar">
78 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="20x120"
79 help="If there are parameters, either positional or argparse style, the script must parse and use them appropriately">
80 <sanitizer>
81 <valid initial="string.printable">
82 </valid>
83 <mapping initial="none"/>
84 </sanitizer>
85 </param>
86 </xml>
87 <xml name="dynpar">
88 <param name="interpreter_version" type="text" value="" label="Specific script interpreter version to match dependency (Conda) repositories - e.g. for python '3.8.5' Latest if empty" size="60"/>
89 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="20x120"
90 help="If there are parameters, either positional or argparse style, the script must parse and use them appropriately">
91 <sanitizer>
92 <valid initial="string.printable">
93 </valid>
94 <mapping initial="none"/>
95 </sanitizer>
96 </param>
97 </xml>
98 </macros>
99 <requirements>
100 <requirement type="package">python</requirement>
101 <requirement type="package">galaxyxml</requirement>
102 </requirements>
103 <command interpreter="python"><![CDATA[
104 #import os
105 #set dev_env = os.environ.get('GALAXY_DEVELOPMENT_ENVIRONMENT', '0') == '1'
106 #if not $dev_env and ( $__user_email__ not in $__admin_users__ ):
107 $__tool_directory__/rgToolFactory2.py --bad_user $__user_email__
108 #else:
109 $__tool_directory__/rgToolFactory2.py --script_path "$runme"
110 #if str($interexe.interpreter)=="Executable":
111 --exe_package="$interexe.exe_package" --exe_package_version="$interexe.exe_package_version"
112 #else:
113 --interpreter_name="$interexe.interpreter"
114 #if not str($interexe.interpreter) in ['bash','sh']:
115 --interpreter_version="$interexe.interpreter_version"
116 #end if
117 #end if
118 --tool_name="$tool_name" --user_email="$__user_email__" --citations="$citeme" --parampass="$ppass.parampass"
119 --output_tab="$output1" --output_format="$output_format" --output_cl="$output_CL"
120 #if str($makeMode.make_Tool)=="yes":
121 --make_Tool="$makeMode.make_Tool"
122 --tool_desc="$makeMode.tool_desc"
123 --tool_version="$makeMode.tool_version"
124 --new_tool="$new_tool"
125 --help_text="$helpme"
126 #end if
127 #if $ppass.parampass != '0':
128 #if str($ppass.edit_params) == "yes":
129 --edit_additional_parameters
130 #end if
131 #for i in $ppass.additional_parameters:
132 --additional_parameters="$i.param_name~~~$i.param_value~~~$i.param_label~~~$i.param_help~~~$i.param_type~~~$i.CL"
133 #end for
134 #end if
135 --output_dir="."
136 #if str($input_files) != '':
137 --input_files="$input_files~~~$input_CL~~~$input_formats~~~$input_label~~~$input_help"
138 #end if
139 #if $ppass.parampass != '0' and $ppass.additional_history_inputs:
140 #for $intab in $ppass.additional_history_inputs:
141 --input_files="$intab.input_files~~~$intab.CL~~~$intab.input_formats~~~$intab.param_label~~~$intab.param_help"
142 #end for
143 #end if
144 #end if
145 ]]></command>
146 <configfiles>
147 <configfile name="runme">
148 #if $interexe.interpreter != "Executable":
149 ${interexe.dynScript}
150 #else
151 "Not used"
152 #end if
153 </configfile>
154 <configfile name="helpme">
155 #if $makeMode.make_Tool == "yes":
156 ${makeMode.help_text}
157 #end if
158 </configfile>
159 <configfile name="citeme">
160 #if $makeMode.make_Tool == "yes":
161 #for $citation in $makeMode.citations:
162 #if $citation.citation_type.type == "bibtex":
163 **ENTRY**bibtex
164 ${citation.citation_type.bibtex}
165 #else
166 **ENTRY**doi
167 ${citation.citation_type.doi}
168 #end if
169 #end for
170 #end if
171 </configfile>
172 </configfiles>
173 <inputs>
174
175 <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60"
176 help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">
177 <sanitizer invalid_char="">
178 <valid initial="string.letters,string.digits">
179 <add value="_"/>
180 </valid>
181 </sanitizer>
182 </param>
183 <param name="input_files" format="data" type="data" label="Select a small test input file" optional="true" size="120" multiple="false"
184 help="This will be used to test the new tool to generate a built in test for the generated tool"/>
185 <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts for this input"
186 help="If not listed here, datatypes can be added in galaxy's datatypes_conf.xml." value="tabular">
187 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
188 <column name="value" index="0"/>
189 </options>
190 </param>
191 <param name="input_label" type="text" value="parameter_label" label="Data input user prompt on the generated tool form" size="60"
192 help="Describe the input file so the user can understand how it will be used" >
193 <sanitizer invalid_char="">
194 <valid initial="string.printable"> <remove value='~~~'/> </valid>
195 <mapping initial="none"/>
196 </sanitizer>
197 </param>
198 <param name="input_help" type="text" value="parameter_help" label="Data input user help on the generated tool form"
199 help="Enter text to appear as help for the user on the generated tool form" size="60">
200 <sanitizer invalid_char="">
201 <valid initial="string.printable"> <remove value='~~~'/> </valid>
202 <mapping initial="none"/>
203 </sanitizer>
204 </param>
205 <param name="input_CL" type="text" size="60" label="Positional order (must be integer > 1) or Argument name to be prefixed with '--'. Use 'STDIN' if your script reads from STDIN"
206 help="If you will pass positional parameters, enter the integer index for this parameter on the command line. If Argparse style, '--' will be prepended on the CL" value="">
207 </param>
208 <param name="output_format" type="select" multiple="false" label="Select the Galaxy datatype that your tool/script emits as output for the new history item"
209 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml" value="tabular">
210 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
211 <column name="value" index="0"/>
212 </options>
213 </param>
214 <param name="output_CL" type="text" size="60" label="Positional order (must be integer > 1) or Argument name to be prefixed with '--'. Use 'STDOUT' if your script writes to stdout"
215 help="If you will pass positional parameters, enter the integer index for this parameter on the command line. If Argparse style, '--' will be prepended on the CL" value="">
216 </param>
217 <conditional name="interexe">
218 <param name="interpreter" type="select" label="For binaries, choose 'Executable'. Otherwise choose the interpreter for your code"
219 help = "If executable, the supplied package will become a requirement so must match the tool dependency resolver package name - conda is the default.">
220 <option value="Executable" selected="true">An executable binary to be provided and managed by the Conda dependency management subsystem</option>
221 <option value="python">python</option>
222 <option value="r-base">Rscript</option>
223 <option value="perl">perl</option>
224 <option value="bash">bash</option>
225 <option value="sh">sh</option>
226 </param>
227 <when value="Executable">
228 <param name="exe_package" type="text" value="" label="Executable package name in dependency (Conda) repositories - e.g. 'bwa'" size="60" optional="false"/>
229 <param name="exe_package_version" type="text" value="" label="Executable package version to match dependency (Conda) repositories - e.g. for bwa='0.7.17'. Latest if empty" size="60"/>
230 </when>
231 <when value = "python">
232 <expand macro="dynpar" />
233 </when>
234 <when value = "r-base">
235 <expand macro="dynpar" />
236 </when>
237 <when value = "perl">
238 <expand macro="dynpar" />
239 </when>
240 <when value = "bash">
241 <expand macro="builtin_dynpar" />
242 </when>
243 <when value = "sh">
244 <expand macro="builtin_dynpar" />
245 </when>
246 </conditional>
247 <conditional name="ppass">
248 <param name="parampass" type="select" display="radio" label="Command line parameter passing method to use">
249 <option value="argparse" selected="true">Argparse style: on CL in the form of --inputbam="foo.bam" if label below is "inputbam"</option>
250 <option value="positional">Positional: on CL in the order defined on this screen -> "... foo.bam bar.idx zot.xls"</option>
251 <option value="0">No parameters needed because tool reads selected history file from STDIN and writes to STDOUT for history"</option>
252 </param>
253 <when value="0">
254 </when>
255 <when value = "argparse">
256 <expand macro="addpar" />
257 </when>
258 <when value = "positional">
259 <expand macro="addpar" />
260 </when>
261 </conditional>
262 <conditional name="makeMode">
263 <param name="make_Tool" type="select" display="radio" label="Generate new tool as a tar.gz file ready to upload to a toolshed repository"
264 help="Generate a toolshed archive - upload to a toolshed from where it can be auto-installed via the Galaxy admin functions"
265 size="60">
266 <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option>
267 <option value="" selected="true">No. Just run the script please</option>
268 </param>
269 <when value = "yes">
270 <param name="tool_version" label="Tool Version - bump this to warn users trying to redo old analyses" type="text" value="0.01"
271 help="If you change your script and regenerate the 'same' tool, you should inform Galaxy (and users) by changing (bumping is traditional) this number"/>
272 <param name="tool_desc" label="Tool Description" type="text" value="" size="40"
273 help="Supply a brief tool description for the Galaxy tool menu entry (optional - appears after the tool name)" />
274 <param name="help_text" label="Tool form documentation and help text for users" type="text" area="true"
275 size="8x120" value="**What it Does**"
276 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" >
277 <sanitizer>
278 <valid initial="string.printable">
279 </valid>
280 <mapping initial="none"/>
281 </sanitizer>
282 </param>
283 <repeat name="citations" title="Citation">
284 <conditional name="citation_type">
285 <param name="type" type="select" display="radio" label="Citation Type">
286 <option value="doi">DOI</option>
287 <option value="bibtex">BibTeX</option>
288 </param>
289 <when value="doi">
290 <param name="doi" label="DOI" type="text" value=""
291 help="Supply a DOI (e.g. doi: 10.1111/j.1740-9713.2007.00258.x) that should be cited when this tool is used in published research." />
292 </when>
293 <when value="bibtex">
294 <param name="bibtex" label="BibTex" type="text" area="true" size="8x120"
295 help="Supply a BibTex entry that should be cited when this tool is used in published research." value="" >
296 <sanitizer>
297 <valid initial="string.printable">
298 </valid>
299 <mapping initial="none"/>
300 </sanitizer>
301 </param>
302 </when>
303 </conditional>
304 </repeat>
305 </when>
306 <when value = "">
307 </when>
308 </conditional>
309 </inputs>
310 <outputs>
311 <data name="output1" label="${tool_name}.${output_format}" format="tabular" metadata_source="input_file">
312 <actions>
313 <action type="format">
314 <option type="from_param" name="output_format" />
315 </action>
316 </actions>
317 </data>
318 <data format="toolshed.gz" name="new_tool" label="${tool_name}.toolshed.gz">
319 <filter>makeMode['make_Tool'] == "yes"</filter>
320 </data>
321 </outputs>
322
323 <tests>
324 <test>
325 <param name='input_files' value='infile.tabular' ftype='tabular' />
326 <param name='script_path' value='runme.py' />
327 <param name='tool_name' value='reverseargp2_test1' />
328 <param name='make_Tool' value='yes' />
329 <param name='tool_version' value='0.01' />
330 <param name="tool_desc" value='testing_tf2' />
331 <param name="help_text" value='help text goes here' />
332 <param name="output_format" value="tabular" />
333 <param name="input_formats" value="tabular" />
334 <param name="interpreter" value='python' />
335 <output name='output1' file='reverseargp2_test1_output.xls' compare='diff' lines_diff = '10'/>
336 <output name='new_tool' file="reverseargp2.toolshed.gz" compare="sim_size" delta="600" />
337 </test>
338 </tests>
339 <help>
340
341 .. class:: warningmark
342
343 **Details and attribution**
344 (see GTF_)
345
346 **Local Admins ONLY**
347 Only users whose IDs found in the local admin_user configuration setting in universe_wsgi.ini can run this tool.
348
349 **If you find a bug**
350 Please raise an issue at the bitbucket repository GTFI_
351
352 **What it does**
353 This tool optionally generates normal workflow compatible first class Galaxy tools
354
355 Generated tools can run existing binary packages that become requirements, existing scripts, or new scripts pasted into this tool form.
356 Pasted scripts are written so they are part of the new tool and cannot be adjusted by the downstream user.
357 Binary packages are managed by the dependency subsystem - conda usually, so anything in bioconda or conda_forge is available for example.
358
359 Any number of parameters can be built into the new tool form for passing in to the script or executable at runtime.
360 These can be editable by the downstream user or baked in.
361
362 When you run this tool, your executable or script and supplied parameter values will be run to produce a canonical
363 set of outputs - these are used to construct a test for the new tool.
364
365 If tool generation is required, a new tarball compatible with any Galaxy toolshed is created.
366 It can be unpacked in your galaxy/tools directory and manually added to tool_conf.xml, or
367 installed into any toolshed from where it can be installed into your Galaxy.
368
369
370 .. class:: warningmark
371
372 **Note to system administrators**
373 This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.
374 Admin_users will have the power to do anything they want as the Galaxy user if you install this tool.
375
376 .. class:: warningmark
377
378 **Use on public servers** is STRONGLY discouraged for obvious reasons
379
380 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.
381 We recommend that you follow the good code hygiene practices associated with safe toolshed practices.
382
383 Here's a sample python script that can be cut and pasted into the tool form, suitable for positional parameter passing:
384
385 ::
386
387 # reverse order of text by row
388 import sys
389 inp = sys.argv[1]
390 outp = sys.argv[2]
391 i = open(inp,'r').readlines()
392 o = open(outp,'w')
393 for row in i:
394 rs = row.rstrip()
395 rs = list(rs)
396 rs.reverse()
397 o.write(''.join(rs))
398 o.write('\n')
399 o.close()
400
401 With argparse style parameters:
402
403 ::
404
405 # reverse order of text by row
406 import argparse
407 parser = argparse.ArgumentParser()
408 a = parser.add_argument
409 a('--infile',default='')
410 a('--outfile',default=None)
411 args = parser.parse_args()
412 inp = args.infile
413 outp = args.outfile
414 i = open(inp,'r').readlines()
415 o = open(outp,'w')
416 for row in i:
417 rs = row.rstrip()
418 rs = list(rs)
419 rs.reverse()
420 o.write(''.join(rs))
421 o.write('\n')
422 o.close()
423
424
425 Paper_ :
426
427 Creating re-usable tools from scripts: The Galaxy Tool Factory
428 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team
429 Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573
430
431 **Licensing**
432
433 Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012
434 All rights reserved.
435 Licensed under the LGPL_
436
437 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
438 .. _GTF: https://bitbucket.org/fubar/galaxytoolfactory
439 .. _GTFI: https://bitbucket.org/fubar/galaxytoolfactory/issues
440 .. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573
441
442
443 </help>
444 <citations>
445 <citation type="doi">10.1093/bioinformatics/bts573</citation>
446 </citations>
447 </tool>
448
449