changeset 41:8d28e32c71ff draft

Uploaded
author fubar
date Fri, 29 Aug 2014 01:50:44 -0400
parents 8603867451d8
children 4b807bc775ad
files README.txt rgToolFactory.py rgToolFactory.xml
diffstat 3 files changed, 43 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/README.txt	Thu Aug 28 06:18:31 2014 -0400
+++ b/README.txt	Fri Aug 29 01:50:44 2014 -0400
@@ -16,6 +16,14 @@
 freeze the supplied script into a new, ordinary Galaxy tool that runs it over a single input file, 
 working just like any other Galaxy tool for your users. 
 
+If you use the Html output option, please ensure that sanitize_all_html is set to False and 
+uncommented in universe_wsgi.ini - it should show:
+
+# By default, all tool output served as 'text/html' will be sanitized
+sanitize_all_html = False
+
+*More Detail*
+
 To use the ToolFactory, you should have prepared a script to paste into a text box,
 and a small test input example ready to select from your history to test your new script.
 There is an example in each scripting language on the Tool Factory form. You can just
@@ -40,31 +48,6 @@
 
 Tool factory tools are perfect for workflow components. One input, one output, no variables.
 
-*Reasons to read further*
-
-If you use Galaxy to support your research;
-
-You and fellow users are sometimes forced to take data out of Galaxy, process it with ugly
-little perl/awk/sed/R... scripts and put it back;
-
-You do this when you can't do some transformation in Galaxy (the 90/10 rule);
-
-You don't have enough developer resources for wrapping dozens of even relatively simple tools;
-
-Your research and your institution would be far better off if those feral scripts were all tucked 
-safely in your local toolshed and Galaxy histories.
-
-*The good news* If it can be trivially scripted, it can be running safely in your
-local Galaxy via your own local toolshed in a few minutes - with functional tests.
-
-
-*Value proposition* The ToolFactory allows Galaxy to efficiently take over most of your lab's 
-dark script matter, making it reproducible in Galaxy and shareable through the ToolShed.
-
-That's what this tool does. You paste a simple script and the tool returns 
-a new, real Galaxy tool, ready to be installed from the local toolshed to local servers.
-Scripts can be wrapped and online literally within minutes.
-
 *To fully and safely exploit the awesome power* of this tool, Galaxy and the ToolShed,
 you should be a developer installing this tool on a private/personal/scratch local instance where you 
 are an admin_user. Then, if you break it, you get to keep all the pieces
@@ -72,9 +55,10 @@
 
 ** Installation **
 This is a Galaxy tool. You can install it most conveniently using the administrative "Search and browse tool sheds" link.
-Find the Galaxy Test toolshed (not main) and search for the toolfactory repository.
+Find the Galaxy Main toolshed at https://toolshed.g2.bx.psu.edu/ and search for the toolfactory repository.
 Open it and review the code and select the option to install it.
 
+(
 If you can't get the tool that way, the xml and py files here need to be copied into a new tools 
 subdirectory such as tools/toolfactory Your tool_conf.xml needs a new entry pointing to the xml 
 file - something like::
@@ -85,11 +69,8 @@
 
 If not already there (I just added it to datatypes_conf.xml.sample), please add:
 <datatype extension="toolshed.gz" type="galaxy.datatypes.binary:Binary" mimetype="multipart/x-gzip" subclass="True" />
-to your local data_types_conf.xml. 
-
-Ensure that html sanitization is set to False and uncommented in universe_wsgi.ini
-
-You'll have to restart the server for the new tool to be available.
+to your local data_types_conf.xml.
+)
 
 Of course, R, python, perl etc are needed on your path if you want to test scripts using those interpreters.
 Adding new ones to this tool code should be easy enough. Please make suggestions as bitbucket issues and code.
@@ -137,18 +118,6 @@
 
 Patches and suggestions welcome as bitbucket issues please? 
 
