comparison macros.xml @ 0:0fa46413d0d9 draft

planemo upload for repository https://bitbucket.org/mvdbeek/dockertoolfactory/ commit 2f33eb59c06ac3d6ba6e22622fd4ae729eb5e4da-dirty
author mvdbeek
date Sat, 03 Oct 2015 08:34:39 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0fa46413d0d9
1 <macros>
2 <macro name="help_macro">
3 <help><![CDATA[
4 .. class:: warningmark
5
6 **Details and attribution** Docker_toolfactory_
7
8 **If you find a bug** please raise an issue at the bitbucket repository Issues_
9
10 **What it does** This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy.
11
12 **Input options** This version is limited to simple transformation or reporting requiring only a single input file selected from the history.
13
14 **Output options** Optional script outputs include one single new history tabular file, or for scripts that create multiple outputs,
15 a new HTML report linking all the files and images created by the script can be automatically generated.
16
17 **Tool Generation option** Once the script is working with test data, this tool will optionally generate a new Galaxy tool in a gzip file
18 ready to upload to your local toolshed for sharing and installation. Provide a small sample input when you run generate the tool because
19 it will become the input for the generated functional test.
20
21 .. class:: warningmark
22
23 **Note to system administrators** This tool uses docker containers as protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.
24
25 .. class:: warningmark
26
27 **Use on public servers** is STRONGLY discouraged for obvious reasons
28
29 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.
30 We recommend that you follow the good code hygiene practices associated with safe toolshed.
31
32 **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
33 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.
34 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.
35 This can be handy for complex scripts creating lots of output.
36
37 **Examples**
38
39 Each of these following trivial examples can be cut and pasted into the script box for testing.
40 Please make sure you choose the appropriate interpreter and upload and select a suitable small matching test data input
41
42 A simple Rscript "filter" showing how the command line parameters can be handled, takes an input file, does something (transpose in this case) and
43 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
44 as a string::
45
46 # transpose a tabular input file and write as a tabular output file
47 ourargs = commandArgs(TRUE)
48 inf = ourargs[1]
49 outf = ourargs[2]
50 inp = read.table(inf,head=F,row.names=NULL,sep='\t',colClasses="character")
51 outp = t(inp)
52 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F)
53
54 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
55 given input file type(s) specified when the tool is generated ::
56
57 # use p.adjust - assumes a HEADER row and column 1 - please fix for any real use
58 column = 1 # adjust if necessary for some other kind of input
59 ourargs = commandArgs(TRUE)
60 inf = ourargs[1]
61 outf = ourargs[2]
62 inp = read.table(inf,head=T,row.names=NULL,sep='\t')
63 p = inp[,column]
64 q = p.adjust(p,method='BH')
65 outp = cbind(inp,'BH Adjusted p-value'=q)
66 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=T)
67
68
69 A demonstration Rscript example takes no input file but generates some random data based pdf images
70 You must make sure the option to create an HTML output file is
71 turned on for this to work. Images (pdf) are linked via thumbnails and
72 all files have a link on the resulting HTML page::
73
74 # note this script takes NO input or output because it generates random data
75 for (i in 1:10) {
76 foo = runif(100)
77 bar = rnorm(100)
78 bar = foo + 0.05*bar
79 pdf(paste('yet',i,"anotherplot.pdf",sep='_'))
80 plot(foo,bar,main=paste("Foo by Bar plot #",i),col="maroon", pch=3,cex=0.6)
81 dev.off()
82 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
83 bar = as.matrix(foo)
84 pdf(paste('yet',i,"anotherheatmap.pdf",sep='_'))
85 heatmap(bar,main='Random Heatmap')
86 dev.off()
87 }
88
89 A slight variation taking an input tabular file from which we read the first number as nreps
90
91 # note this script takes a single parameter
92 # number of replicates
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 **Citation**
158
159
160 Paper_ :
161
162 Creating re-usable tools from scripts: The Galaxy Tool Factory
163 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team
164 Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573
165
166
167 **Licensing**
168
169 Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012
170 All rights reserved.
171 Licensed under the LGPL_
172
173 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
174 .. _Docker_toolfactory: https://bitbucket.org/mvdbeek/dockertoolfactory
175 .. _Issues: https://bitbucket.org/mvdbeek/dockertoolfactory/issues
176 .. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&amp;keytype=ref
177 ]]>
178 </help>
179 </macro>
180 </macros>