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