comparison rgToolFactory.xml @ 12:d12728e33c3d

Changed to deliver a gz file - requires a new datatypes_conf.xml entry: <datatype extension="gz" type="galaxy.datatypes.binary:Binary" mimetype="multipart/x-gzip" subclass="True" /> There's some wierd shit going on with filter values and such but it now all appears to be working ok
author ross lazarus ross.lazarus@gmail.com
date Sun, 03 Jun 2012 15:39:20 +1000
parents a0a5d0757e39
children 8594478e8d2c
comparison
equal deleted inserted replaced
11:a0a5d0757e39 12:d12728e33c3d
4 #if ( $__user_email__ not in ['ross.lazarus@gmail.com',] ): 4 #if ( $__user_email__ not in ['ross.lazarus@gmail.com',] ):
5 rgToolFactory.py --bad_user $__user_email__ 5 rgToolFactory.py --bad_user $__user_email__
6 #else: 6 #else:
7 rgToolFactory.py --script_path "$runme" --interpreter "$interpreter" 7 rgToolFactory.py --script_path "$runme" --interpreter "$interpreter"
8 --tool_name "$tool_name" 8 --tool_name "$tool_name"
9 #if $make_HTML.value=="yes" or $factory.make_Tool=="yes": 9 #if $make_TAB.value=="yes":
10 --output_tab "$tab_file"
11 #end if
12 #if $factory.make_Tool=="yes":
13 --make_Tool "$factory.make_Tool"
14 --help_text "$helpme"
15 --tool_desc "$factory.tool_desc"
16 --new_tool "$new_tool"
17 #end if
18 #if $make_HTML.value=="yes":
10 --output_dir "$html_file.files_path" --output_html "$html_file" 19 --output_dir "$html_file.files_path" --output_html "$html_file"
11 #end if 20 #end if
12 #if $input1 != 'None': 21 #if $input1 != 'None':
13 --input_tab "$input1" 22 --input_tab "$input1"
14 #end if 23 #end if
15 #if $make_HTML.value=="yes": 24 #if $make_HTML.value=="yes":
16 --make_HTML "yes" 25 --make_HTML "yes"
17 #end if
18 #if $make_TAB.value=="yes":
19 --output_tab "$tab_file"
20 #end if
21 #if $factory.make_Tool=="yes":
22 --make_Tool "$factory.make_Tool"
23 --help_text "$helpme"
24 --tool_desc "$factory.tool_desc"
25 #end if 26 #end if
26 #end if 27 #end if
27 </command> 28 </command>
28 <inputs> 29 <inputs>
29 <param name="input1" type="data" label="Select an optional input file from your history" optional="true" 30 <param name="input1" type="data" label="Select an optional input file from your history" optional="true"
30 help="Your script probably needs an input - but if not, this can be left unassigned. Note that your script MUST be able to parse whatever format you choose!"/> 31 help="Your script probably needs an input - but if not, this can be left unassigned. Note that your script MUST be able to parse whatever format you choose!"/>
31 <param name="tool_name" type="text" value="My dynamic script" size="80" label="Title for job outputs" help="Supply a meaningful name here to remind you what the outputs contain"/> 32 <param name="tool_name" type="text" value="My dynamic script" size="80" label="Title for job outputs" help="Supply a meaningful name here to remind you what the outputs contain">
33 <sanitizer>
34 <valid initial="string.letters,string.digits">
35 <mapping initial="none"/>
36 </valid>
37 </sanitizer>
38 </param>
32 <conditional name="factory"> 39 <conditional name="factory">
33 <param name="make_Tool" type="select" label="Create a tar.gz file ready for local toolshed entry" help="Ready to deploy securely!"> 40 <param name="make_Tool" type="select" label="Create a tar.gz file ready for local toolshed entry" help="Ready to deploy securely!">
34 <option value="yes">Yes</option> 41 <option value="yes">Yes</option>
35 <option value="" selected="true">Not yet, it's still broken</option> 42 <option value="" selected="true">Not yet, it's still broken</option>
36 </param> 43 </param>
43 <mapping initial="none"/> 50 <mapping initial="none"/>
44 </sanitizer> 51 </sanitizer>
45 </param> 52 </param>
46 </when> 53 </when>
47 </conditional> 54 </conditional>
48 <param name="make_HTML" type="select" label="Create an HTML output with all script outputs collected together, with thumbnails of new PDF images, the script and a run log file" 55 <param name="make_HTML" type="select" label="Create an HTML report with links to all output files and thumbnail links to PDF images"
49 help="This is useful for presenting complex outputs and is not needed if your script doesn't create anything other than a single tabular output"> 56 help="Recommended for presenting complex outputs in an accessible manner">
50 <option value="yes">Yes</option> 57 <option value="yes">Yes</option>
51 <option value="" selected="true">No</option> 58 <option value="" selected="true">No</option>
52 </param> 59 </param>
53 <param name="make_TAB" type="select" label="Create a new tabular history output" 60 <param name="make_TAB" type="select" label="Create a new tabular history output"
54 help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes"> 61 help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes">
58 <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host"> 65 <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host">
59 <option value="Rscript" selected="true">Rscript</option> 66 <option value="Rscript" selected="true">Rscript</option>
60 <option value="python">python</option> 67 <option value="python">python</option>
61 <option value="perl (ugh)">perl</option> 68 <option value="perl (ugh)">perl</option>
62 </param> 69 </param>
63 <param name="dynScript" label="Your Script Goes Here" type="text" value="" area="True" size="8x80" width="80" 70 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="8x80" width="80"
64 help="CL parameters: input tabular file path (if selected) and optional output (if selected). Script must deal with these and write output (if any) to the right one"> 71 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').">
65 <sanitizer> 72 <sanitizer>
66 <valid initial="string.printable"> 73 <valid initial="string.printable">
67 </valid> 74 </valid>
68 <mapping initial="none"/> 75 <mapping initial="none"/>
69 </sanitizer> 76 </sanitizer>
70 </param> 77 </param>
71 </inputs> 78 </inputs>
72 <outputs> 79 <outputs>
73 <data format="tabular" name="tab_file" label="${tool_name}.xls"> 80 <data format="tabular" name="tab_file" label="${tool_name}.xls">
74 <filter> make_TAB=="yes" </filter> 81 <filter>make_TAB == "yes"</filter>
75 </data> 82 </data>
76 <data format="html" name="html_file" label="${tool_name}.html"> 83 <data format="html" name="html_file" label="${tool_name}.html">
77 <filter>make_HTML=="yes" or factory.make_Tool=="yes"</filter> 84 <filter>make_HTML == "yes"</filter>
85 </data>
86 <data format="gz" name="new_tool" label="${tool_name}_tool.gz">
87 <filter>factory['make_Tool'] == "yes"</filter>
78 </data> 88 </data>
79 </outputs> 89 </outputs>
80 <configfiles> 90 <configfiles>
81 <configfile name="runme"> 91 <configfile name="runme">
82 ${dynScript} 92 ${dynScript}
87 ${factory.help_text} 97 ${factory.help_text}
88 #end if 98 #end if
89 </configfile> 99 </configfile>
90 </configfiles> 100 </configfiles>
91 <help> 101 <help>
92 **What it does** 102 **What it does** This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy.
93 This tool enables a user to paste and submit an arbitrary R/python/perl script to run in Galaxy.
94 103
95 **Restrictions** 104 **Input options** This version is limited to simple transformation or reporting requiring only a single input file selected from the history.
96 This tool will ONLY work if your user id has been added to the local copy's list of permitted users. 105
97 It should only ever be used on a private, personal Galaxy instance and you should edit this tool's source so your local login 106 **Output options** Optional script outputs include one single new history tabular file, or for scripts that create multiple outputs,
98 is authorised to use it - *it will not run otherwise* 107 a new HTML report linking all the files and images created by the script can be automatically generated.
108
109 **Tool Generation option** Once the script is working with test data, this tool will optionally generate a new Galaxy tool in a gzip file
110 ready to upload to your local toolshed for sharing and installation.
111
112 **Permission to to use this tool** must be explicitly granted by an administrator adding approved Galaxy user IDs to the local tool XML list of permitted users. *It will not run otherwise*
99 113
100 .. class:: warningmark 114 .. class:: warningmark
101 115
102 **Note to system administrators** Under no circumstances should you allow any user to use this tool unless you really, really trust them to do 116 **Note to system administrators** This tool offers *NO* built in protection against malicious scripts and should only be installed on private/personnal Galaxy instances.
103 no harm. This tool (extremely) insecure and is only recommended for private/personnal Galaxy instances. 117 Under no circumstances should you allow any user to use this tool unless you really, really trust them with the power to do what they want as the Galaxy user.
104 118
105 Once you get the script working on some test data, you can generate a complete ready to run 119 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.
106 Galaxy tool by setting the "Make tool" option to Yes. The resulting tarball will be ready to install
107 It will run just as securely as any other normal Galaxy tool - unlike this one used to generate it.
108 120
109 .. class:: warningmark 121 .. class:: warningmark
110 122
111 **Use on public servers** is STRONGLY discouraged for obvious reasons 123 **Use on public servers** is STRONGLY discouraged for obvious reasons
112 124
113 **Scripting conventions** 125 **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
114 The pasted script will be executed. 126 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.
115 It will get the path to the (optional) input tabular data file path or NONE if you do not select one 127 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.
116 as the first command line parameter
117
118 The script must write it's output as tab delimited text to the path found as the second command line parameter
119 Note that if an optional HTML output is selected, all the output files spewed by your script will be nicely presented as links to the user.
120 Any pdf images will automagically be converted to show thumbnails in that output.
121 This can be handy for complex scripts creating lots of output. 128 This can be handy for complex scripts creating lots of output.
122 129
123 **Simple Rscript example** 130 **Simple examples**
124 131
125 A simple "filter" that takes an input file, does something and writes the results to a new tabular file might look like this:: 132 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::
126 133
134 # transpose a tabular input file and write as a tabular output file
127 ourargs = commandArgs(TRUE) 135 ourargs = commandArgs(TRUE)
128 inf = ourargs[1] 136 inf = ourargs[1]
129 outf = ourargs[2] 137 outf = ourargs[2]
130 inp = read.table(inf,head=F,row.names=NULL,sep='\t') 138 inp = read.table(inf,head=F,row.names=NULL,sep='\t')
131 outp = t(inp) 139 outp = t(inp)
132 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F) 140 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F)
133 141
134 A more complex example takes no input file but generates a random heatmap pdf - you must make sure the option to create an HTML output file is 142 A more complex Rscript example takes no input file but generates a random heatmap pdf - you must make sure the option to create an HTML output file is
135 turned on for this to work. The heatmap will be presented as a thumbnail linked to the pdf in the resulting HTML page:: 143 turned on for this to work. The heatmap will be presented as a thumbnail linked to the pdf in the resulting HTML page::
136 144
145 # note this script takes NO input or output because it generates random data
137 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100)) 146 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
138 bar = as.matrix(foo) 147 bar = as.matrix(foo)
139 pdf( "heattest.pdf" ) 148 pdf( "heattest.pdf" )
140 heatmap(bar,main='Random Heatmap') 149 heatmap(bar,main='Random Heatmap')
141 dev.off() 150 dev.off()
142 151
143 **Attribution** 152 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)::
144 Copyright ross lazarus (ross.lazarus at gmail stop com) May 2012 153
145 All rights reserved 154 # reverse order of columns in a tabular file
146 Licensed under the LGPL for your pleasure 155 import sys
156 inp = sys.argv[1]
157 outp = sys.argv[2]
158 i = open(inp,'r')
159 o = open(outp,'w')
160 for row in i:
161 rs = row.rstrip().split('\t')
162 rs.reverse()
163 o.write('\t'.join(rs))
164 o.write('\n')
165 i.close()
166 o.close()
167
168
169 **Attribution** Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012
170
171 All rights reserved.
172
173 Licensed under the LGPL_
174
175 .. _LGPL: http://www.gnu.org/copyleft/lesser.html
176
147 </help> 177 </help>
148 178
149 </tool> 179 </tool>
150 180
151 181