comparison macros.xml @ 0:21d312776891 draft

planemo upload for repository https://github.com/mvdbeek/docker_scriptrunner/ commit 30f8264cdd67d40dec8acde6407f32152e6a29c1-dirty
author mvdbeek
date Sat, 09 Jul 2016 16:57:13 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:21d312776891
1
2 <macro>
3 <xml name="help_macro">
4 <help>
5 .. class:: warningmark
6
7 **Details and attribution** Docker_toolfactory_
8
9 **If you find a bug** please raise an issue at the bitbucket repository Issues_
10
11 **What it does** This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy.
12
13 **Input options** This version is limited to simple transformation or reporting requiring only a single input file selected from the history.
14
15 **Output options** Optional script outputs include one single new history tabular file, or for scripts that create multiple outputs,
16 a new HTML report linking all the files and images created by the script can be automatically generated.
17
18 .. class:: warningmark
19
20 **Note to system administrators** This tool uses docker containers as protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.
21
22 .. class:: warningmark
23
24 **Use on public servers** is STRONGLY discouraged for obvious reasons
25
26 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.
27 We recommend that you follow the good code hygiene practices associated with safe toolshed.
28
29 **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
30 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.
31 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.
32 This can be handy for complex scripts creating lots of output.
33
34 **Examples**
35 <![CDATA[
36
37 Each of these following trivial examples can be cut and pasted into the script box for testing.
38 Please make sure you choose the appropriate interpreter and upload and select a suitable small matching test data input
39
40 A simple Rscript "filter" showing how the command line parameters can be handled, takes an input file, does something (transpose in this case) and
41 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
42 as a string::
43
44 # transpose a tabular input file and write as a tabular output file
45 ourargs = commandArgs(TRUE)
46 inf = ourargs[1]
47 outf = ourargs[2]
48 inp = read.table(inf,head=F,row.names=NULL,sep='\t',colClasses="character")
49 outp = t(inp)
50 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F)
51
52 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
53 given input file type(s) specified when the tool is generated ::
54
55 # use p.adjust - assumes a HEADER row and column 1 - please fix for any real use
56 column = 1 # adjust if necessary for some other kind of input
57 ourargs = commandArgs(TRUE)
58 inf = ourargs[1]
59 outf = ourargs[2]
60 inp = read.table(inf,head=T,row.names=NULL,sep='\t')
61 p = inp[,column]
62 q = p.adjust(p,method='BH')
63 outp = cbind(inp,'BH Adjusted p-value'=q)
64 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=T)
65
66
67 A demonstration Rscript example takes no input file but generates some random data based pdf images
68 You must make sure the option to create an HTML output file is
69 turned on for this to work. Images (pdf) are linked via thumbnails and
70 all files have a link on the resulting HTML page::
71
72 # note this script takes NO input or output because it generates random data
73 for (i in 1:10) {
74 foo = runif(100)
75 bar = rnorm(100)
76 bar = foo + 0.05*bar
77 pdf(paste('yet',i,"anotherplot.pdf",sep='_'))
78 plot(foo,bar,main=paste("Foo by Bar plot #",i),col="maroon", pch=3,cex=0.6)
79 dev.off()
80 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
81 bar = as.matrix(foo)
82 pdf(paste('yet',i,"anotherheatmap.pdf",sep='_'))
83 heatmap(bar,main='Random Heatmap')
84 dev.off()
85 }
86
87 # A slight variation taking an input tabular file from which we read the first number as nreps
88 # his script takes a single parameter
89 # number of replicates
90
91 .. code-block:: R
92
93 ourargs = commandArgs(TRUE)
94 infname = ourargs[1]
95 nreps = read.table(infname,head=F)
96 nreps = unlist(nreps)[1]
97 nreps = max(c(1,nreps))
98 nreps = min(c(20,nreps))
99 print(paste("Using nreps=",nreps))
100 for (i in 1:nreps) {
101 foo = runif(100)
102 bar = rnorm(100)
103 bar = foo + 0.2*bar
104 pdf(paste("yet",i,"anotherplot.pdf",sep="_"))
105 plot(foo,bar,main=paste("Foo by Bar plot ",i),col="maroon", pch=3,cex=0.6)
106 dev.off()
107 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
108 bar = as.matrix(foo)
109 pdf(paste("yet",i,"anotherheatmap.pdf",sep="_"))
110 heatmap(bar,main="Random Heatmap")
111 dev.off()
112 }
113
114 A Python example that reverses each row of a tabular file (you'll need to remove the leading spaces
115 for this to work if cut and pasted into the script box)::
116
117 # reverse order of columns in a tabular file
118 import sys
119 inp = sys.argv[1]
120 outp = sys.argv[2]
121 i = open(inp,'r')
122 o = open(outp,'w')
123 for row in i:
124 rs = row.rstrip().split('\t')
125 rs.reverse()
126 o.write('\t'.join(rs))
127 o.write('\n')
128 i.close()
129 o.close()
130
131 A trivial shell script example to show that it works::
132
133 #!/bin/bash
134 INF=$1
135 OUTF=$2
136 cut -c2,4,6,8,10,12 $INF > $OUTF
137
138 A trivial perl script example to show that even perl works::
139
140 #
141 # change all occurances of a string in a file to another string
142 #
143 $oldfile = $ARGV[0];
144 $newfile = $ARGV[1];
145 $old = "gene";
146 $new = "foo";
147 open(OF, $oldfile);
148 open(NF, ">$newfile");
149 # read in each line of the file
150 while ($line = <OF>) {
151 $line =~ s/$old/$new/;
152 print NF $line;
153 }
154 close(OF);
155 close(NF);
156
157 ]]>
158
159 **Citation**
160
161
162 Paper_ :
163
164 Creating re-usable tools from scripts: The Galaxy Tool Factory
165 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team
166 Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573
167
168
169 **Licensing**
170
171 Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012
172 All rights reserved.
173 Licensed under the LGPL_
174
175 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
176 .. _Docker_toolfactory: https://bitbucket.org/mvdbeek/dockertoolfactory
177 .. _Issues: https://bitbucket.org/mvdbeek/dockertoolfactory/issues
178 .. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&amp;keytype=ref
179
180 </help>
181 <citations>
182 <citation type="doi">10.1093/bioinformatics/bts573</citation>
183 </citations>
184 </xml>
185 <xml name="test_data_macro">
186 </xml>
187 </macro>