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