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