Previous changeset 29:6db39cbc3242 (2020-08-07) Next changeset 31:69eed330c91f (2020-08-07) |
Commit message:
Uploaded |
added:
toolfactory/LICENSE toolfactory/README.md toolfactory/images/dynamicScriptTool.png toolfactory/rgToolFactory2.py toolfactory/rgToolFactory2.xml toolfactory/test-data/infile.tabular toolfactory/test-data/reverseargp2.toolshed.gz toolfactory/test-data/reverseargp2_test1_output.xls toolfactory/test-data/runme.py toolfactory/test-data/test1_out.log toolfactory/test-data/toolfactory.log toolfactory/tool_dependencies.xml |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/LICENSE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/LICENSE Fri Aug 07 07:54:23 2020 -0400 |
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 6db39cbc3242 -r 6f48315c32c1 toolfactory/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/README.md Fri Aug 07 07:54:23 2020 -0400 |
[ |
b'@@ -0,0 +1,418 @@\n+toolfactory_2\n+=============\n+\n+This is an upgrade to the tool factory but with added parameters \n+(optionally editable in the generated tool form - otherwise fixed) and \n+multiple input files.\n+\n+Specify any number of parameters - well at \n+least up to the limit of your patience with repeat groups.\n+\n+Parameter values supplied at tool generation time are defaults and \n+can be optionally editable by the user - names cannot be changed once\n+a tool has been generated.\n+\n+If not editable, they act as hidden parameters passed to the script \n+and are not editable on the tool form.\n+\n+Note! There will be Galaxy default sanitization for all \n+user input parameters which your script may need to dance around.\n+\n+Any number of input files can be passed to your script, but of course it\n+has to deal with them. Both path and metadata name are supplied either in the environment \n+(bash/sh) or as command line parameters (python,perl,rscript) that need to be parsed and\n+dealt with in the script. This is complicated by the common use case of needing file names\n+for (eg) column headers, as well as paths. Try the examples are show on the tool factory \n+form to see how Galaxy file and user supplied parameter values can be recovered in each \n+of the 4 scripting environments supported.\n+\n+Best way to deal with multiple outputs is to let the tool factory generate an HTML\n+page for your users. It automagically lays out pdf images as thumbnail galleries\n+and can have separate results sections gathering all similarly prefixed files, such as\n+a Foo section taking text and results from text (foo_whatever.log) and \n+artifacts (eg foo_MDS_plot.pdf) file names. All artifacts are linked for download.\n+A copy of the actual script is provided for provenance - be warned, it exposes\n+real file paths.\n+\n+**WARNING before you start**\n+\n+Install this tool on a private Galaxy ONLY\n+Please NEVER on a public or production instance\n+Please cite the resource at\n+http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573?ijkey=lczQh1sWrMwdYWJ&keytype=ref\n+if you use this tool in your published work.\n+\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 scripting\n+to all designated administrators of the host Galaxy server, allowing them to\n+run scripts in R, python, sh and perl over multiple selected input data sets,\n+writing a single new data set as output.\n+\n+*Differences between TF2 and the original Tool Factory*\n+\n+1. TF2 (this one) allows any number of either fixed or user-editable parameters to be defined\n+for the new tool. If these are editable, the user can change them but otherwise, they are passed\n+as fixed and invisible parameters for each execution. Obviously, there are substantial security\n+implications with editable parameters, but these are always sanitized by Galaxy\'s inbuilt \n+parameter sanitization so you may need to "unsanitize" characters - eg translate all "__lt__" \n+into "<" for certain parameters where that is needed. Please practise safe toolshed.\n+\n+2. Any number of (the same datatype) of input files may be defined.\n+\n+These changes substantially complicate the way your supplied script is supplied with\n+all the new and variable parameters. Examples in each scripting language are shown\n+in the tool help\n+\n+*Automated outputs in named sections*\n+\n+If your script writes to the current directory path, arbitrary mix of (eg)\n+pdfs, tabular analysis results and run logs,the tool factory can optionally\n+auto-generate a linked Html page with separate sections showing a thumbnail\n+grid for all pdfs and the log text, grouping all artifacts sharing a file\n+name and log name prefix.if "foo.log" is emitted then *all* other outputs matching foo_* will\n+all be grouped together - eg\n+- foo_baz.pdf\n+- foo_bar.pdf and\n+- foo_zot.xls\n+ \n+would all be displayed and linked in the same section with foo.log\'s contents to form the "Foo" sectio'..b'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+Galaxy as an IDE for developing API scripts\n+If you need to develop Galaxy API scripts and you like to live dangerously,\n+please read on.\n+\n+Galaxy as an IDE?\n+Amazingly enough, blend-lib API scripts run perfectly well *inside*\n+Galaxy when pasted into a Tool Factory form. No need to generate a new\n+tool. Galaxy+Tool_Factory = IDE I think we need a new t-shirt. Seriously,\n+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\n+Galaxy, you get persistence and other framework benefits plus at absolutely\n+no extra charge, a ginormous security problem if you share the history or\n+any outputs because they contain the api script with key so development\n+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\n+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\n+almost nothing about the API. I started with very simple code from one of the\n+samples and after each run, the (edited..) api script is conveniently recreated\n+using the redo button on the history output item. So each successive version\n+of the developing api script you run is persisted - ready to be edited and\n+rerun easily. It is \'\'very\'\' handy to be able to add a line of code to the\n+script and run it, then view the output to (eg) inspect dicts returned by\n+API calls to help move progressively deeper iteratively.\n+\n+Give the below a whirl on a private clone (install the tool factory from\n+the main toolshed) and try adding complexity with few rerun/edit/rerun cycles.\n+\n+Eg tool factory api script\n+```\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\':\n+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+\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+**screenshot**\n+\n+![example run](/images/dynamicScriptTool.png)\n+\n+\n+```\n+\n' |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/images/dynamicScriptTool.png |
b |
Binary file toolfactory/images/dynamicScriptTool.png has changed |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/rgToolFactory2.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/rgToolFactory2.py Fri Aug 07 07:54:23 2020 -0400 |
[ |
b'@@ -0,0 +1,610 @@\n+# rgToolFactory.py\n+# see https://github.com/fubar2/toolfactory\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://github.com/fubar2/toolfactory\n+#\n+# July 2020: BCC was fun and I feel like rip van winkle after 5 years.\n+# Decided to\n+# 1. Fix the toolfactory so it works - done for simplest case\n+# 2. Fix planemo so the toolfactory function works\n+# 3. Rewrite bits using galaxyxml functions where that makes sense - done\n+#\n+# removed all the old complications including making the new tool use this same script\n+# galaxyxml now generates the tool xml https://github.com/hexylena/galaxyxml\n+# No support for automatic HTML file creation from arbitrary outputs\n+# TODO: add option to run that code as a post execution hook\n+# TODO: add additional history input parameters - currently only one\n+\n+import sys\n+import subprocess\n+import shutil\n+import os\n+import time\n+import tempfile\n+import argparse\n+import tarfile\n+import re\n+import galaxyxml.tool as gxt\n+import galaxyxml.tool.parameters as gxtp\n+import logging\n+\n+\n+progname = os.path.split(sys.argv[0])[1]\n+myversion = \'V2.1 July 2020\'\n+verbose = True\n+debug = True\n+toolFactoryURL = \'https://github.com/fubar2/toolfactory\'\n+ourdelim = \'~~~\'\n+\n+# --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label~~~$input_help"\n+IPATHPOS = 0\n+ICLPOS = 1\n+IFMTPOS = 2\n+ILABPOS = 3\n+IHELPOS = 4\n+IOCLPOS = 5\n+# --output_files "$otab.history_name~~~$otab.history_format~~~$otab.CL\n+ONAMEPOS = 0\n+OFMTPOS = 1\n+OCLPOS = 2\n+OOCLPOS = 3\n+\n+#--additional_parameters="$i.param_name~~~$i.param_value~~~$i.param_label~~~$i.param_help~~~$i.param_type~~~$i.CL"\n+ANAMEPOS = 0\n+AVALPOS = 1\n+ALABPOS = 2\n+AHELPPOS = 3\n+ATYPEPOS = 4\n+ACLPOS = 5\n+AOCLPOS = 6\n+\n+def timenow():\n+ """return current time as a string\n+ """\n+ return time.strftime(\'%d/%m/%Y %H:%M:%S\', time.localtime(time.time()))\n+\n+\n+def quote_non_numeric(s):\n+ """return a prequoted string for non-numerics\n+ useful for perl and Rscript parameter passing?\n+ """\n+ try:\n+ _ = float(s)\n+ return s\n+ except ValueError:\n+ return \'"%s"\' % s\n+\n+\n+html_escape_table = {\n+ "&": "&",\n+ ">": ">",\n+ "<": "<",\n+ "$": r"\\$"\n+}\n+\n+\n+def html_escape(text):\n+ """Produce entities within text."""\n+ return "".join(html_escape_table.get(c, c) for c in text)\n+\n+\n+def html_unescape(text):\n+ """Revert entities within text. Multiple character targets so use replace"""\n+ t = text.replace(\'&\', \'&\')\n+ t = t.replace(\'>\', \'>\')\n+ t = t.replace(\'<\', \'<\')\n+ t = t.replace(\'\\\\$\', \'$\')\n+ return t\n+\n+\n+def parse_citations(citations_text):\n+ """\n+ """\n+ citations = [c for c in citations_text.split("**ENTRY**") if c.strip()]\n+ citation_tuples = []\n+ for citation in citations:\n+ if citation.startswith("doi"):\n+ citation_tuples.append(("doi", citation[len("doi"):].strip()))\n+ else:\n+ citation_tuples.append(\n+ ("bibtex", citation[len("bibtex"):].strip()))\n+ return citation_tuples\n+\n+\n+class ScriptRunner:\n+ """Wrapper for an arbitrary script\n+ uses galaxyxml\n+\n+ """\n+ \n+ \n+ def __init__(self, args=None):\n+ """\n+ prepare command line cl for running the tool here\n+ and prepare elements needed for galaxyxml tool generation\n+ """\n+\n+ self.infiles = [x.split(ourdelim) for x in args.input_files]\n+ self.outfiles = [x.split(ourdelim) for x in args.output_files]\n+ self.addpar = [x.split(ourdelim) for x in args.additional_parameters]\n+ self.args = args\n+ self.cleanuppar()\n+ self.lastclredirect = None\n+ self.lastxclredirect = None\n+ self.cl = []\n+ self.xmlcl = []\n+ aCL = self.cl.append\n+ assert args.parampass in [\'0\',\'argparse\',\'positional\'],\'Parameter passing in ar'..b'Toolfactory generated command line = %s\\n\' % scl, "utf8"))\n+ sto.flush()\n+ p = subprocess.run(self.cl, shell=False, stdout=sto,\n+ stderr=ste)\n+ sto.close()\n+ ste.close()\n+ tmp_stderr = open(self.elog, \'rb\')\n+ err = \'\'\n+ buffsize = 1048576\n+ try:\n+ while True:\n+ err += str(tmp_stderr.read(buffsize))\n+ if not err or len(err) % buffsize != 0:\n+ break\n+ except OverflowError:\n+ pass\n+ tmp_stderr.close()\n+ retval = p.returncode\n+ else: # work around special case of simple scripts that take stdin and write to stdout\n+ sti = open(self.infiles[0][IPATHPOS], \'rb\')\n+ sto = open(self.outfiles[0][ONAMEPOS], \'wb\')\n+ # must use shell to redirect\n+ p = subprocess.run(self.cl, shell=False, stdout=sto, stdin=sti)\n+ retval = p.returncode\n+ sto.close()\n+ sti.close()\n+ if os.path.isfile(self.tlog) and os.stat(self.tlog).st_size == 0:\n+ os.unlink(self.tlog)\n+ if os.path.isfile(self.elog) and os.stat(self.elog).st_size == 0:\n+ os.unlink(self.elog)\n+ if p.returncode != 0 and err: # problem\n+ sys.stderr.write(err)\n+ logging.debug(\'run done\')\n+ return retval\n+\n+\n+def main():\n+ """\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+ parser = argparse.ArgumentParser()\n+ a = parser.add_argument\n+ a(\'--script_path\', default=\'\')\n+ a(\'--tool_name\', default=None)\n+ a(\'--interpreter_name\', default=None)\n+ a(\'--interpreter_version\', default=None)\n+ a(\'--exe_package\', default=None)\n+ a(\'--exe_package_version\', default=None)\n+ a(\'--input_files\', default=[], action="append")\n+ a(\'--output_files\', default=[], action="append")\n+ a(\'--user_email\', default=\'Unknown\')\n+ a(\'--bad_user\', default=None)\n+ a(\'--make_Tool\', default=None)\n+ a(\'--help_text\', default=None)\n+ a(\'--tool_desc\', default=None)\n+ a(\'--tool_version\', default=None)\n+ a(\'--citations\', default=None)\n+ a(\'--additional_parameters\', action=\'append\', default=[])\n+ a(\'--edit_additional_parameters\', action="store_true", default=False)\n+ a(\'--parampass\', default="positional")\n+ a(\'--tfout\', default="./tfout")\n+ a(\'--new_tool\',default="new_tool")\n+ a(\'--runmode\',default=None)\n+ args = parser.parse_args()\n+ assert not args.bad_user, \'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file\' % (\n+ args.bad_user, args.bad_user)\n+ assert args.tool_name, \'## Tool Factory expects a tool name - eg --tool_name=DESeq\'\n+ assert (args.interpreter_name or args.exe_package), \'## Tool Factory wrapper expects an interpreter - eg --interpreter_name=Rscript or an executable package findable by the dependency management package\'\n+ assert args.exe_package or (len(args.script_path) > 0 and os.path.isfile(\n+ args.script_path)), \'## Tool Factory wrapper expects a script path - eg --script_path=foo.R if no executable\'\n+ args.input_files = [x.replace(\'"\', \'\').replace("\'", \'\')\n+ for x in args.input_files]\n+ # remove quotes we need to deal with spaces in CL params\n+ for i, x in enumerate(args.additional_parameters):\n+ args.additional_parameters[i] = args.additional_parameters[i].replace(\n+ \'"\', \'\')\n+ r = ScriptRunner(args)\n+ if args.make_Tool:\n+ retcode = r.makeTooltar()\n+ else:\n+ retcode = r.run()\n+ if retcode:\n+ sys.exit(retcode) # indicate failure to job runner\n+\n+\n+if __name__ == "__main__":\n+ main()\n' |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/rgToolFactory2.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/rgToolFactory2.xml Fri Aug 07 07:54:23 2020 -0400 |
[ |
b'@@ -0,0 +1,460 @@\n+<tool id="rgTF2" name="toolfactory" version="2.00">\n+ <description>Scripts into tools</description>\n+ <macros>\n+ <xml name="io">\n+ <repeat name="history_inputs" title="Add a data file from your history to pass in to the script. Use the \'+\' button as needed"\n+ help="USE SMALL SAMPLES because these will be used for the new tool\'s test. The names will become a history item selector as input for users of the new tool you are making">\n+ <param name="input_files" type="data" format="data" label="Select an input file from your history" optional="true" size="120" multiple="false"\n+ help=""/>\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" value="tabular">\n+ <options from_parameter="tool.app.datatypes_registry.upload_file_formats">\n+ <column name="value" index="0"/>\n+ </options>\n+ </param>\n+ <param name="input_label" type="text" value="" label="This will become the user prompt for the form so please make it informative" size="60" \n+ help="Note that \'~~~\' is an internal delimiter so must not appear in this text field - please work around this technical limitation" >\n+ <sanitizer invalid_char="">\n+ <valid initial="string.printable"> <remove value=\'~~~\'/> </valid>\n+ <mapping initial="none"/>\n+ </sanitizer>\n+ </param>\n+ <param name="input_help" type="text" value="parameter_help" label="This will become help text on the form."\n+ help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation" size="60">\n+ <sanitizer invalid_char="">\n+ <valid initial="string.printable"> <remove value=\'~~~\'/> </valid>\n+ <mapping initial="none"/>\n+ </sanitizer>\n+ </param>\n+ <param name="input_CL" type="text" size="60" label="Positional: ordinal integer. Argparse: argument name."\n+ 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=""> \n+ </param>\n+ </repeat>\n+ <repeat name="history_outputs" title="Add a tool run output file to the user\'s history from your tool - Use the \'+\' button to add as many as needed"\n+ help="The name will become a history item for users of the new tool you are making containing one of it\'s outputs">\n+ <param name="history_name" type="text" label="Name for this output to appear in new history" optional="false" size="120" \n+ help=""/>\n+ <param name="history_format" type="select" multiple="false" label="Select the datatype for this output"\n+ help="If your datatype is not listed here, it has to be added in galaxy\'s datatypes_conf.xml" value="tabular">\n+ <options from_parameter="tool.app.datatypes_registry.upload_file_formats">\n+ <column name="value" index="0"/>\n+ </options>\n+ </param>\n+ <param name="history_CL" type="text" size="60" label="Positional: ordinal integer. Argparse: argument name expected for this output parameter"\n+ help="If positional parameters, enter the integer ordinal expected for this parameter. If Argparse style, \'--\' will be prepended or \'-\' if single character" value=""> \n+ </param>\n+ </repeat>\n+ </xml>\n+ <xml name="additparam">\n+ <param name="edit_params" type="select" display="radio" label="Add any additional parameters to the generated tool form so they are user editable?" \n+ help="If no (default), users will NOT be able to'..b'le_sample" file="output2_sample" ftype="txt" compare="diff" lines_diff = "10" />\n+ </output_collection>\n+ <output name="new_tool" file="toolfactory_pyrevpos_tgz_sample" compare="sim_size" delta="6000" />\n+</test>\n+</tests>\n+<help>\n+\n+.. class:: warningmark\n+\n+**Details and attribution** \n+(see GTF_)\n+\n+**Local Admins ONLY** \n+Only users whose IDs found in the local admin_user configuration setting in universe_wsgi.ini can run this tool.\n+\n+**If you find a bug** \n+Please raise an issue, or even better, submit a pull request fixing it, on the github repository GTF_\n+\n+**What it does** \n+This tool optionally generates normal workflow compatible first class Galaxy tools\n+\n+Generated tools can run existing binary packages that become requirements, existing scripts, or new scripts pasted into this tool form.\n+Pasted scripts are written so they are part of the new tool and cannot be adjusted by the downstream user.\n+Binary packages are managed by the dependency subsystem - conda usually, so anything in bioconda or conda_forge is available for example.\n+\n+Any number of parameters can be built into the new tool form for passing in to the script or executable at runtime.\n+These can be editable by the downstream user or baked in.\n+\n+When you run this tool, your executable or script and supplied parameter values will be run to produce a canonical\n+set of outputs - these are used to construct a test for the new tool.\n+\n+If tool generation is required, a new tarball compatible with any Galaxy toolshed is created.\n+It can be unpacked in your galaxy/tools directory and manually added to tool_conf.xml, or\n+installed into any toolshed from where it can be installed into your Galaxy.\n+\n+\n+.. class:: warningmark\n+\n+**Note to system administrators** \n+This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances.\n+Admin_users will have the power to do anything they want as the Galaxy user if you install this tool.\n+\n+.. class:: warningmark\n+\n+**Use on public servers** is STRONGLY discouraged for obvious reasons\n+\n+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.\n+We recommend that you follow the good code hygiene practices associated with safe toolshed practices.\n+\n+Here\'s a sample python script that can be cut and pasted into the tool form, suitable for positional parameter passing:\n+\n+::\n+\n+ # reverse order of text by row\n+ import sys\n+ inp = sys.argv[1]\n+ outp = sys.argv[2]\n+ i = open(inp,\'r\').readlines()\n+ o = open(outp,\'w\')\n+ for row in i:\n+ rs = row.rstrip()\n+ rs = list(rs)\n+ rs.reverse()\n+ o.write(\'\'.join(rs))\n+ o.write(\'\\n\')\n+ o.close()\n+\n+With argparse style parameters:\n+ \n+::\n+\n+ # reverse order of text by row\n+ import argparse\n+ parser = argparse.ArgumentParser()\n+ a = parser.add_argument\n+ a(\'--infile\',default=\'\')\n+ a(\'--outfile\',default=None)\n+ args = parser.parse_args()\n+ inp = args.infile\n+ outp = args.outfile\n+ i = open(inp,\'r\').readlines()\n+ o = open(outp,\'w\')\n+ for row in i:\n+ rs = row.rstrip()\n+ rs = list(rs)\n+ rs.reverse()\n+ o.write(\'\'.join(rs))\n+ o.write(\'\\n\')\n+ o.close()\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+**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://github.com/fubar2/toolfactory\n+.. _Paper: http://bioinformatics.oxfordjournals.org/cgi/reprint/bts573\n+\n+\n+</help>\n+<citations>\n+ <citation type="doi">10.1093/bioinformatics/bts573</citation>\n+</citations>\n+</tool>\n+\n+\n' |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/test-data/infile.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/test-data/infile.tabular Fri Aug 07 07:54:23 2020 -0400 |
b |
@@ -0,0 +1,7 @@ +0.1 +0.00001 +0.2 +0.3 +0.004 +0.5 +0.000000002 |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/test-data/reverseargp2.toolshed.gz |
b |
Binary file toolfactory/test-data/reverseargp2.toolshed.gz has changed |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/test-data/runme.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/test-data/runme.py Fri Aug 07 07:54:23 2020 -0400 |
b |
@@ -0,0 +1,19 @@ +# reverse order of columns in a tabular file +import argparse +parser = argparse.ArgumentParser() +a = parser.add_argument +a('--infile',default='') +a('--outfile',default=None) +a('--prefix',default=None) +args = parser.parse_args() +inp = args.infile +outp = args.outfile +i = open(inp,'r').readlines() +o = open(outp,'w') +for row in i: + rs = row.rstrip() + rs = list(rs) + rs.reverse() + o.write('%s:%s' % (args.prefix,''.join(rs))) + o.write('\n') +o.close() |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/test-data/test1_out.log --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/test-data/test1_out.log Fri Aug 07 07:54:23 2020 -0400 |
b |
@@ -0,0 +1,1 @@ +## Executing Toolfactory generated command line = python3 /home/ross/galaxy/database/tmp/reverseargp2tzq9wpni.python --infile /home/ross/galaxy/database/objects/3/5/2/dataset_352183fc-9148-44e6-a703-0c1b06d0a365.dat --outfile /home/ross/galaxy/database/objects/6/1/3/dataset_613ab089-f4d1-493c-baf5-0a0bbaebaff8.dat --prefix "hello world" |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/test-data/toolfactory.log --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/test-data/toolfactory.log Fri Aug 07 07:54:23 2020 -0400 |
[ |
@@ -0,0 +1,39 @@ +### cl=python3 /tmp/reverseargp2_test1veulkauo.python -- /tmp/tmpzal0_664/files/c/8/4/dataset_c84573ea-e358-4a99-bac6-3dfe1b030c65.dat -- /tmp/tmpzal0_664/files/e/b/2/dataset_eb270919-0c8c-4b52-9e58-d351de848508.dat +xml=<tool name="reverseargp2_test1" id="reverseargp2_test1" version="0.01"> + <!--Cite: Creating re-usable tools from scripts doi: 10.1093/bioinformatics/bts573--> + <!--Source in git at: https://github.com/fubar2/toolfactory--> + <!--Created by test@bx.psu.edu at 30/07/2020 19:44:43 using the Galaxy Tool Factory.--> + <description>testing_tf2</description> + <requirements> + <requirement version="" type="package">python</requirement> + </requirements> + <configfiles> + <configfile name="runMe"><![CDATA[ + +]]></configfile> + </configfiles> + <stdio> + <exit_code range="1:" level="fatal"/> + </stdio> + <version_command/> + <command interpreter="python"><![CDATA[$runMe - $ +- $]]></command> + <inputs> + <param optional="false" label="parameter_label" help="parameter_help" format="tabular" multiple="false" type="data" name="" argument="-"/> + </inputs> + <outputs> + <data name="" format="tabular" hidden="false"/> + </outputs> + <tests> + <test> + <param name="" value=".tabular" ftype="tabular"/> + <param name="job_name" value="test_a"/> + <param name="runMe" value="$runMe"/> + <output name="" value="reverseargp2_test1_test1_output.xls"/> + </test> + </tests> + <help><![CDATA[ + help text goes here + ]]></help> +</tool> + |
b |
diff -r 6db39cbc3242 -r 6f48315c32c1 toolfactory/tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/tool_dependencies.xml Fri Aug 07 07:54:23 2020 -0400 |
b |
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="ghostscript" version="9.10"> + <repository changeset_revision="9345d2740f0c" name="package_ghostscript_9_10" owner="devteam" toolshed="https://testtoolshed.g2.bx.psu.edu" /> + </package> + <package name="graphicsmagick" version="1.3.20"> + <repository changeset_revision="25002de17a97" name="package_graphicsmagick_1_3_20" owner="iuc" toolshed="https://testtoolshed.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> |