-long route to June 2012 product
-derived from an integrated script model  
-called rgBaseScriptWrapper.py
-Note to the unwary:
-  This tool allows arbitrary scripting on your Galaxy as the Galaxy user
-  There is nothing stopping a malicious user doing whatever they choose
-  Extremely dangerous!!
-  Totally insecure. So, trusted users only
-
-
-
-
 copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012
 
 all rights reserved
--- a/rgToolFactory.py	Thu Aug 28 06:18:31 2014 -0400
+++ b/rgToolFactory.py	Fri Aug 29 01:50:44 2014 -0400
@@ -7,6 +7,10 @@
 # Licensed under the LGPL
 # suggestions for improvement and bug fixes welcome at https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home
 #
+# August 2014 
+# merged John Chilton's citation addition and ideas from Marius van den Beek to enable arbitrary
+# data types for input and output - thanks!
+#
 # march 2014
 # had to remove dependencies because cross toolshed dependencies are not possible - can't pre-specify a toolshed url for graphicsmagick and ghostscript
 # grrrrr - night before a demo
@@ -197,8 +201,8 @@
             a('-') # stdin
         a(opts.input_tab)
         a(opts.output_tab)
-        self.outFormats = 'tabular' # TODO make this an option at tool generation time
-        self.inputFormats = 'tabular,txt' # TODO make this an option at tool generation time
+        self.outputFormat = self.opts.output_format
+        self.inputFormats = self.opts.input_formats 
         self.test1Input = '%s_test1_input.xls' % self.toolname
         self.test1Output = '%s_test1_output.xls' % self.toolname
         self.test1HTML = '%s_test1_output.html' % self.toolname
@@ -290,17 +294,17 @@
         tooltestsTabOnly = """
         <tests>
         <test>
-        <param name="input1" value="%(test1Input)s" ftype="tabular"/>
+        <param name="input1" value="%(test1Input)s" ftype="%(inputFormats)s"/>
         <param name="job_name" value="test1"/>
         <param name="runMe" value="$runMe"/>
-        <output name="tab_file" file="%(test1Output)s" ftype="tabular"/>
+        <output name="tab_file" file="%(test1Output)s" ftype="%(outputFormat)s"/>
         </test>
         </tests>
         """
         tooltestsHTMLOnly = """
         <tests>
         <test>
-        <param name="input1" value="%(test1Input)s" ftype="tabular"/>
+        <param name="input1" value="%(test1Input)s" ftype="%(inputFormats)s"/>
         <param name="job_name" value="test1"/>
         <param name="runMe" value="$runMe"/>
         <output name="html_file" file="%(test1HTML)s" ftype="html" lines_diff="5"/>
@@ -309,15 +313,17 @@
         """
         tooltestsBoth = """<tests>
         <test>
-        <param name="input1" value="%(test1Input)s" ftype="tabular"/>
+        <param name="input1" value="%(test1Input)s" ftype="%(inputFormats)s"/>
         <param name="job_name" value="test1"/>
         <param name="runMe" value="$runMe"/>
-        <output name="tab_file" file="%(test1Output)s" ftype="tabular" />
+        <output name="tab_file" file="%(test1Output)s" ftype="%(outputFormat)s" />
         <output name="html_file" file="%(test1HTML)s" ftype="html" lines_diff="10"/>
         </test>
         </tests>
         """
         xdict = {}
+        xdict['outputFormat'] = self.outputFormat
+        xdict['inputFormats'] = self.inputFormats
         xdict['requirements'] = ''
         if self.opts.make_HTML:
             if self.opts.include_dependencies == "yes":
@@ -383,7 +389,7 @@
             xdict['command_outputs'] += ' --output_dir "./"' 
         if self.opts.output_tab <> 'None':
             xdict['command_outputs'] += ' --output_tab "$tab_file"'
