Mercurial > repos > fubar > toolfactory
comparison rgToolFactory.xml @ 39:64f7bd086146 draft
Uploaded
author | fubar |
---|---|
date | Thu, 28 Aug 2014 03:05:01 -0400 |
parents | |
children | 8603867451d8 |
comparison
equal
deleted
inserted
replaced
38:5bf5c411baf3 | 39:64f7bd086146 |
---|---|
1 <tool id="rgTF" name="Tool Factory" version="1.12"> | |
2 <description>Run a script; make a tool!</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 <command interpreter="python"> | |
8 #if ( $__user_email__ not in $__admin_users__ ): | |
9 rgToolFactory.py --bad_user $__user_email__ | |
10 #else: | |
11 rgToolFactory.py --script_path "$runme" --interpreter "$interpreter" | |
12 --tool_name "$tool_name" --user_email "$__user_email__" | |
13 #if $make_TAB.value=="yes": | |
14 --output_tab "$tab_file" | |
15 #end if | |
16 #if $makeMode.make_Tool=="yes": | |
17 --make_Tool "$makeMode.make_Tool" | |
18 --tool_desc "$makeMode.tool_desc" | |
19 --tool_version "$makeMode.tool_version" | |
20 --new_tool "$new_tool" | |
21 --help_text "$helpme" | |
22 #if $make_HTML.value=="yes": | |
23 #if makeMode.include.deps.value=="yes": | |
24 --include_dependencies "yes" | |
25 #end if | |
26 #end if | |
27 --citations "$citeme" | |
28 #end if | |
29 #if $make_HTML.value=="yes": | |
30 --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes" | |
31 #else: | |
32 --output_dir "." | |
33 #end if | |
34 #if $input1 != 'None': | |
35 --input_tab "$input1" | |
36 #end if | |
37 #end if | |
38 </command> | |
39 <inputs> | |
40 <param name="input1" type="data" label="Select an input file from your history" optional="true" size="120" | |
41 help="Most scripts will need an input - your script MUST be ready for whatever format you choose"/> | |
42 <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60" | |
43 help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers"> | |
44 <sanitizer invalid_char=""> | |
45 <valid initial="string.letters,string.digits"/> | |
46 </sanitizer> | |
47 </param> | |
48 <conditional name="makeMode"> | |
49 <param name="make_Tool" type="select" label="Create a tar.gz file ready for local toolshed entry" help="Ready to deploy securely!" size="60"> | |
50 <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option> | |
51 <option value="" selected="true">No. Just run the script please</option> | |
52 </param> | |
53 <when value = "yes"> | |
54 <param name="tool_version" label="Tool Version - bump this to warn users trying to redo old analyses" type="text" value="0.01" | |
55 help="If you change your script and regenerate the 'same' tool, you should inform Galaxy (and users) by changing (bumping is traditional) this number"/> | |
56 <param name="tool_desc" label="Tool Description" type="text" value="" size="40" | |
57 help="Supply a brief tool description for the Galaxy tool menu entry (optional - appears after the tool name)" /> | |
58 <param name="help_text" label="Tool form documentation and help text for users" type="text" area="true" | |
59 size="8x120" value="**What it Does**" | |
60 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" > | |
61 <sanitizer> | |
62 <valid initial="string.printable"> | |
63 </valid> | |
64 <mapping initial="none"/> | |
65 </sanitizer> | |
66 </param> | |
67 <param name="include_deps" type="select" label="Include ghostscript and graphicsmagick dependencies in generated tool" size="60" | |
68 help="If an HTML file is being created, including dependencies is recommended. Otherwise this setting has no effect"> | |
69 <option value="">Rely on system ghostscript and graphicsmagick rather than include these as dependencies</option> | |
70 <option value="yes" selected="true">Include dependencies so target installations will always work if HTML is being generated</option> | |
71 </param> | |
72 <repeat name="citations" title="Citation"> | |
73 <conditional name="citation_type"> | |
74 <param name="type" type="select" label="Citation Type"> | |
75 <option value="doi">DOI</option> | |
76 <option value="bibtex">BibTeX</option> | |
77 </param> | |
78 <when value="doi"> | |
79 <param name="doi" label="DOI" type="text" value="" | |
80 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." /> | |
81 </when> | |
82 <when value="bibtex"> | |
83 <param name="bibtex" label="BibTex" type="text" area="true" | |
84 size="8x120" help="Supply a BibTex entry that should be cited when this tool is used in published research." value="" > | |
85 <sanitizer> | |
86 <valid initial="string.printable"> | |
87 </valid> | |
88 <mapping initial="none"/> | |
89 </sanitizer> | |
90 </param> | |
91 </when> | |
92 </conditional> | |
93 </repeat> | |
94 </when> | |
95 <when value = ""> | |
96 </when> | |
97 </conditional> | |
98 <param name="make_HTML" type="select" label="Create an HTML report with links to all output files and thumbnail links to PDF images" size="60" | |
99 help="Recommended for presenting complex outputs in an accessible manner. Turn off for simple tools so they just create one output"> | |
100 <option value="yes">Yes, arrange all outputs produced by my script as an HTML output</option> | |
101 <option value="" selected="true">No, no HTML output file thanks</option> | |
102 </param> | |
103 <param name="make_TAB" type="select" label="Create a new (default tabular) history output with or without an HTML file specified above" | |
104 help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes"> | |
105 <option value="yes" selected="true">My script writes to a new history output</option> | |
106 <option value="">I do not want a new history output file</option> | |
107 </param> | |
108 <param name="out_format" type="select" label="Galaxy datatype for your tool's output file if any" help="You may need to edit the xml to extend this list"> | |
109 <option value="tabular" selected="true">Tabular</option> | |
110 <option value="interval">Interval</option> | |
111 <option value="gz">gz</option> | |
112 <option value="text">text</option> | |
113 <option value="sam">sam</option> | |
114 <option value="bam">bam</option> | |
115 <option value="fastqsanger">fastqsanger</option> | |
116 <option value="fastq">fastq</option> | |
117 <option value="fasta">fasta</option> | |
118 </param> | |
119 <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host"> | |
120 <option value="Rscript" selected="true">Rscript</option> | |
121 <option value="python">python</option> | |
122 <option value="perl">perl</option> | |
123 <option value="bash">bash</option> | |
124 <option value="sh">sh</option> | |
125 </param> | |
126 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="8x120" | |
127 help="Script must deal with two command line parameters: Path to input tabular file path (or 'None' if none selected) and path to output tabular history file (or 'None')."> | |
128 <sanitizer> | |
129 <valid initial="string.printable"> | |
130 </valid> | |
131 <mapping initial="none"/> | |
132 </sanitizer> | |
133 </param> | |
134 </inputs> | |
135 <outputs> | |
136 <data format="tabular" name="tab_file" label="${tool_name}.${out_format}"> | |
137 <filter>make_TAB=="yes"</filter> | |
138 <change_format> | |
139 <when input="out_format" value="interval" format="interval" /> | |
140 <when input="out_format" value="gz" format="gz" /> | |
141 <when input="out_format" value="text" format="text" /> | |
142 <when input="out_format" value="sam" format="sam" /> | |
143 <when input="out_format" value="bam" format="bam" /> | |
144 <when input="out_format" value="fastqsanger" format="fastqsanger" /> | |
145 <when input="out_format" value="fastq" format="fastq" /> | |
146 </change_format> | |
147 </data> | |
148 <data format="html" name="html_file" label="${tool_name}.html"> | |
149 <filter>make_HTML == "yes"</filter> | |
150 </data> | |
151 <data format="toolshed.gz" name="new_tool" label="${tool_name}.toolshed.gz"> | |
152 <filter>makeMode['make_Tool'] == "yes"</filter> | |
153 </data> | |
154 </outputs> | |
155 <configfiles> | |
156 <configfile name="runme">$dynScript</configfile> | |
157 <configfile name="helpme"> | |
158 #if $makeMode.make_Tool == "yes": | |
159 ${makeMode.help_text} | |
160 #end if | |
161 </configfile> | |
162 <configfile name="citeme"> | |
163 #if $makeMode.make_Tool == "yes": | |
164 #for $citation in $makeMode.citations: | |
165 #if $citation.citation_type.type == "bibtex": | |
166 **ENTRY**bibtex | |
167 ${citation.citation_type.bibtex} | |
168 #else | |
169 **ENTRY**doi | |
170 ${citation.citation_type.doi} | |
171 #end if | |
172 #end for | |
173 #end if | |
174 </configfile> | |
175 </configfiles> | |
176 <help> | |
177 | |
178 .. class:: warningmark | |
179 | |
180 **Details and attribution** GTF_ | |
181 | |
182 **Local Admins ONLY** Only users whose IDs found in the local admin_user configuration setting in universe_wsgi.ini can run this tool. | |
183 | |
184 **If you find a bug** please raise an issue at the bitbucket repository GTFI_ | |
185 | |
186 **What it does** This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy. | |
187 | |
188 **Input options** This version is limited to simple transformation or reporting requiring only a single input file selected from the history. | |
189 | |
190 **Output options** Optional script outputs include one single new history tabular file, or for scripts that create multiple outputs, | |
191 a new HTML report linking all the files and images created by the script can be automatically generated. | |
192 | |
193 **Tool Generation option** Once the script is working with test data, this tool will optionally generate a new Galaxy tool in a gzip file | |
194 ready to upload to your local toolshed for sharing and installation. Provide a small sample input when you run generate the tool because | |
195 it will become the input for the generated functional test. | |
196 | |
197 .. class:: warningmark | |
198 | |
199 **Note to system administrators** This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances. | |
200 Admin_users will have the power to do anything they want as the Galaxy user if you install this tool. | |
201 | |
202 .. class:: warningmark | |
203 | |
204 **Use on public servers** is STRONGLY discouraged for obvious reasons | |
205 | |
206 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. | |
207 We recommend that you follow the good code hygiene practices associated with safe toolshed. | |
208 | |
209 **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 | |
210 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. | |
211 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. | |
212 This can be handy for complex scripts creating lots of output. | |
213 | |
214 **Examples** | |
215 <![CDATA[ | |
216 | |
217 Each of these following trivial examples can be cut and pasted into the script box for testing. | |
218 Please make sure you choose the appropriate interpreter and upload and select a suitable small matching test data input | |
219 | |
220 A simple Rscript "filter" showing how the command line parameters can be handled, takes an input file, does something (transpose in this case) and | |
221 writes the results to a new tabular file. Note the use of colClasses to ensure that no fiddling takes place with numeric values by treating everything | |
222 as a string:: | |
223 | |
224 # transpose a tabular input file and write as a tabular output file | |
225 ourargs = commandArgs(TRUE) | |
226 inf = ourargs[1] | |
227 outf = ourargs[2] | |
228 inp = read.table(inf,head=F,row.names=NULL,sep='\t',colClasses="character") | |
229 outp = t(inp) | |
230 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F) | |
231 | |
232 Calculate a multiple test adjusted p value from a column of p values - for this script to be useful, it needs the right column for the input to be specified in the code for the | |
233 given input file type(s) specified when the tool is generated :: | |
234 | |
235 # use p.adjust - assumes a HEADER row and column 1 - please fix for any real use | |
236 column = 1 # adjust if necessary for some other kind of input | |
237 ourargs = commandArgs(TRUE) | |
238 inf = ourargs[1] | |
239 outf = ourargs[2] | |
240 inp = read.table(inf,head=T,row.names=NULL,sep='\t') | |
241 p = inp[,column] | |
242 q = p.adjust(p,method='BH') | |
243 outp = cbind(inp,'BH Adjusted p-value'=q) | |
244 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=T) | |
245 | |
246 | |
247 A demonstration Rscript example takes no input file but generates some random data based pdf images | |
248 You must make sure the option to create an HTML output file is | |
249 turned on for this to work. Images (pdf) are linked via thumbnails and | |
250 all files have a link on the resulting HTML page:: | |
251 | |
252 # note this script takes NO input or output because it generates random data | |
253 for (i in 1:10) { | |
254 foo = runif(100) | |
255 bar = rnorm(100) | |
256 bar = foo + 0.05*bar | |
257 pdf(paste('yet',i,"anotherplot.pdf",sep='_')) | |
258 plot(foo,bar,main=paste("Foo by Bar plot #",i),col="maroon", pch=3,cex=0.6) | |
259 dev.off() | |
260 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100)) | |
261 bar = as.matrix(foo) | |
262 pdf(paste('yet',i,"anotherheatmap.pdf",sep='_')) | |
263 heatmap(bar,main='Random Heatmap') | |
264 dev.off() | |
265 } | |
266 | |
267 A slight variation taking an input tabular file from which we read the first number as nreps | |
268 | |
269 # note this script takes a single parameter | |
270 # number of replicates | |
271 ourargs = commandArgs(TRUE) | |
272 infname = ourargs[1] | |
273 nreps = read.table(infname,head=F) | |
274 nreps = unlist(nreps)[1] | |
275 nreps = max(c(1,nreps)) | |
276 nreps = min(c(20,nreps)) | |
277 print(paste("Using nreps=",nreps)) | |
278 for (i in 1:nreps) { | |
279 foo = runif(100) | |
280 bar = rnorm(100) | |
281 bar = foo + 0.2*bar | |
282 pdf(paste("yet",i,"anotherplot.pdf",sep="_")) | |
283 plot(foo,bar,main=paste("Foo by Bar plot ",i),col="maroon", pch=3,cex=0.6) | |
284 dev.off() | |
285 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100)) | |
286 bar = as.matrix(foo) | |
287 pdf(paste("yet",i,"anotherheatmap.pdf",sep="_")) | |
288 heatmap(bar,main="Random Heatmap") | |
289 dev.off() | |
290 } | |
291 | |
292 A Python example that reverses each row of a tabular file (you'll need to remove the leading spaces | |
293 for this to work if cut and pasted into the script box):: | |
294 | |
295 # reverse order of columns in a tabular file | |
296 import sys | |
297 inp = sys.argv[1] | |
298 outp = sys.argv[2] | |
299 i = open(inp,'r') | |
300 o = open(outp,'w') | |
301 for row in i: | |
302 rs = row.rstrip().split('\t') | |
303 rs.reverse() | |
304 o.write('\t'.join(rs)) | |
305 o.write('\n') | |
306 i.close() | |
307 o.close() | |
308 | |
309 A trivial shell script example to show that it works:: | |
310 | |
311 #!/bin/bash | |
312 INF=$1 | |
313 OUTF=$2 | |
314 cut -c2,4,6,8,10,12 $INF > $OUTF | |
315 | |
316 A trivial perl script example to show that even perl works:: | |
317 | |
318 # | |
319 # change all occurances of a string in a file to another string | |
320 # | |
321 $oldfile = $ARGV[0]; | |
322 $newfile = $ARGV[1]; | |
323 $old = "gene"; | |
324 $new = "foo"; | |
325 open(OF, $oldfile); | |
326 open(NF, ">$newfile"); | |
327 # read in each line of the file | |
328 while ($line = <OF>) { | |
329 $line =~ s/$old/$new/; | |
330 print NF $line; | |
331 } | |
332 close(OF); | |
333 close(NF); | |
334 | |
335 ]]> | |
336 | |
337 **Citation** | |
338 | |
339 | |
340 Paper_ : | |
341 | |
342 Creating re-usable tools from scripts: The Galaxy Tool Factory | |
343 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team | |
344 Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573 | |
345 | |
346 | |
347 **Licensing** | |
348 | |
349 Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012 | |
350 All rights reserved. | |
351 Licensed under the LGPL_ | |
352 | |
353 .. _LGPL: http://www.gnu.org/copyleft/lesser.html | |
354 .. _GTF: https://bitbucket.org/fubar/galaxytoolfactory | |
355 .. _GTFI: https://bitbucket.org/fubar/galaxytoolfactory/issues | |
356 .. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&keytype=ref | |
357 | |
358 | |
359 </help> | |
360 <citations> | |
361 <citation type="doi">10.1093/bioinformatics/bts573</citation> | |
362 </citations> | |
363 </tool> | |
364 | |
365 |