Next changeset 1:323982517b30 (2015-01-10) |
Commit message:
Initial commit of code in iuc github repository |
added:
LICENSE README.md README.txt images/dynamicScriptTool.png rgToolFactory2.py rgToolFactory2.xml test-data/tf2_test.html test-data/tf2_test.toolshed.gz test-data/tf2_test_in.xls test-data/tf2_test_out.xls test-data/tf2_test_runme.py tool_dependencies.xml |
b |
diff -r 000000000000 -r c34063ab3735 LICENSE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LICENSE Thu Jan 01 21:58:00 2015 -0500 |
b |
b"@@ -0,0 +1,504 @@\n+GNU LESSER GENERAL PUBLIC LICENSE\n+ Version 2.1, February 1999\n+\n+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n+ Everyone is permitted to copy and distribute verbatim copies\n+ of this license document, but changing it is not allowed.\n+\n+(This is the first released version of the Lesser GPL. It also counts\n+ as the successor of the GNU Library Public License, version 2, hence\n+ the version number 2.1.)\n+\n+ Preamble\n+\n+ The licenses for most software are designed to take away your\n+freedom to share and change it. By contrast, the GNU General Public\n+Licenses are intended to guarantee your freedom to share and change\n+free software--to make sure the software is free for all its users.\n+\n+ This license, the Lesser General Public License, applies to some\n+specially designated software packages--typically libraries--of the\n+Free Software Foundation and other authors who decide to use it. You\n+can use it too, but we suggest you first think carefully about whether\n+this license or the ordinary General Public License is the better\n+strategy to use in any particular case, based on the explanations below.\n+\n+ When we speak of free software, we are referring to freedom of use,\n+not price. Our General Public Licenses are designed to make sure that\n+you have the freedom to distribute copies of free software (and charge\n+for this service if you wish); that you receive source code or can get\n+it if you want it; that you can change the software and use pieces of\n+it in new free programs; and that you are informed that you can do\n+these things.\n+\n+ To protect your rights, we need to make restrictions that forbid\n+distributors to deny you these rights or to ask you to surrender these\n+rights. These restrictions translate to certain responsibilities for\n+you if you distribute copies of the library or if you modify it.\n+\n+ For example, if you distribute copies of the library, whether gratis\n+or for a fee, you must give the recipients all the rights that we gave\n+you. You must make sure that they, too, receive or can get the source\n+code. If you link other code with the library, you must provide\n+complete object files to the recipients, so that they can relink them\n+with the library after making changes to the library and recompiling\n+it. And you must show them these terms so they know their rights.\n+\n+ We protect your rights with a two-step method: (1) we copyright the\n+library, and (2) we offer you this license, which gives you legal\n+permission to copy, distribute and/or modify the library.\n+\n+ To protect each distributor, we want to make it very clear that\n+there is no warranty for the free library. Also, if the library is\n+modified by someone else and passed on, the recipients should know\n+that what they have is not the original version, so that the original\n+author's reputation will not be affected by problems that might be\n+introduced by others.\n+\n+ Finally, software patents pose a constant threat to the existence of\n+any free program. We wish to make sure that a company cannot\n+effectively restrict the users of a free program by obtaining a\n+restrictive license from a patent holder. Therefore, we insist that\n+any patent license obtained for a version of the library must be\n+consistent with the full freedom of use specified in this license.\n+\n+ Most GNU software, including some libraries, is covered by the\n+ordinary GNU General Public License. This license, the GNU Lesser\n+General Public License, applies to certain designated libraries, and\n+is quite different from the ordinary General Public License. We use\n+this license for certain libraries in order to permit linking those\n+libraries into non-free programs.\n+\n+ When a program is linked with a library, whether statically or using\n+a shared library, the combination of the two is legally speaking a\n+combined work, a derivative "..b'oes not specify a\n+license version number, you may choose any version ever published by\n+the Free Software Foundation.\n+\n+ 14. If you wish to incorporate parts of the Library into other free\n+programs whose distribution conditions are incompatible with these,\n+write to the author to ask for permission. For software which is\n+copyrighted by the Free Software Foundation, write to the Free\n+Software Foundation; we sometimes make exceptions for this. Our\n+decision will be guided by the two goals of preserving the free status\n+of all derivatives of our free software and of promoting the sharing\n+and reuse of software generally.\n+\n+ NO WARRANTY\n+\n+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\n+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\n+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\n+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY\n+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\n+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\n+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\n+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n+\n+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\n+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\n+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\n+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\n+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\n+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\n+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\n+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\n+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\n+DAMAGES.\n+\n+ END OF TERMS AND CONDITIONS\n+\n+ How to Apply These Terms to Your New Libraries\n+\n+ If you develop a new library, and you want it to be of the greatest\n+possible use to the public, we recommend making it free software that\n+everyone can redistribute and change. You can do so by permitting\n+redistribution under these terms (or, alternatively, under the terms of the\n+ordinary General Public License).\n+\n+ To apply these terms, attach the following notices to the library. It is\n+safest to attach them to the start of each source file to most effectively\n+convey the exclusion of warranty; and each file should have at least the\n+"copyright" line and a pointer to where the full notice is found.\n+\n+ {description}\n+ Copyright (C) {year} {fullname}\n+\n+ This library is free software; you can redistribute it and/or\n+ modify it under the terms of the GNU Lesser General Public\n+ License as published by the Free Software Foundation; either\n+ version 2.1 of the License, or (at your option) any later version.\n+\n+ This library is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ Lesser General Public License for more details.\n+\n+ You should have received a copy of the GNU Lesser General Public\n+ License along with this library; if not, write to the Free Software\n+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301\n+ USA\n+\n+Also add information on how to contact you by electronic and paper mail.\n+\n+You should also get your employer (if you work as a programmer) or your\n+school, if any, to sign a "copyright disclaimer" for the library, if\n+necessary. Here is a sample; alter the names:\n+\n+ Yoyodyne, Inc., hereby disclaims all copyright interest in the\n+ library `Frob\' (a library for tweaking knobs) written by James Random\n+ Hacker.\n+\n+ {signature of Ty Coon}, 1 April 1990\n+ Ty Coon, President of Vice\n+\n+That\'s all there is to it!\n' |
b |
diff -r 000000000000 -r c34063ab3735 README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Thu Jan 01 21:58:00 2015 -0500 |
b |
@@ -0,0 +1,15 @@ +toolfactory_2 +============= + +This is an upgrade to the tool factory but with added parameters +(optionally editable in the generated tool form - otherwise fixed) and multiple input files. + +Any number of parameters up to the limit of your patience with repeat groups +These are optionally editable by the user - names cannot be changed - no overwriting $JAVA_HOME_DIR +or else permanently fixed and not editable at run time. + +Any number of input files can be passed to your script, but of course it +has to deal with them. Both path and metadata name are supplied either in the environment (bash/sh) or +as command line parameters (python,perl,rscript) that need to be parsed and +dealt with in the script. + |
b |
diff -r 000000000000 -r c34063ab3735 README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.txt Thu Jan 01 21:58:00 2015 -0500 |
[ |
b'@@ -0,0 +1,287 @@\n+# WARNING before you start\n+# Install this tool on a private Galaxy ONLY\n+# Please NEVER on a public or production instance\n+# updated august 2014 by John Chilton adding citation support\n+#\n+# updated august 8 2014 to fix bugs reported by Marius van den Beek\n+# please cite the resource at http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&keytype=ref \n+# if you use this tool in your published work.\n+\n+*Short Story*\n+\n+This is an unusual Galaxy tool capable of generating new Galaxy tools.\n+It works by exposing *unrestricted* and therefore extremely dangerous\n+scripting to all designated administrators of the host Galaxy server, allowing them to run scripts \n+in R, python, sh and perl over multiple selected input data sets, writing a single new data set as output.\n+\n+*Automated outputs in named sections*\n+\n+If your script writes to the current directory path, arbitrary mix of (eg) pdfs, tabular analysis results and run logs,\n+the tool factory can optionally auto-generate a linked Html page with separate sections showing a thumbnail grid\n+for all pdfs and the log text, grouping all artifacts sharing a file name and log name prefix::\n+\n+ eg: if "foo.log" is emitted then *all* other outputs matching foo_* will all be grouped together - eg\n+ foo_baz.pdf\n+ foo_bar.pdf and\n+ foo_zot.xls\n+ would all be displayed and linked in the same section with foo.log\'s contents - to form the "Foo" section of the Html page.\n+ Sections appear in alphabetic order and there are no limits on the number of files or sections.\n+\n+*Automated generation of new Galaxy tool shed tools for installation into any Galaxy*\n+\n+Once a script is working correctly, this tool optionally generates a new Galaxy tool, effectively\n+freezing the supplied script into a new, ordinary Galaxy tool that runs it over one or more input files\n+selected by the user. Generated tools are installed via a tool shed by an administrator and work exactly like all other Galaxy tools for your users. \n+\n+If you use the Html output option, please ensure that sanitize_all_html is set to False and \n+uncommented in universe_wsgi.ini - it should show::\n+\n+ # By default, all tool output served as \'text/html\' will be sanitized\n+ sanitize_all_html = False\n+\n+This opens potential security risks and may not be acceptable for public sites where the lack of stylesheets\n+may make Html pages damage onlookers\' eyeballs but should still be correct.\n+\n+\n+*More Detail*\n+\n+To use the ToolFactory, you should have prepared a script to paste into a text box,\n+and a small test input example ready to select from your history to test your new script.\n+There is an example in each scripting language on the Tool Factory form. You can just\n+cut and paste these to try it out - remember to select the right interpreter please. You\'ll\n+also need to create a small test data set using the Galaxy history add new data tool.\n+\n+If the script fails somehow, use the "redo" button on the tool output in your history to\n+recreate the form complete with broken script. Fix the bug and execute again. Rinse, wash, repeat.\n+\n+Once the script runs sucessfully, a new Galaxy tool that runs your script can be generated.\n+Select the "generate" option and supply some help text and names. The new tool will be\n+generated in the form of a new Galaxy datatype - toolshed.gz - as the name suggests,\n+it\'s an archive ready to upload to a Galaxy ToolShed as a new tool repository.\n+\n+Once it\'s in a ToolShed, it can be installed into any local Galaxy server from\n+the server administrative interface.\n+\n+Once the new tool is installed, local users can run it - each time, the script that was supplied\n+when it was built will be executed with the input chosen from the user\'s history. In other words,\n+the tools you generate with the ToolFactory run just like any other Galaxy tool,\n+but run your script every time. \n+\n+Tool factory tools are perfect for workflow components. One input, one output, no variables.\n+\n+'..b'ple without any input file - generates a random heatmap pdf - you must make sure the option to create an HTML output file is\n+turned on for this to work. The heatmap will be presented as a thumbnail linked to the pdf in the resulting HTML page::\n+\n+ # note this script takes NO input or output because it generates random data\n+ foo = data.frame(a=runif(100),b=runif(100),c=runif(100),d=runif(100),e=runif(100),f=runif(100))\n+ bar = as.matrix(foo)\n+ pdf( "heattest.pdf" )\n+ heatmap(bar,main=\'Random Heatmap\')\n+ dev.off()\n+\n+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\n+and pasted into the script box. Note that you can already do this in Galaxy by setting up the cut columns tool with the\n+correct number of columns in reverse order,but this script will work for any number of columns so is completely generic::\n+\n+# reverse order of columns in a tabular file\n+import sys\n+inp = sys.argv[1]\n+outp = sys.argv[2]\n+i = open(inp,\'r\')\n+o = open(outp,\'w\')\n+for row in i:\n+ rs = row.rstrip().split(\'\\t\')\n+ rs.reverse()\n+ o.write(\'\\t\'.join(rs))\n+ o.write(\'\\n\')\n+i.close()\n+o.close()\n+\n+\n+Galaxy as an IDE for developing API scripts\n+If you need to develop Galaxy API scripts and you like to live dangerously, please read on.\n+\n+Galaxy as an IDE?\n+Amazingly enough, blend-lib API scripts run perfectly well *inside* Galaxy when pasted into a Tool Factory form. No need to generate a new tool. Galaxy+Tool_Factory = IDE I think we need a new t-shirt. Seriously, it is actually quite useable.\n+\n+Why bother - what\'s wrong with Eclipse\n+Nothing. But, compared with developing API scripts in the usual way outside Galaxy, you get persistence and other framework benefits plus at absolutely no extra charge, a ginormous security problem if you share the history or any outputs because they contain the api script with key so development servers only please!\n+\n+Workflow\n+Fire up the Tool Factory in Galaxy.\n+\n+Leave the input box empty, set the interpreter to python, paste and run an api script - eg working example (substitute the url and key) below.\n+\n+It took me a few iterations to develop the example below because I know almost nothing about the API. I started with very simple code from one of the samples and after each run, the (edited..) api script is conveniently recreated using the redo button on the history output item. So each successive version of the developing api script you run is persisted - ready to be edited and rerun easily. It is \'\'very\'\' handy to be able to add a line of code to the script and run it, then view the output to (eg) inspect dicts returned by API calls to help move progressively deeper iteratively.\n+\n+Give the below a whirl on a private clone (install the tool factory from the main toolshed) and try adding complexity with few rerun/edit/rerun cycles.\n+\n+Eg tool factory api script\n+import sys\n+from blend.galaxy import GalaxyInstance\n+ourGal = \'http://x.x.x.x:xxxx\'\n+ourKey = \'xxx\'\n+gi = GalaxyInstance(ourGal, key=ourKey)\n+libs = gi.libraries.get_libraries()\n+res = []\n+# libs looks like\n+# u\'url\': u\'/galaxy/api/libraries/441d8112651dc2f3\', u\'id\': u\'441d8112651dc2f3\', u\'name\':.... u\'Demonstration sample RNA data\',\n+for lib in libs: \n+ res.append(\'%s:\\n\' % lib[\'name\'])\n+ res.append(str(gi.libraries.show_library(lib[\'id\'],contents=True)))\n+outf=open(sys.argv[2],\'w\')\n+outf.write(\'\\n\'.join(res))\n+outf.close()\n+\n+**Attribution** \n+Creating re-usable tools from scripts: The Galaxy Tool Factory \n+Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team\n+Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573\n+\n+http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&keytype=ref\n+\n+**Licensing**\n+Copyright Ross Lazarus 2010\n+ross lazarus at g mail period com\n+\n+All rights reserved.\n+\n+Licensed under the LGPL\n+\n+**Obligatory screenshot**\n+\n+http://bitbucket.org/fubar/galaxytoolmaker/src/fda8032fe989/images/dynamicScriptTool.png\n+\n' |
b |
diff -r 000000000000 -r c34063ab3735 images/dynamicScriptTool.png |
b |
Binary file images/dynamicScriptTool.png has changed |
b |
diff -r 000000000000 -r c34063ab3735 rgToolFactory2.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rgToolFactory2.py Thu Jan 01 21:58:00 2015 -0500 |
[ |
b'@@ -0,0 +1,861 @@\n+# rgToolFactoryMultIn.py\n+# see https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home\n+# \n+# copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012\n+# \n+# all rights reserved\n+# Licensed under the LGPL\n+# suggestions for improvement and bug fixes welcome at https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home\n+#\n+# sept 2014 added additional params from\n+# https://bitbucket.org/mvdbeek/dockertoolfactory/src/d4863bcf7b521532c7e8c61b6333840ba5393f73/DockerToolFactory.py?at=default\n+# passing them is complex\n+# and they are restricted to NOT contain commas or double quotes to ensure that they can be safely passed together on \n+# the toolfactory command line as a comma delimited double quoted string for parsing and passing to the script\n+# see examples on this tool form\n+\n+# august 2014\n+\n+# Allows arbitrary number of input files\n+# NOTE positional parameters are now passed to script\n+# and output (may be "None") is *before* arbitrary number of inputs\n+#\n+# march 2014\n+# had to remove dependencies because cross toolshed dependencies are not possible - can\'t pre-specify a toolshed url for graphicsmagick and ghostscript\n+# grrrrr - night before a demo\n+# added dependencies to a tool_dependencies.xml if html page generated so generated tool is properly portable\n+#\n+# added ghostscript and graphicsmagick as dependencies \n+# fixed a wierd problem where gs was trying to use the new_files_path from universe (database/tmp) as ./database/tmp\n+# errors ensued\n+#\n+# august 2013\n+# found a problem with GS if $TMP or $TEMP missing - now inject /tmp and warn\n+#\n+# july 2013\n+# added ability to combine images and individual log files into html output\n+# just make sure there\'s a log file foo.log and it will be output\n+# together with all images named like "foo_*.pdf\n+# otherwise old format for html\n+#\n+# January 2013\n+# problem pointed out by Carlos Borroto\n+# added escaping for <>$ - thought I did that ages ago...\n+#\n+# August 11 2012 \n+# changed to use shell=False and cl as a sequence\n+\n+# This is a Galaxy tool factory for simple scripts in python, R or whatever ails ye.\n+# It also serves as the wrapper for the new tool.\n+# \n+# you paste and run your script\n+# Only works for simple scripts that read one input from the history.\n+# Optionally can write one new history dataset,\n+# and optionally collect any number of outputs into links on an autogenerated HTML page.\n+\n+# DO NOT install on a public or important site - please.\n+\n+# installed generated tools are fine if the script is safe.\n+# They just run normally and their user cannot do anything unusually insecure\n+# but please, practice safe toolshed.\n+# Read the fucking code before you install any tool \n+# especially this one\n+\n+# After you get the script working on some test data, you can\n+# optionally generate a toolshed compatible gzip file\n+# containing your script safely wrapped as an ordinary Galaxy script in your local toolshed for\n+# safe and largely automated installation in a production Galaxy.\n+\n+# If you opt for an HTML output, you get all the script outputs arranged\n+# as a single Html history item - all output files are linked, thumbnails for all the pdfs.\n+# Ugly but really inexpensive.\n+# \n+# Patches appreciated please. \n+#\n+#\n+# long route to June 2012 product\n+# Behold the awesome power of Galaxy and the toolshed with the tool factory to bind them\n+# derived from an integrated script model \n+# called rgBaseScriptWrapper.py\n+# Note to the unwary:\n+# This tool allows arbitrary scripting on your Galaxy as the Galaxy user\n+# There is nothing stopping a malicious user doing whatever they choose\n+# Extremely dangerous!!\n+# Totally insecure. So, trusted users only\n+#\n+# preferred model is a developer using their throw away workstation instance - ie a private site.\n+# no real risk. The universe_wsgi.ini admin_users string is checked - only admin users are permitted to run this tool.\n+#\n+\n+import sys \n+import shutil \n+import subprocess \n+'..b' ste = open(self.elog,\'w\')\n+ sto = open(self.tlog,\'w\')\n+ sto.write(\'## Toolfactory generated command line = %s\\n\' % \' \'.join(self.cl))\n+ sto.flush()\n+ p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=ste,stdin=subprocess.PIPE,cwd=self.opts.output_dir)\n+ else:\n+ p = subprocess.Popen(self.cl,shell=False,stdin=subprocess.PIPE)\n+ p.stdin.write(self.script)\n+ p.stdin.close()\n+ retval = p.wait()\n+ if self.opts.output_dir:\n+ sto.close()\n+ ste.close()\n+ err = open(self.elog,\'r\').readlines()\n+ if retval <> 0 and err: # problem\n+ print >> sys.stderr,err\n+ if self.opts.make_HTML:\n+ self.makeHtml()\n+ return retval\n+\n+ def runBash(self):\n+ """\n+ cannot use - for bash so use self.sfile\n+ """\n+ if self.opts.output_dir:\n+ s = \'## Toolfactory generated command line = %s\\n\' % \' \'.join(self.cl)\n+ sto = open(self.tlog,\'w\')\n+ sto.write(s)\n+ sto.flush()\n+ p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=sto,cwd=self.opts.output_dir)\n+ else:\n+ p = subprocess.Popen(self.cl,shell=False) \n+ retval = p.wait()\n+ if self.opts.output_dir:\n+ sto.close()\n+ if self.opts.make_HTML:\n+ self.makeHtml()\n+ return retval\n+ \n+\n+def main():\n+ u = """\n+ This is a Galaxy wrapper. It expects to be called by a special purpose tool.xml as:\n+ <command interpreter="python">rgBaseScriptWrapper.py --script_path "$scriptPath" --tool_name "foo" --interpreter "Rscript"\n+ </command>\n+ """\n+ op = optparse.OptionParser()\n+ a = op.add_option\n+ a(\'--script_path\',default=None)\n+ a(\'--tool_name\',default=None)\n+ a(\'--interpreter\',default=None)\n+ a(\'--output_dir\',default=\'./\')\n+ a(\'--output_html\',default=None)\n+ a(\'--input_tab\',default=[], action="append") # these are "galaxypath,metadataname" pairs\n+ a("--input_formats",default="tabular")\n+ a(\'--output_tab\',default=None)\n+ a(\'--output_format\',default=\'tabular\')\n+ a(\'--user_email\',default=\'Unknown\')\n+ a(\'--bad_user\',default=None)\n+ a(\'--make_Tool\',default=None)\n+ a(\'--make_HTML\',default=None)\n+ a(\'--help_text\',default=None)\n+ a(\'--tool_desc\',default=None)\n+ a(\'--new_tool\',default=None)\n+ a(\'--tool_version\',default=None)\n+ a(\'--include_dependencies\',default="yes") \n+ a(\'--citations\',default=None)\n+ a(\'--additional_parameters\', dest=\'additional_parameters\', action=\'append\', default=[])\n+ a(\'--edit_additional_parameters\', action="store_true", default=False)\n+ opts, args = op.parse_args()\n+ assert not opts.bad_user,\'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to admin_users in universe_wsgi.ini\' % (opts.bad_user,opts.bad_user)\n+ assert opts.tool_name,\'## Tool Factory expects a tool name - eg --tool_name=DESeq\'\n+ assert opts.interpreter,\'## Tool Factory wrapper expects an interpreter - eg --interpreter=Rscript\'\n+ assert os.path.isfile(opts.script_path),\'## Tool Factory wrapper expects a script path - eg --script_path=foo.R\'\n+ if opts.output_dir:\n+ try:\n+ os.makedirs(opts.output_dir)\n+ except:\n+ pass\n+ opts.input_tab = [x.replace(\'"\',\'\').replace("\'",\'\') for x in opts.input_tab]\n+ for i,x in enumerate(opts.additional_parameters): # remove quotes we need to deal with spaces in CL params\n+ opts.additional_parameters[i] = opts.additional_parameters[i].replace(\'"\',\'\')\n+ r = ScriptRunner(opts)\n+ if opts.make_Tool:\n+ retcode = r.makeTooltar()\n+ else:\n+ retcode = r.run()\n+ os.unlink(r.sfile)\n+ if retcode:\n+ sys.exit(retcode) # indicate failure to job runner\n+\n+\n+if __name__ == "__main__":\n+ main()\n+\n+\n' |
b |
diff -r 000000000000 -r c34063ab3735 rgToolFactory2.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rgToolFactory2.xml Thu Jan 01 21:58:00 2015 -0500 |
[ |
b'@@ -0,0 +1,423 @@\n+<tool id="rgTF2" name="Tool Factory Two" version="1.15">\n+ <description>Scripts into tools</description>\n+ <requirements>\n+ <requirement type="package" version="9.10">ghostscript</requirement>\n+ <requirement type="package" version="1.3.18">graphicsmagick</requirement>\n+ </requirements>\n+ <command interpreter="python">\n+#if ( $__user_email__ not in $__admin_users__ ):\n+ rgToolFactory2.py --bad_user $__user_email__\n+#else:\n+ rgToolFactory2.py --script_path "$runme" --interpreter "$interpreter" \n+ --tool_name "$tool_name" --user_email "$__user_email__" --citations "$citeme"\n+\n+ #if $make_TAB.value=="yes":\n+ --output_tab "$output1"\n+ --output_format "$output_format"\n+ #end if\n+ #if $makeMode.make_Tool=="yes":\n+ --make_Tool "$makeMode.make_Tool"\n+ --tool_desc "$makeMode.tool_desc"\n+ --tool_version "$makeMode.tool_version"\n+ --new_tool "$new_tool"\n+ --help_text "$helpme"\n+ #if $make_HTML.value=="yes":\n+ #if $makeMode.include_deps.value=="yes":\n+ --include_dependencies "yes"\n+ #end if\n+ #end if\n+ #end if\n+ #if $additional_parameters != \'None\':\n+ #if $edit_params.value == "yes":\n+ --edit_additional_parameters\n+ #end if\n+ #for i in $additional_parameters:\n+ --additional_parameters "$i.param_name,$i.param_value,$i.param_label,$i.param_help,$i.param_type"\n+ #end for\n+ #end if\n+ #if $make_HTML.value=="yes":\n+ --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes"\n+ #else:\n+ --output_dir "."\n+ #end if\n+ #if $input_tab != \'None\':\n+ --input_formats "$input_formats"\n+ #for intab in $input_tab:\n+ --input_tab "$intab,$intab.name"\n+ #end for\n+ #end if\n+#end if \n+ </command>\n+ <inputs>\n+ <param name="input_tab" type="data" label="Select one or more input file(s) from your history" optional="true" size="120" multiple="true"\n+ 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"/>\n+ <param name="input_formats" type="select" multiple="true" label="Select the datatype(s) that your tool/script accepts as input"\n+ help="If your datatype is not listed here, it has to be added in galaxy\'s datatypes_conf.xml">\n+ <options from_parameter="tool.app.datatypes_registry.upload_file_formats">\n+ <column name="value" index="0"/>\n+ </options>\n+ </param>\n+ <param name="tool_name" type="text" value="My dynamic script" label="New tool ID and title for outputs" size="60"\n+ help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">\n+ <sanitizer invalid_char="">\n+ <valid initial="string.letters,string.digits">\n+ <add value="_"/>\n+ </valid>\n+ </sanitizer>\n+ </param>\n+ <conditional name="makeMode">\n+ <param name="make_Tool" type="select" label="Generate new tool as a tar.gz file ready to upload to a toolshed repository" \n+ help="Generate a toolshed archive - upload to a toolshed from where it can be auto-installed via the Galaxy admin functions" \n+ size="60">\n+ <option value="yes">Generate a Galaxy ToolShed compatible toolshed.gz</option>\n+ <option value="" selected="true">No. Just run the script please</option>\n+ </param>\n+ <when value = "yes">\n+ <param name="tool_version" label="Tool Version - bump this to warn users trying to redo old analyses" type="text" value="0.01"\n+ help="If you change your script and regenerate the \'same\' tool, you should inform Galaxy (and users) by changing (bumping is traditional) this number"/>\n+ <param name="tool_desc" label="Tool Description" type="text" value="" size="40" \n+ help="Sup'..b' data file path or NONE if you do not select one, and the path to the optional\n+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.\n+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.\n+This can be handy for complex scripts creating lots of output.\n+\n+<![CDATA[\n+\n+**Multiple inputs**\n+\n+Your script will receive up to 3 named parameters\n+INPATHS is a comma separated list of input file paths\n+INNAMES is a comma separated list of input file names in the same order\n+OUTPATH is optional if a file is being generated, your script should write there\n+Your script should open and write files in the provided working directory if you are using the Html\n+automatic presentation option.\n+\n+Python script command lines will have --INPATHS and --additional_arguments etc. to make it easy to use argparse\n+\n+Rscript will need to use commandArgs(TRUE) - see the example below - additional arguments will\n+appear as themselves - eg foo="bar" will mean that foo is defined as "bar" for the script.\n+\n+Bash and sh will see any additional parameters on their command lines and the 3 named parameters\n+in their environment magically - well, using env on the CL\n+\n+***python***::\n+\n+ # argparse for 3 possible comma separated lists\n+ # additional parameters need to be parsed !\n+ # then echo parameters to the output file\n+ import sys\n+ import argparse\n+ argp=argparse.ArgumentParser()\n+ argp.add_argument(\'--INNAMES\',default=None)\n+ argp.add_argument(\'--INPATHS\',default=None)\n+ argp.add_argument(\'--OUTPATH\',default=None)\n+ argp.add_argument(\'--additional_parameters\',default=[],action="append")\n+ argp.add_argument(\'otherargs\', nargs=argparse.REMAINDER)\n+ args = argp.parse_args()\n+ f= open(args.OUTPATH,\'w\')\n+ s = \'### args=%s\\n\' % str(args)\n+ f.write(s)\n+ s = \'sys.argv=%s\\n\' % sys.argv\n+ f.write(s) \n+ f.close()\n+\n+\n+\n+***Rscript***::\n+\n+ # tool factory Rscript parser suggested by Forester\n+ # http://www.r-bloggers.com/including-arguments-in-r-cmd-batch-mode/\n+ # additional parameters will appear in the ls() below - they are available\n+ # to your script\n+ # echo parameters to the output file\n+ ourargs = commandArgs(TRUE)\n+ if(length(ourargs)==0){\n+ print("No arguments supplied.")\n+ }else{\n+ for(i in 1:length(ourargs)){\n+ eval(parse(text=ourargs[[i]]))\n+ }\n+ sink(OUTPATH)\n+ cat(\'INPATHS=\',INPATHS,\'\\n\')\n+ cat(\'INNAMES=\',INNAMES,\'\\n\')\n+ cat(\'OUTPATH=\',OUTPATH,\'\\n\')\n+ x=ls()\n+ cat(\'all objects=\',x,\'\\n\')\n+ sink()\n+ }\n+ sessionInfo()\n+ print.noquote(date())\n+\n+\n+***bash/sh***::\n+\n+ # tool factory sets up these environmental variables\n+ # this example writes those to the output file\n+ # additional params appear on command line\n+ if [ ! -f "$OUTPATH" ] ; then\n+ touch "$OUTPATH"\n+ fi\n+ echo "INPATHS=$INPATHS" >> "$OUTPATH"\n+ echo "INNAMES=$INNAMES" >> "$OUTPATH"\n+ echo "OUTPATH=$OUTPATH" >> "$OUTPATH"\n+ echo "CL=$@" >> "$OUTPATH"\n+\n+***perl***::\n+\n+ (my $INPATHS,my $INNAMES,my $OUTPATH ) = @ARGV;\n+ open(my $fh, \'>\', $OUTPATH) or die "Could not open file \'$OUTPATH\' $!";\n+ print $fh "INPATHS=$INPATHS\\n INNAMES=$INNAMES\\n OUTPATH=$OUTPATH\\n";\n+ close $fh;\n+ \n+\n+]]>\n+\n+**Citation**\n+\n+\n+Paper_ :\n+\n+Creating re-usable tools from scripts: The Galaxy Tool Factory\n+Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team\n+Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573\n+\n+\n+**Licensing** \n+\n+Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012\n+All rights reserved.\n+Licensed under the LGPL_\n+\n+.. _LGPL: http://www.gnu.org/copyleft/lesser.html\n+.. _GTF: https://bitbucket.org/fubar/galaxytoolfactory\n+.. _GTFI: https://bitbucket.org/fubar/galaxytoolfactory/issues\n+.. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&keytype=ref\n+\n+\n+</help>\n+\n+</tool>\n+\n+\n' |
b |
diff -r 000000000000 -r c34063ab3735 test-data/tf2_test.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/tf2_test.html Thu Jan 01 21:58:00 2015 -0500 |
b |
@@ -0,0 +1,25 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <meta name="generator" content="Galaxy rgToolFactory2.py tool output - see http://g2.trac.bx.psu.edu/" /> + <title></title> + <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> + </head> + <body> + <div class="toolFormBody"> + +<div class="infomessage">Galaxy Tool "tf2_test" run at 02/01/2015 11:50:01</div><br/> +<div class="toolFormTitle">tf2 log output</div> +tf2_test_error.log is empty<br/> +<div class="toolFormTitle">Other log output</div> +/tmp/tmpsyPOyw/job_working_directory/000/2/dataset_3_files/tf2_test_runner.log is empty<br/> +<div class="toolFormTitle">All output files available for downloading</div> + +<div><table class="colored" cellpadding="3" cellspacing="3"><tr><th>Output File Name (click to view)</th><th>Size</th></tr> + +<tr><td><a href="tf2_test.python">tf2_test.python</a></td><td>0 B</td></tr> +<tr class="odd_row"><td><a href="tf2_test_error.log">tf2_test_error.log</a></td><td>0 B</td></tr> +<tr><td><a href="tf2_test_runner.log">tf2_test_runner.log</a></td><td>177 B</td></tr> +</table></div><br/> +</div></body></html> + |
b |
diff -r 000000000000 -r c34063ab3735 test-data/tf2_test.toolshed.gz |
b |
Binary file test-data/tf2_test.toolshed.gz has changed |
b |
diff -r 000000000000 -r c34063ab3735 test-data/tf2_test_in.xls --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/tf2_test_in.xls Thu Jan 01 21:58:00 2015 -0500 |
b |
@@ -0,0 +1,3 @@ +col1 col2 col3 +r11 r12 r13 +r21 r22 r23 |
b |
diff -r 000000000000 -r c34063ab3735 test-data/tf2_test_runme.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/tf2_test_runme.py Thu Jan 01 21:58:00 2015 -0500 |
[ |
@@ -0,0 +1,25 @@ +### bog standard argparse for 3 possible comma separated lists +## followed by some silly reverse each row code provided as an example +## you're supposed to replace it with your great code.. +import sys +import argparse +import copy +argp=argparse.ArgumentParser() +argp.add_argument('--INNAMES',default=None) +argp.add_argument('--INPATHS',default=None) +argp.add_argument('--OUTPATH',default=None) +argp.add_argument('--additional_parameters',default=[],action="append") +argp.add_argument('otherargs', nargs=argparse.REMAINDER) +args = argp.parse_args() +fout = open(args.OUTPATH,'w') +sins = open(args.INPATHS.split(',')[0]).readlines() +for i,sin in enumerate(sins): + row = sin.strip().split('\t') + rrow = copy.copy(row) + lrow = len(row) + if (lrow > 1): + for j in range(lrow): + rrow[j] = row[lrow-j-1] + fout.write('\t'.join(rrow)) + fout.write('\n') +fout.close() |
b |
diff -r 000000000000 -r c34063ab3735 tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_dependencies.xml Thu Jan 01 21:58:00 2015 -0500 |
b |
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="ghostscript" version="9.10"> + <repository changeset_revision="a285e78179bd" name="package_ghostscript_9_10" owner="devteam" toolshed="http://toolshed.g2.bx.psu.edu/" /> + </package> + <package name="graphicsmagick" version="1.3.20"> + <repository changeset_revision="d87c457bbbc2" name="package_graphicsmagick_1_3_20" owner="iuc" toolshed="http://toolshed.g2.bx.psu.edu/" /> + </package> + <readme> + Only Admins can use this tool generator but please do NOT install on a public facing Galaxy as it exposes unrestricted scripting as your Galaxy user + </readme> +</tool_dependency> |