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