comparison rgToolFactory2.xml @ 26:db35d39e1de9 draft

Passes planemo test Uses galaxyxml to generate new tool. More outputs will be added...
author fubar
date Thu, 30 Jul 2020 06:48:45 -0400
parents 9fe74bd23af2
children
comparison
equal deleted inserted replaced
25:9fe74bd23af2 26:db35d39e1de9
1 <tool id="rgTF2" name="Tool Factory Two" version="1.17"> 1 <tool id="rgTF2" name="ToolFactory" version="2.00">
2 <description>Scripts into tools</description> 2 <description>Scripts into tools</description>
3 <macros>
4 <xml name="addpar">
5 <param name="edit_params" type="select" display="radio" label="Add all additional parameters to the generated tool form so they are user editable?"
6 help="If no (default), users will NOT be able to alter any additional parameters. If yes, these will appear on the tool form as text fields with no validation or sanitizing">
7 <option value="yes">Yes, allow user to edit all additional parameters on the generated tool form</option>
8 <option value="no" selected="true">No - use the fixed values for all additional parameters - no user editing</option>
9 </param>
10 <repeat name="additional_history_inputs" title="Additional Current history data files to pass in to the script - Use the '+' button to add as many as needed"
11 help="Each of these will become a history item selector as input for users of the new tool you are making">
12 <param name="input_files" type="data" format="data" label="Select an input file from your history" optional="true" size="120" multiple="false"
13 help=""/>
14 <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts as input"
15 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml" value="tabular">
16 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
17 <column name="value" index="0"/>
18 </options>
19 </param>
20 <param name="param_label" type="text" value="" label="This will become the user prompt for the form so please make it informative" size="60"
21 help="Note that '~~~' is an internal delimiter so must not appear in this text field - please work around this technical limitation" >
22 <sanitizer invalid_char="">
23 <valid initial="string.printable"> <remove value='~~~'/> </valid>
24 <mapping initial="none"/>
25 </sanitizer>
26 </param>
27 <param name="param_help" type="text" value="parameter_help" label="This will become help text on the form."
28 help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation" size="60">
29 <sanitizer invalid_char="">
30 <valid initial="string.printable"> <remove value='~~~'/> </valid>
31 <mapping initial="none"/>
32 </sanitizer>
33 </param>
34 <param name="CL" type="text" size="60" label="Positional: ordinal integer. Argparse: argument name."
35 help="If you will pass positional parameters, enter the integer ordinal for this parameter. If Argparse style, '--' will be prepended or '-' if single character" value="">
36 </param>
37 </repeat>
38 <repeat name="additional_parameters" title="Pass additional parameters to the script"
39 help="See examples below to see how these can be parsed by scripts in the various languages">
40 <param name="param_name" type="text" value="parameter_name" label="Choose the name for this parameter" size="60">
41 <sanitizer invalid_char="">
42 <valid initial="string.letters,string.digits"/>
43 <mapping initial="none"/>
44 </sanitizer>
45 </param>
46 <param name="param_type" type="select" label="Select the type for this parameter">
47 <option value="text" selected="true">text</option>
48 <option value="integer">integer</option>
49 <option value="float">float</option>
50 </param>
51 <param name="param_value" type="text" value="parameter_value" label="Enter this parameter's default value" size="60"
52 help="Note that '~~~' is an internal delimiter must not appear in this text field - please work around this technical limitation" >
53 <sanitizer invalid_char="">
54 <valid initial="string.printable"> <remove value='~~~'/> </valid>
55 <mapping initial="none"/>
56 </sanitizer>
57 </param>
58 <param name="param_label" type="text" value="parameter_label" label="Enter this parameter's label for the form" size="60"
59 help="Note that '~~~' is an internal delimiter so must not appear in this text field - please work around this technical limitation" >
60 <sanitizer invalid_char="">
61 <valid initial="string.printable"> <remove value='~~~'/> </valid>
62 <mapping initial="none"/>
63 </sanitizer>
64 </param>
65 <param name="param_help" type="text" value="parameter_help" label="Help for this parameter"
66 help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation" size="60">
67 <sanitizer invalid_char="">
68 <valid initial="string.printable"> <remove value='~~~'/> </valid>
69 <mapping initial="none"/>
70 </sanitizer>
71 </param>
72 <param name="CL" type="text" size="60" label="Positional order (must be integer > 1) or Argument name to be prefixed with '--' or '-' if single letter"
73 help="Using positional parameters, enter the integer ordinal for this parameter on the command line. Using Argparse style, '--' will be prepended on the CL" value="">
74 </param>
75 </repeat>
76 </xml>
77 <xml name="builtin_dynpar">
78 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="20x120"
79 help="If there are parameters, either positional or argparse style, the script must parse and use them appropriately">
80 <sanitizer>
81 <valid initial="string.printable">
82 </valid>
83 <mapping initial="none"/>
84 </sanitizer>
85 </param>
86 </xml>
87 <xml name="dynpar">
88 <param name="interpreter_version" type="text" value="" label="Specific script interpreter version to match dependency (Conda) repositories - e.g. for python '3.8.5' Latest if empty" size="60"/>
89 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="20x120"
90 help="If there are parameters, either positional or argparse style, the script must parse and use them appropriately">
91 <sanitizer>
92 <valid initial="string.printable">
93 </valid>
94 <mapping initial="none"/>
95 </sanitizer>
96 </param>
97 </xml>
98 </macros>
3 <requirements> 99 <requirements>
4 <requirement type="package" version="9.10">ghostscript</requirement> 100 <requirement type="package">python</requirement>
5 <requirement type="package" version="1.3.20">graphicsmagick</requirement> 101 <requirement type="package">galaxyxml</requirement>
6 </requirements> 102 </requirements>
7 <code file="getlocalrpackages.py"/> 103 <command interpreter="python"><![CDATA[
8 <command interpreter="python">
9 #import os 104 #import os
10 #set dev_env = os.environ.get('GALAXY_DEVELOPMENT_ENVIRONMENT', '0') == '1' 105 #set dev_env = os.environ.get('GALAXY_DEVELOPMENT_ENVIRONMENT', '0') == '1'
11 #if not $dev_env and ( $__user_email__ not in $__admin_users__ ): 106 #if not $dev_env and ( $__user_email__ not in $__admin_users__ ):
12 rgToolFactory2.py --bad_user $__user_email__ 107 $__tool_directory__/rgToolFactory2.py --bad_user $__user_email__
13 #else: 108 #else:
14 rgToolFactory2.py --script_path "$runme" --interpreter "$interp.interpreter" 109 $__tool_directory__/rgToolFactory2.py --script_path "$runme"
15 --tool_name "$tool_name" --user_email "$__user_email__" --citations "$citeme" 110 #if str($interexe.interpreter)=="Executable":
16 --envshpath "$interp.envpath" 111 --exe_package="$interexe.exe_package" --exe_package_version="$interexe.exe_package_version"
17 112 #else:
18 #if $make_TAB.value=="yes": 113 --interpreter_name="$interexe.interpreter"
19 --output_tab "$output1" 114 #if not str($interexe.interpreter) in ['bash','sh']:
20 --output_format "$output_format" 115 --interpreter_version="$interexe.interpreter_version"
21 #end if 116 #end if
22 #if $makeMode.make_Tool=="yes": 117 #end if
23 --make_Tool "$makeMode.make_Tool" 118 --tool_name="$tool_name" --user_email="$__user_email__" --citations="$citeme" --parampass="$ppass.parampass"
24 --tool_desc "$makeMode.tool_desc" 119 --output_tab="$output1" --output_format="$output_format" --output_cl="$output_CL"
25 --tool_version "$makeMode.tool_version" 120 #if str($makeMode.make_Tool)=="yes":
26 --new_tool "$new_tool" 121 --make_Tool="$makeMode.make_Tool"
27 --help_text "$helpme" 122 --tool_desc="$makeMode.tool_desc"
28 #if $make_HTML.value=="yes": 123 --tool_version="$makeMode.tool_version"
29 #if $makeMode.include_deps.value=="yes": 124 --new_tool="$new_tool"
30 --include_dependencies "yes" 125 --help_text="$helpme"
31 #end if 126 #end if
32 #end if 127 #if $ppass.parampass != '0':
33 #end if 128 #if str($ppass.edit_params) == "yes":
34 #if $additional_parameters != 'None': 129 --edit_additional_parameters
35 #if $edit_params.value == "yes": 130 #end if
36 --edit_additional_parameters 131 #for i in $ppass.additional_parameters:
37 #end if 132 --additional_parameters="$i.param_name~~~$i.param_value~~~$i.param_label~~~$i.param_help~~~$i.param_type~~~$i.CL"
38 #for i in $additional_parameters: 133 #end for
39 --additional_parameters "$i.param_name,$i.param_value,$i.param_label,$i.param_help,$i.param_type" 134 #end if
40 #end for 135 --output_dir="."
41 #end if 136 #if str($input_files) != '':
42 #if $make_HTML.value=="yes": 137 --input_files="$input_files~~~$input_CL~~~$input_formats~~~$input_label~~~$input_help"
43 --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes" 138 #end if
44 #else: 139 #if $ppass.parampass != '0' and $ppass.additional_history_inputs:
45 --output_dir "." 140 #for $intab in $ppass.additional_history_inputs:
46 #end if 141 --input_files="$intab.input_files~~~$intab.CL~~~$intab.input_formats~~~$intab.param_label~~~$intab.param_help"
47 #if len($input_tab) != 0: 142 #end for
48 --input_formats "$input_formats" 143 #end if
49 #for $intab in $input_tab:
50 #if $intab.ext != 'data':
51 --input_tab "${intab},${intab.name}"
52 #end if
53 #end for
54 #end if
55 #end if 144 #end if
56 </command> 145 ]]></command>
146 <configfiles>
147 <configfile name="runme">
148 #if $interexe.interpreter != "Executable":
149 ${interexe.dynScript}
150 #else
151 "Not used"
152 #end if
153 </configfile>
154 <configfile name="helpme">
155 #if $makeMode.make_Tool == "yes":
156 ${makeMode.help_text}
157 #end if
158 </configfile>
159 <configfile name="citeme">
160 #if $makeMode.make_Tool == "yes":
161 #for $citation in $makeMode.citations:
162 #if $citation.citation_type.type == "bibtex":
163 **ENTRY**bibtex
164 ${citation.citation_type.bibtex}
165 #else
166 **ENTRY**doi
167 ${citation.citation_type.doi}
168 #end if
169 #end for
170 #end if
171 </configfile>
172 </configfiles>
57 <inputs> 173 <inputs>
58 <param name="input_tab" type="data" label="Select one or more input file(s) from your history" optional="true" size="120" multiple="true" 174
59 help="Use the multiple input widget (above/right of input box) for multiple inputs - your script MUST be ready to parse the command line right - see samples below"/> 175 <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60"
60 <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts as input"
61 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
62 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
63 <column name="value" index="0"/>
64 </options>
65 </param>
66 <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60"
67 help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers"> 176 help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">
68 <sanitizer invalid_char=""> 177 <sanitizer invalid_char="">
69 <valid initial="string.letters,string.digits"> 178 <valid initial="string.letters,string.digits">
70 <add value="_"/> 179 <add value="_"/>
71 </valid> 180 </valid>
72 </sanitizer> 181 </sanitizer>
73 </param> 182 </param>
183 <param name="input_files" format="data" type="data" label="Select a small test input file" optional="true" size="120" multiple="false"
184 help="This will be used to test the new tool to generate a built in test for the generated tool"/>
185 <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts for this input"
186 help="If not listed here, datatypes can be added in galaxy's datatypes_conf.xml." value="tabular">
187 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
188 <column name="value" index="0"/>
189 </options>
190 </param>
191 <param name="input_label" type="text" value="parameter_label" label="Data input user prompt on the generated tool form" size="60"
192 help="Describe the input file so the user can understand how it will be used" >
193 <sanitizer invalid_char="">
194 <valid initial="string.printable"> <remove value='~~~'/> </valid>
195 <mapping initial="none"/>
196 </sanitizer>
197 </param>
198 <param name="input_help" type="text" value="parameter_help" label="Data input user help on the generated tool form"
199 help="Enter text to appear as help for the user on the generated tool form" size="60">
200 <sanitizer invalid_char="">
201 <valid initial="string.printable"> <remove value='~~~'/> </valid>
202 <mapping initial="none"/>
203 </sanitizer>
204 </param>
205 <param name="input_CL" type="text" size="60" label="Positional order (must be integer > 1) or Argument name to be prefixed with '--'. Use 'STDIN' if your script reads from STDIN"
206 help="If you will pass positional parameters, enter the integer index for this parameter on the command line. If Argparse style, '--' will be prepended on the CL" value="">
207 </param>
208 <param name="output_format" type="select" multiple="false" label="Select the Galaxy datatype that your tool/script emits as output for the new history item"
209 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml" value="tabular">
210 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
211 <column name="value" index="0"/>
212 </options>
213 </param>
214 <param name="output_CL" type="text" size="60" label="Positional order (must be integer > 1) or Argument name to be prefixed with '--'. Use 'STDOUT' if your script writes to stdout"
215 help="If you will pass positional parameters, enter the integer index for this parameter on the command line. If Argparse style, '--' will be prepended on the CL" value="">
216 </param>
217 <conditional name="interexe">
218 <param name="interpreter" type="select" label="For binaries, choose 'Executable'. Otherwise choose the interpreter for your code"
219 help = "If executable, the supplied package will become a requirement so must match the tool dependency resolver package name - conda is the default.">
220 <option value="Executable" selected="true">An executable binary to be provided and managed by the Conda dependency management subsystem</option>
221 <option value="python">python</option>
222 <option value="r-base">Rscript</option>
223 <option value="perl">perl</option>
224 <option value="bash">bash</option>
225 <option value="sh">sh</option>
226 </param>
227 <when value="Executable">
228 <param name="exe_package" type="text" value="" label="Executable package name in dependency (Conda) repositories - e.g. 'bwa'" size="60" optional="false"/>
229 <param name="exe_package_version" type="text" value="" label="Executable package version to match dependency (Conda) repositories - e.g. for bwa='0.7.17'. Latest if empty" size="60"/>
230 </when>
231 <when value = "python">
232 <expand macro="dynpar" />
233 </when>
234 <when value = "r-base">
235 <expand macro="dynpar" />
236 </when>
237 <when value = "perl">
238 <expand macro="dynpar" />
239 </when>
240 <when value = "bash">
241 <expand macro="builtin_dynpar" />
242 </when>
243 <when value = "sh">
244 <expand macro="builtin_dynpar" />
245 </when>
246 </conditional>
247 <conditional name="ppass">
248 <param name="parampass" type="select" display="radio" label="Command line parameter passing method to use">
249 <option value="argparse" selected="true">Argparse style: on CL in the form of --inputbam="foo.bam" if label below is "inputbam"</option>
250 <option value="positional">Positional: on CL in the order defined on this screen -> "... foo.bam bar.idx zot.xls"</option>
251 <option value="0">No parameters needed because tool reads selected history file from STDIN and writes to STDOUT for history"</option>
252 </param>
253 <when value="0">
254 </when>
255 <when value = "argparse">
256 <expand macro="addpar" />
257 </when>
258 <when value = "positional">
259 <expand macro="addpar" />
260 </when>
261 </conditional>
74 <conditional name="makeMode"> 262 <conditional name="makeMode">
75 <param name="make_Tool" type="select" label="Generate new tool as a tar.gz file ready to upload to a toolshed repository" 263 <param name="make_Tool" type="select" display="radio" label="Generate new tool as a tar.gz file ready to upload to a toolshed repository"
76 help="Generate a toolshed archive - upload to a toolshed from where it can be auto-installed via the Galaxy admin functions" 264 help="Generate a toolshed archive - upload to a toolshed from where it can be auto-installed via the Galaxy admin functions"
77 size="60"> 265 size="60">
78 <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option> 266 <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option>
79 <option value="" selected="true">No. Just run the script please</option> 267 <option value="" selected="true">No. Just run the script please</option>
80 </param> 268 </param>
92 <mapping initial="none"/> 280 <mapping initial="none"/>
93 </sanitizer> 281 </sanitizer>
94 </param> 282 </param>
95 <repeat name="citations" title="Citation"> 283 <repeat name="citations" title="Citation">
96 <conditional name="citation_type"> 284 <conditional name="citation_type">
97 <param name="type" type="select" label="Citation Type"> 285 <param name="type" type="select" display="radio" label="Citation Type">
98 <option value="doi">DOI</option> 286 <option value="doi">DOI</option>
99 <option value="bibtex">BibTeX</option> 287 <option value="bibtex">BibTeX</option>
100 </param> 288 </param>
101 <when value="doi"> 289 <when value="doi">
102 <param name="doi" label="DOI" type="text" value="" 290 <param name="doi" label="DOI" type="text" value=""
112 </sanitizer> 300 </sanitizer>
113 </param> 301 </param>
114 </when> 302 </when>
115 </conditional> 303 </conditional>
116 </repeat> 304 </repeat>
117 <param name="include_deps" type="select" label="Include ghostscript and graphicsmagick dependencies in generated tool" size="60"
118 help="If an HTML file is being created, including dependencies is recommended. Otherwise this setting has no effect">
119 <option value="">Rely on system ghostscript and graphicsmagick rather than include these as dependencies</option>
120 <option value="yes" selected="true">Include dependencies so target installations will always work if HTML is being generated</option>
121 </param>
122 </when> 305 </when>
123 <when value = ""> 306 <when value = "">
124 </when> 307 </when>
125 </conditional> 308 </conditional>
126 <param name="make_HTML" type="select" label="Create an HTML report with links to every output file your script writes to the current directory" size="60"
127 help="Recommended for presenting complex outputs in an accessible manner. Turn off for simple tools so they just create one output">
128 <option value="yes">Yes, arrange and link all output files written by my script to the current directory as an HTML page</option>
129 <option value="" selected="true">No, no HTML output file thanks</option>
130 </param>
131 <param name="make_TAB" type="select" label="Create a new (default tabular) history output with or without an HTML file specified above"
132 help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes">
133 <option value="yes" selected="true">My script writes to a new history output</option>
134 <option value="">I do not want a new history output file</option>
135 </param>
136 <param name="output_format" type="select" multiple="false" label="Select the datatype that your tool/script emits as output"
137 help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
138 <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
139 <column name="value" index="0"/>
140 </options>
141 </param>
142 <conditional name="interp">
143 <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host">
144 <option value="Rscript" selected="true">Rscript</option>
145 <option value="python">python</option>
146 <option value="perl">perl</option>
147 <option value="bash">bash</option>
148 <option value="sh">sh</option>
149 </param>
150 <when value="Rscript">
151 <param name="envpath" type="select" label="Interpreter to use" dynamic_options="find_packages(prefix='package_r_')"
152 help = "Select the R interpreter to use when running this code - should show all installed tool shed package_r_..." />
153 </when>
154 <when value="python">
155 <param name="envpath" type="select" label="Interpreter to use" dynamic_options="find_packages(prefix='package_python_')"
156 help = "Select the python dependency to use when running this code - should show all installed tool shed package_python_..." />
157 </when>
158 <when value="perl">
159 <param name="envpath" type="select" label="Interpreter to use" dynamic_options="find_packages(prefix='package_perl_')"
160 help = "Select the Perl interpreter to use when running this code - should show all installed tool shed package_perl_..." />
161 </when>
162 <when value="bash">
163 <param name="envpath" type="hidden" value="system" />
164 </when>
165 <when value="sh">
166 <param name="envpath" type="hidden" value="system" />
167 </when>
168 </conditional>
169 <param name="edit_params" type="select" label="Add all additional parameters to the generated tool form so they are user editable?"
170 help="If no (default), users will NOT be able to alter any additional parameters. If yes, these will appear on the tool form as text fields with no validation or sanitizing">
171 <option value="yes">Yes, allow user to edit all additional parameters on the generated tool form</option>
172 <option value="no" selected="true">No - use the fixed values for all additional parameters - no user editing</option>
173 </param>
174 <repeat name="additional_parameters" title="Pass additional parameters to the script"
175 help="See examples below to see how these can be parsed by scripts in the various languages">
176 <param name="param_name" type="text" value="parameter_name" label="Choose the name for this parameter" size="60">
177 <sanitizer invalid_char="">
178 <valid initial="string.letters,string.digits"/>
179 <mapping initial="none"/>
180 </sanitizer>
181 </param>
182 <param name="param_type" type="select" label="Select the type for this parameter">
183 <option value="text" selected="true">text</option>
184 <option value="integer">integer</option>
185 <option value="float">float</option>
186 <option value="file">file</option>
187 <option value="library_data">library_data</option>
188 </param>
189 <param name="param_value" type="text" value="parameter_value" label="Enter this parameter's default value" size="60"
190 help="Note that commas and double quotes cannot be used in this text field - please work around this technical limitation" >
191 <sanitizer invalid_char="">
192 <valid initial="string.printable"> <remove value=','/> <remove value='"'/> </valid>
193 <mapping initial="none"/>
194 </sanitizer>
195 </param>
196 <param name="param_label" type="text" value="parameter_label" label="Enter this parameter's label for the form" size="60"
197 help="Note that commas and double quotes cannot be used in this text field - please creatively work around this technical limitation" >
198 <sanitizer invalid_char="">
199 <valid initial="string.printable"> <remove value=','/> <remove value='"'/> </valid>
200 <mapping initial="none"/>
201 </sanitizer>
202 </param>
203 <param name="param_help" type="text" value="parameter_help" label="Help for this parameter"
204 help="Note that commas and double quotes cannot be used in this text field - please work around this technical limitation" size="60">
205 <sanitizer invalid_char="">
206 <valid initial="string.printable"> <remove value=','/> <remove value='"'/> </valid>
207 <mapping initial="none"/>
208 </sanitizer>
209 </param>
210 </repeat>
211 <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="20x120"
212 help="Script must deal with three command line parameters: please cut and paste from examples below for the appropriate scripting language">
213 <sanitizer>
214 <valid initial="string.printable">
215 </valid>
216 <mapping initial="none"/>
217 </sanitizer>
218 </param>
219 </inputs> 309 </inputs>
220 <outputs> 310 <outputs>
221 <data name="output1" label="${tool_name}.${output_format}" format="tabular" metadata_source="input_tab"> 311 <data name="output1" label="${tool_name}.${output_format}" format="tabular" metadata_source="input_file">
222 <filter>make_TAB=="yes"</filter>
223 <actions> 312 <actions>
224 <action type="format"> 313 <action type="format">
225 <option type="from_param" name="output_format" /> 314 <option type="from_param" name="output_format" />
226 </action> 315 </action>
227 </actions> 316 </actions>
228 </data> 317 </data>
229 <data format="html" name="html_file" label="${tool_name}.html">
230 <filter>make_HTML == "yes"</filter>
231 </data>
232 <data format="toolshed.gz" name="new_tool" label="${tool_name}.toolshed.gz"> 318 <data format="toolshed.gz" name="new_tool" label="${tool_name}.toolshed.gz">
233 <filter>makeMode['make_Tool'] == "yes"</filter> 319 <filter>makeMode['make_Tool'] == "yes"</filter>
234 </data> 320 </data>
235 </outputs> 321 </outputs>
236 <configfiles> 322
237 <configfile name="runme">$dynScript</configfile>
238 <configfile name="helpme">
239 #if $makeMode.make_Tool == "yes":
240 ${makeMode.help_text}
241 #end if
242 </configfile>
243 <configfile name="citeme">
244 #if $makeMode.make_Tool == "yes":
245 #for $citation in $makeMode.citations:
246 #if $citation.citation_type.type == "bibtex":
247 **ENTRY**bibtex
248 ${citation.citation_type.bibtex}
249 #else
250 **ENTRY**doi
251 ${citation.citation_type.doi}
252 #end if
253 #end for
254 #end if
255 </configfile>
256 </configfiles>
257 <tests> 323 <tests>
258 <test> 324 <test>
259 <param name='input_tab' value='tf2_test_in.xls' ftype='tabular' /> 325 <param name='input_files' value='infile.tabular' ftype='tabular' />
260 <param name='tool_name' value='tf2_test' /> 326 <param name='script_path' value='runme.py' />
327 <param name='tool_name' value='reverseargp2_test1' />
261 <param name='make_Tool' value='yes' /> 328 <param name='make_Tool' value='yes' />
262 <param name='tool_version' value='0.01' /> 329 <param name='tool_version' value='0.01' />
263 <param name="tool_desc" value='testing_tf2' /> 330 <param name="tool_desc" value='testing_tf2' />
264 <param name="help_text" value='help text goes here' /> 331 <param name="help_text" value='help text goes here' />
265 <param name='include_deps' value='yes' />
266 <param name="make_HTML" value="yes" />
267 <param name="make_TAB" value="yes" />
268 <param name="output_format" value="tabular" /> 332 <param name="output_format" value="tabular" />
269 <param name="input_formats" value="tabular" /> 333 <param name="input_formats" value="tabular" />
270 <param name="interpreter" value='python' /> 334 <param name="interpreter" value='python' />
271 <param name="envpath" value='system' /> 335 <output name='output1' file='reverseargp2_test1_output.xls' compare='diff' lines_diff = '10'/>
272 <param name="runme" value="tf2_test_runme.py"/> 336 <output name='new_tool' file="reverseargp2.toolshed.gz" compare="sim_size" delta="600" />
273 <output name='output1' file='tf2_test_out.xls' compare='diff' lines_diff = '10'/>
274 <output name='html_file' file="tf2_test.html" compare='diff' lines_diff = '10'/>
275 <output name='new_tool' file="tf2_test.toolshed.gz" compare="sim_size" delta="600" />
276 </test> 337 </test>
277 </tests> 338 </tests>
278 <help> 339 <help>
279 340
280 .. class:: warningmark 341 .. class:: warningmark
287 348
288 **If you find a bug** 349 **If you find a bug**
289 Please raise an issue at the bitbucket repository GTFI_ 350 Please raise an issue at the bitbucket repository GTFI_
290 351
291 **What it does** 352 **What it does**
292 This tool enables a user to paste and submit an arbitrary R/python/perl script to Galaxy passing 353 This tool optionally generates normal workflow compatible first class Galaxy tools
293 any number of input files and their metadata names to the script for use in (eg) summaries or reports. 354
294 This allows quick generation of tools capable of taking some arbitrary number of user selected inputs 355 Generated tools can run existing binary packages that become requirements, existing scripts, or new scripts pasted into this tool form.
295 for the "reduce" step of a map-reduce HPC model. 356 Pasted scripts are written so they are part of the new tool and cannot be adjusted by the downstream user.
296 357 Binary packages are managed by the dependency subsystem - conda usually, so anything in bioconda or conda_forge is available for example.
297 **Input options** 358
298 This version allows multiple input file selected from the history - their paths and metadata names 359 Any number of parameters can be built into the new tool form for passing in to the script or executable at runtime.
299 are provided to your script - see the examples below for each scripting language. Python uses argparse. 360 These can be editable by the downstream user or baked in.
300 Rscript uses some code to create all the command line variables. Parameters are injected into the bash/sh 361
301 execution environment so they magically "appear" as $ prefixed variables and will also be found on the 362 When you run this tool, your executable or script and supplied parameter values will be run to produce a canonical
302 command line as parameters to be parsed if that's your preference. 363 set of outputs - these are used to construct a test for the new tool.
303 Note that additional parameters are NOT presented to the user of the generated tool but are frozen with the script. 364
304 If there's demand, it would not be too hard to add them to the generated script... 365 If tool generation is required, a new tarball compatible with any Galaxy toolshed is created.
305 366 It can be unpacked in your galaxy/tools directory and manually added to tool_conf.xml, or
306 **Output options** 367 installed into any toolshed from where it can be installed into your Galaxy.
307 Optional script outputs include one single new history tabular file and for scripts that create multiple file reports 368
308 or analyses, an Html page linking every file and image created by the script can be automatically generated.
309
310 **Tool Generation option**
311 Once the script is working with test data, this tool will optionally generate a new Galaxy tool in a Tool Shed (gzip) repository file
312 ready to upload to your local toolshed for sharing and installation.
313 Provide a small sample input when you run generate the tool because it will become the input for the generated functional test.
314 369
315 .. class:: warningmark 370 .. class:: warningmark
316 371
317 **Note to system administrators** 372 **Note to system administrators**
318 This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances. 373 This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.
321 .. class:: warningmark 376 .. class:: warningmark
322 377
323 **Use on public servers** is STRONGLY discouraged for obvious reasons 378 **Use on public servers** is STRONGLY discouraged for obvious reasons
324 379
325 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. 380 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.
326 We recommend that you follow the good code hygiene practices associated with safe toolshed. 381 We recommend that you follow the good code hygiene practices associated with safe toolshed practices.
327 382
328 **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 383 Here's a sample python script that can be cut and pasted into the tool form, suitable for positional parameter passing:
329 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. 384
330 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. 385 ::
331 This can be handy for complex scripts creating lots of output. 386
332 387 # reverse order of text by row
333 <![CDATA[ 388 import sys
334 389 inp = sys.argv[1]
335 **Multiple inputs** 390 outp = sys.argv[2]
336 391 i = open(inp,'r').readlines()
337 Your script will receive up to 3 named parameters 392 o = open(outp,'w')
338 INPATHS is a comma separated list of input file paths 393 for row in i:
339 INNAMES is a comma separated list of input file names in the same order 394 rs = row.rstrip()
340 OUTPATH is optional if a file is being generated, your script should write there 395 rs = list(rs)
341 Your script should open and write files in the provided working directory if you are using the Html 396 rs.reverse()
342 automatic presentation option. 397 o.write(''.join(rs))
343 398 o.write('\n')
344 Python script command lines will have --INPATHS and --additional_arguments etc. to make it easy to use argparse 399 o.close()
345 400
346 Rscript will need to use commandArgs(TRUE) - see the example below - additional arguments will 401 With argparse style parameters:
347 appear as themselves - eg foo="bar" will mean that foo is defined as "bar" for the script. 402
348 403 ::
349 Bash and sh will see any additional parameters on their command lines and the 3 named parameters 404
350 in their environment magically - well, using env on the CL 405 # reverse order of text by row
351 406 import argparse
352 ***python***:: 407 parser = argparse.ArgumentParser()
353 408 a = parser.add_argument
354 # argparse for 3 possible comma separated lists 409 a('--infile',default='')
355 # additional parameters need to be parsed ! 410 a('--outfile',default=None)
356 # then echo parameters to the output file 411 args = parser.parse_args()
357 import sys 412 inp = args.infile
358 import os 413 outp = args.outfile
359 import argparse 414 i = open(inp,'r').readlines()
360 415 o = open(outp,'w')
361 argp=argparse.ArgumentParser() 416 for row in i:
362 argp.add_argument('--innames',default=None) 417 rs = row.rstrip()
363 argp.add_argument('--inpaths',default=None) 418 rs = list(rs)
364 argp.add_argument('--outpath',default=None) 419 rs.reverse()
365 argp.add_argument('--additional_parameters',default=[],action="append") 420 o.write(''.join(rs))
366 argp.add_argument('otherargs', nargs=argparse.REMAINDER) 421 o.write('\n')
367 args = argp.parse_args() 422 o.close()
368 opath = args.outpath 423
369 odir = os.path.split(opath)[0]
370 try:
371 os.makedirs(odir)
372 print '### made',odir
373 except:
374 pass
375 f= open(opath,'w')
376 s = '### args=%s\n' % str(args)
377 f.write(s)
378 s = 'sys.argv=%s\n' % sys.argv
379 f.write(s)
380 f.close()
381
382
383 ***Rscript***::
384
385 # tool factory Rscript parser suggested by Forester
386 # http://www.r-bloggers.com/including-arguments-in-r-cmd-batch-mode/
387 # additional parameters will appear in the ls() below - they are available
388 # to your script
389 # echo parameters to the output file
390 ourargs = commandArgs(TRUE)
391 if(length(ourargs)==0){
392 print("No arguments supplied.")
393 }else{
394 for(i in 1:length(ourargs)){
395 eval(parse(text=ourargs[[i]]))
396 }
397 sink(OUTPATH)
398 cat('INPATHS=',INPATHS,'\n')
399 cat('INNAMES=',INNAMES,'\n')
400 cat('OUTPATH=',OUTPATH,'\n')
401 x=ls()
402 cat('all objects=',x,'\n')
403 sink()
404 }
405 sessionInfo()
406 print.noquote(date())
407
408
409 ***bash/sh***::
410
411 # tool factory sets up these environmental variables
412 # this example writes those to the output file
413 # additional params appear on command line
414 if [ ! -f "$OUTPATH" ] ; then
415 touch "$OUTPATH"
416 fi
417 echo "INPATHS=$INPATHS" >> "$OUTPATH"
418 echo "INNAMES=$INNAMES" >> "$OUTPATH"
419 echo "OUTPATH=$OUTPATH" >> "$OUTPATH"
420 echo "CL=$@" >> "$OUTPATH"
421
422 ***perl***::
423
424 (my $INPATHS,my $INNAMES,my $OUTPATH ) = @ARGV;
425 open(my $fh, '>', $OUTPATH) or die "Could not open file '$OUTPATH' $!";
426 print $fh "INPATHS=$INPATHS\n INNAMES=$INNAMES\n OUTPATH=$OUTPATH\n";
427 close $fh;
428
429
430 ]]>
431
432
433 424
434 Paper_ : 425 Paper_ :
435 426
436 Creating re-usable tools from scripts: The Galaxy Tool Factory 427 Creating re-usable tools from scripts: The Galaxy Tool Factory
437 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team 428 Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team