-            xdict['outputs'] += ' <data format="%s" name="tab_file" label="${job_name}"/>\n' % self.outFormats
+            xdict['outputs'] += ' <data format="%s" name="tab_file" label="${job_name}"/>\n' % self.outputFormat
         xdict['command'] = newCommand % xdict
         xmls = newXML % xdict
         xf = open(self.xmlfile,'w')
@@ -693,7 +699,9 @@
     a('--output_dir',default='./')
     a('--output_html',default=None)
     a('--input_tab',default="None")
+    a('--input_formats',default="tabular,text")
     a('--output_tab',default="None")
+    a('--output_format',default="tabular")
     a('--user_email',default='Unknown')
     a('--bad_user',default=None)
     a('--make_Tool',default=None)
--- a/rgToolFactory.xml	Thu Aug 28 06:18:31 2014 -0400
+++ b/rgToolFactory.xml	Fri Aug 29 01:50:44 2014 -0400
@@ -12,6 +12,7 @@
      --tool_name "$tool_name"  --user_email "$__user_email__"
     #if $make_TAB.value=="yes":
        --output_tab "$tab_file"
+       --output_format "$output_format"
     #end if
     #if $makeMode.make_Tool=="yes":
       --make_Tool "$makeMode.make_Tool"
@@ -33,12 +34,19 @@
     #end if
     #if $input1 != 'None':
        --input_tab "$input1"
+       --input_formats "$input_formats"
     #end if
 #end if 
   </command>
   <inputs>
     <param name="input1"  type="data"  label="Select an input file from your history" optional="true" size="120"
        help="Most scripts will need an input - your script MUST be ready for whatever format you choose"/>
+    <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts as input"
+    help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
+     <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
+        <column name="value" index="0"/>
+     </options>
+    </param>
     <param name="tool_name" type="text" value="My dynamic script"   label="New tool ID and title for outputs" size="60"
          help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">
         <sanitizer invalid_char="">
@@ -80,8 +88,8 @@
                         help="Supply a DOI (e.g. 10.1111/j.1740-9713.2007.00258.x) that should be cited when this tool is used in published research." />
                     </when>
                     <when value="bibtex">
-                        <param name="bibtex" label="BibTex" type="text" area="true"
-             size="8x120" help="Supply a BibTex entry that should be cited when this tool is used in published research." value="" >
+                        <param name="bibtex" label="BibTex" type="text" area="true" size="8x120"
+                            help="Supply a BibTex entry that should be cited when this tool is used in published research." value="" >
                             <sanitizer>
                                 <valid initial="string.printable">
                                 </valid>
@@ -105,7 +113,8 @@
         <option value="yes" selected="true">My script writes to a new history output</option>
         <option value="">I do not want a new history output file</option>
     </param>
-   <param name="out_format" type="select" label="Select the datatype that your tool/script produces" help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
+   <param name="output_format" type="select" label="Select the datatype for the file your tool/script will write"
+     help="If your datatype is not listed here, it has to be added in galaxy's datatypes_conf.xml">
      <options from_parameter="tool.app.datatypes_registry.upload_file_formats">
         <column name="value" index="0"/>
      </options>
@@ -114,6 +123,7 @@
         <option value="Rscript" selected="true">Rscript</option>
         <option value="python">python</option>
         <option value="perl">perl</option>
+        <option value="bash">bash</option>
         <option value="sh">sh</option>
     </param>   
     <param name="dynScript" label="Cut and paste the script to be executed here" type="text" value="" area="True" size="8x120"  
@@ -126,11 +136,11 @@
      </param>
   </inputs>
   <outputs>
-    <data format="input" name="tab_file" label="${tool_name}.${out_format}">
+    <data format="input" name="tab_file" label="${tool_name}.${output_format}">
       <filter>make_TAB == "yes"</filter>
         <actions>
           <action type="format">
-                <option type="from_param" name="out_format" />
+                <option type="from_param" name="output_format" />
           </action>
         </actions>
     </data>