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