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