view rgToolFactory.xml @ 10:71f2ac0eee95

Updated tarball with some test material - still need code generated... Completed a round trip test via a local toolshed. Awsome
author ross lazarus ross.lazarus@gmail.com
date Sat, 02 Jun 2012 22:40:33 +1000
parents e09c76551bed
children a0a5d0757e39
line wrap: on
line source

<tool id="rgTF" name="Tool Factory" version="0.04">
  <description>Makes scripts into tools</description>
  <command interpreter="python">
#if ( $__user_email__ not in ['ross.lazarus@gmail.com',] ):
     rgToolFactory.py --bad_user $__user_email__
  #else:
    rgToolFactory.py --script_path "$runme" --interpreter "$interpreter" 
     --tool_name "$tool_name"  
    #if $make_HTML.value=="yes" or $factory.make_Tool=="yes":
      --output_dir "$html_file.files_path" --output_html "$html_file"
    #end if
    #if $input1 != 'None':
       --input_tab "$input1"
    #end if
    #if $make_HTML.value=="yes":
    --make_HTML "yes"
    #end if
    #if $make_TAB.value=="yes":
      --output_tab "$tab_file"
    #end if
    #if $factory.make_Tool=="yes":
      --make_Tool "$factory.make_Tool"
      --help_text "$helpme"
      --tool_desc "$factory.tool_desc"
    #end if
#end if 
  </command>
  <inputs>
    <param name="input1"  type="data" format="tabular" label="Select an optional input tabular file from your history" optional="true"
       help="Your script probably needs an input - but if not, this can be left unassigned"/>
    <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"/>
    <conditional name="factory">
        <param name="make_Tool" type="select" label="Create a tar.gz file ready for local toolshed entry" help="Ready to deploy securely!">
        <option value="yes">Yes</option>
        <option value="" selected="true">Not yet, it's still broken</option>
        </param>
        <when value = "yes">
            <param name="tool_desc" type="text" width="120" value="" help="Supply a brief tool description for the Galaxy tool menu entry (optional - appears after the tool name)" />
            <param name="help_text" type="text" area="true" size="8x80" width="120" value="**What it Does**" help="Supply the brief user documentation to appear on the new tool form as reStructured text" >           
                <sanitizer>
                    <valid initial="string.printable">
                    </valid>
                    <mapping initial="none"/>
                </sanitizer>
            </param>
        </when>
    </conditional> 
    <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" 
         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">
        <option value="yes">Yes</option>
        <option value="" selected="true">No</option>
    </param>   
    <param name="make_TAB" type="select" label="Create a new tabular history output" 
         help="This is useful if your script creates a single new tabular file you want to appear in the history after the tool executes">
        <option value="yes" selected="true">Yes</option>
        <option value="">No</option>
    </param>   
    <param name="interpreter" type="select" label="Select the interpreter for your code. This must be available on the path of the execution host">
        <option value="Rscript" selected="true">Rscript</option>
        <option value="python">python</option>
        <option value="perl (ugh)">perl</option>
    </param>   
    <param name="dynScript" label="Your Script Goes Here" type="text" value="" area="True" size="8x80" width="80" 
      help="Expect FIRST CL parameter = the optional input tabular file path (or NONE if not specified). Ensure your script writes tabular output to the path in the SECOND command line parameter it gets.">
      <sanitizer>
         <valid initial="string.printable">
         </valid>
         <mapping initial="none"/>
      </sanitizer>
     </param>
  </inputs>
  <outputs>
    <data format="tabular" name="tab_file" label="${tool_name}.xls">
        <filter> make_TAB=="yes" </filter>
    </data>
    <data format="html" name="html_file" label="${tool_name}.html">
        <filter>make_HTML=="yes" or factory.make_Tool=="yes"</filter>
    </data>
  </outputs>
<configfiles>
<configfile name="runme">
${dynScript}
</configfile>

<configfile name="helpme">
#if $factory.make_Tool == "yes":
$factory.help_text
#end if
</configfile>
</configfiles>
<help>
**What it does**
This tool enables a user to paste and submit an arbitrary R/python/perl script to run in Galaxy.

**Restrictions**
This tool will ONLY work if your user id has been added to the local copy's list of permitted users.
It should only ever be used on a private, personal Galaxy instance and you should edit this tool's source so your local login
is authorised to use it - *it will not run otherwise*

.. class:: warningmark

**Note to system administrators** Under no circumstances should you allow any user to use this tool unless you really, really trust them to do
no harm. This tool (extremely) insecure and is only recommended for private/personnal Galaxy instances.

Once you get the script working on some test data, you can generate a complete ready to run
Galaxy tool by setting the "Make tool" option to Yes. The resulting tarball will be ready to install
It will run just as securely as any other normal Galaxy tool - unlike this one used to generate it.

.. class:: warningmark

**Use on public servers**  is STRONGLY discouraged for obvious reasons

**Scripting conventions**
The pasted script will be executed. 
It will get the path to the (optional) input tabular data file path or NONE if you do not select one
as the first command line parameter

The script must write it's output as tab delimited text to the path found as the second command line parameter
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. 
Any pdf images will automagically be converted to show thumbnails in that output.
This can be handy for complex scripts creating lots of output.

**Simple Rscript example**

A simple "filter" that takes an input file, does something and writes the results to a new tabular file might look like this::

 ourargs = commandArgs(TRUE)
 inf = ourargs[1]
 outf = ourargs[2]
 inp = read.table(inf,head=F,row.names=NULL,sep='\t')
 outp = t(inp)
 write.table(outp,outf, quote=FALSE, sep="\t",row.names=F,col.names=F)

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
turned on for this to work. The heatmap will be presented as a thumbnail linked to the pdf in the resulting HTML page::

 foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))
 bar = as.matrix(foo)
 pdf( "heattest.pdf" )
 heatmap(bar,main='Random Heatmap')
 dev.off()

**Attribution**
Copyright ross lazarus (ross.lazarus at gmail stop com) May 2012 
All rights reserved
Licensed under the LGPL for your pleasure
</help>

</tool>