Previous changeset 125:2dbb412af425 (2021-03-26) Next changeset 127:98c8a76b3638 (2021-03-30) |
Commit message:
Uploaded |
modified:
toolfactory/rgToolFactory2.py toolfactory/rgToolFactory2.xml |
b |
diff -r 2dbb412af425 -r def0f754ee1b toolfactory/rgToolFactory2.py --- a/toolfactory/rgToolFactory2.py Fri Mar 26 09:27:55 2021 +0000 +++ b/toolfactory/rgToolFactory2.py Fri Mar 26 09:29:58 2021 +0000 |
[ |
b'@@ -16,6 +16,7 @@\n \n import argparse\n import copy\n+import json\n import logging\n import os\n import re\n@@ -36,44 +37,11 @@\n \n import yaml\n \n-myversion = "V2.1 July 2020"\n+\n+myversion = "V2.2 February 2021"\n verbose = True\n debug = True\n toolFactoryURL = "https://github.com/fubar2/toolfactory"\n-ourdelim = "~~~"\n-\n-# --input_files="$intab.input_files~~~$intab.input_CL~~~\n-# $intab.input_formats# ~~~$intab.input_label\n-# ~~~$intab.input_help"\n-IPATHPOS = 0\n-ICLPOS = 1\n-IFMTPOS = 2\n-ILABPOS = 3\n-IHELPOS = 4\n-IOCLPOS = 5\n-\n-# --output_files "$otab.history_name~~~$otab.history_format~~~\n-# $otab.history_CL~~~$otab.history_test"\n-ONAMEPOS = 0\n-OFMTPOS = 1\n-OCLPOS = 2\n-OTESTPOS = 3\n-OOCLPOS = 4\n-\n-\n-# --additional_parameters="$i.param_name~~~$i.param_value~~~\n-# $i.param_label~~~$i.param_help~~~$i.param_type\n-# ~~~$i.CL~~~i$.param_CLoverride"\n-ANAMEPOS = 0\n-AVALPOS = 1\n-ALABPOS = 2\n-AHELPPOS = 3\n-ATYPEPOS = 4\n-ACLPOS = 5\n-AOVERPOS = 6\n-AOCLPOS = 7\n-\n-\n foo = len(lxml.__version__)\n # fug you, flake8. Say my name!\n FAKEEXE = "~~~REMOVE~~~ME~~~"\n@@ -86,32 +54,9 @@\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- "#": "#",\n- "$": "$",\n-}\n cheetah_escape_table = {"$": "\\\\$", "#": "\\\\#"}\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 cheetah_escape(text):\n """Produce entities within text."""\n return "".join([cheetah_escape_table.get(c, c) for c in text])\n@@ -141,10 +86,48 @@\n and prepare elements needed for galaxyxml tool generation\n """\n self.ourcwd = os.getcwd()\n- self.ourenv = copy.deepcopy(os.environ)\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.collections = []\n+ if len(args.collection) > 0:\n+ try:\n+ self.collections = [\n+ json.loads(x) for x in args.collection if len(x.strip()) > 1\n+ ]\n+ except Exception:\n+ print(\n+ f"--collections parameter {str(args.collection)} is malformed - should be a dictionary"\n+ )\n+ try:\n+ self.infiles = [\n+ json.loads(x) for x in args.input_files if len(x.strip()) > 1\n+ ]\n+ except Exception:\n+ print(\n+ f"--input_files parameter {str(args.input_files)} is malformed - should be a dictionary"\n+ )\n+ try:\n+ self.outfiles = [\n+ json.loads(x) for x in args.output_files if len(x.strip()) > 1\n+ ]\n+ except Exception:\n+ print(\n+ f"--output_files parameter {args.output_files} is malformed - should be a dictionary"\n+ )\n+ try:\n+ self.addpar = [\n+ json.loads(x) for x in args.additional_parameters if len(x.strip()) > 1\n+ ]\n+ except Exception:\n+ print(\n+ f"--additional_parameters {args.additional_parameters} is malformed - should be a dictionary"\n+ )\n+ try:\n+ self.selpar = [\n+ json.loads(x) for x in args.selecttext_parameters if len(x.strip()) > 1\n+ ]\n+ except Exception:\n+ print(\n+ f"--selecttext_parameters {args.selecttext_parameters} is malformed - should be a dictionary"\n+ )\n self.args = args\n self.cleanuppar()\n self.lastclredirect = None\n@@ -153,10'..b'emo",\n- "test",\n- "--test_data",\n- os.path.abspath(self.testdir),\n- "--test_output",\n- os.path.abspath(tool_test_path),\n- "--skip_venv",\n- "--galaxy_root",\n- self.args.galaxy_root,\n- "--update_test_data",\n- os.path.abspath(xreal),\n- ]\n- p = subprocess.run(\n- cll,\n- env=self.ourenv,\n- shell=False,\n- cwd=self.tooloutdir,\n- stderr=dummy,\n- stdout=dummy,\n- )\n-\n- else:\n- cll = [\n- "planemo",\n- "test",\n- "--test_data",\n- os.path.abspath(self.testdir),\n- "--test_output",\n- os.path.abspath(tool_test_path),\n- "--skip_venv",\n- "--galaxy_root",\n- self.args.galaxy_root,\n- os.path.abspath(xreal),\n- ]\n- p = subprocess.run(\n- cll,\n- shell=False,\n- env=self.ourenv,\n- cwd=self.tooloutdir,\n- stderr=tout,\n- stdout=tout,\n- )\n+ cll = [\n+ "planemo",\n+ "test",\n+ "--conda_auto_init",\n+ "--test_data",\n+ os.path.abspath(self.testdir),\n+ "--test_output",\n+ os.path.abspath(tool_test_path),\n+ "--galaxy_root",\n+ self.args.galaxy_root,\n+ "--update_test_data",\n+ os.path.abspath(xreal),\n+ ]\n+ p = subprocess.run(\n+ cll,\n+ shell=False,\n+ cwd=self.tooloutdir,\n+ stderr=tout,\n+ stdout=tout,\n+ )\n tout.close()\n return p.returncode\n \n@@ -986,6 +1056,7 @@\n a("--command_override", default=None)\n a("--test_override", default=None)\n a("--additional_parameters", action="append", default=[])\n+ a("--selecttext_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@@ -998,6 +1069,8 @@\n a("--galaxy_api_key", default="fakekey")\n a("--galaxy_root", default="/galaxy-central")\n a("--galaxy_venv", default="/galaxy_venv")\n+ a("--collection", action="append", default=[])\n+ a("--include_tests", default=False, action="store_true")\n args = parser.parse_args()\n assert not args.bad_user, (\n \'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy \\\n@@ -1009,25 +1082,20 @@\n args.sysexe or args.packages\n ), "## Tool Factory wrapper expects an interpreter \\\n or an executable package in --sysexe or --packages"\n- args.input_files = [x.replace(\'"\', "").replace("\'", "") 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 r = ScriptRunner(args)\n r.writeShedyml()\n r.makeTool()\n if args.make_Tool == "generate":\n- retcode = r.run()\n+ r.run()\n r.moveRunOutputs()\n r.makeToolTar()\n else:\n- retcode = r.planemo_test(genoutputs=True) # this fails :( - see PR\n+ # r.planemo_test(genoutputs=True) # this fails :( - see PR\n+ # r.moveRunOutputs()\n+ # r.makeToolTar(report_fail=False)\n+ r.planemo_test_once()\n r.moveRunOutputs()\n- r.makeToolTar()\n- retcode = r.planemo_test(genoutputs=False)\n- r.moveRunOutputs()\n- r.makeToolTar()\n- print(f"second planemo_test returned {retcode}")\n+ r.makeToolTar(report_fail=True)\n if args.make_Tool == "gentestinstall":\n r.shedLoad()\n r.eph_galaxy_load()\n' |
b |
diff -r 2dbb412af425 -r def0f754ee1b toolfactory/rgToolFactory2.xml --- a/toolfactory/rgToolFactory2.xml Fri Mar 26 09:27:55 2021 +0000 +++ b/toolfactory/rgToolFactory2.xml Fri Mar 26 09:29:58 2021 +0000 |
[ |
b'@@ -1,6 +1,32 @@\n <tool id="rgtf2" name="toolfactory" version="2.00" profile="16.04" >\n <description>Scripts into tools v2.0</description>\n <macros>\n+ <xml name="singleText">\n+ <param name="param_value" type="text" value="" label="Enter this parameter\'s default text value">\n+ </param>\n+ </xml>\n+ <xml name="singleInt">\n+ <param name="param_value" type="integer" value="" label="Enter this parameter\'s default integer value" >\n+ </param>\n+ </xml>\n+ <xml name="singleFloat">\n+ <param name="param_value" type="float" value="" label="Enter this parameter\'s default value">\n+ </param>\n+ </xml>\n+ <xml name="singleBoolean">\n+ <param name="param_value" type="boolean" value="" label="Enter this parameter\'s default value" />\n+ <param name="truevalue" type="text" value="True" label="Command line value to emit when True" />\n+ <param name="falsevalue" type="boolean" value="True" label="Command line value to emit when False" />\n+ </xml>\n+ <xml name="selectText">\n+ <repeat name="selectTexts" title="Add each option to be presented in a text select box" min="2" default="2"\n+ help="Each text added here will also have a value to be emitted on the command line when the text is chosen">\n+ <param name="select_text" type="text" value="" label="Enter the explanatory text the user will see for this choice" >\n+ </param>\n+ <param name="select_value" type="text" value="" label="Enter the value for the command line when the user selects this option">\n+ </param>\n+ </repeat>\n+ </xml>\n <xml name="tool_metadata">\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@@ -10,8 +36,7 @@\n value="**What it Does**"\n help="Supply user documentation to appear on the new tool form as reStructured text - http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html" >\n <sanitizer>\n- <valid initial="string.printable">\n- </valid>\n+ <valid initial="string.printable" />\n <mapping initial="none"/>\n </sanitizer>\n </param>\n@@ -29,8 +54,7 @@\n <param name="bibtex" label="BibTex" type="text" area="true"\n help="Supply a BibTex entry that should be cited when this tool is used in published research." value="" >\n <sanitizer>\n- <valid initial="string.printable">\n- </valid>\n+ <valid initial="string.printable" />\n <mapping initial="none"/>\n </sanitizer>\n </param>\n@@ -40,9 +64,9 @@\n </xml>\n <xml name="io">\n <section name="io" title="Input and output files" expanded="true">\n- <repeat name="history_inputs" title="zero or more input data files to pass as parameters to the executable."\n+ <repeat name="history_inputs" title="zero or more input data files to pass on the command line to the executable."\n help="USE SMALL SAMPLES for the new tool\'s test. Prompts will form a history item selector as input for users of this new tool">\n- <param name="input_files" type="data" format="data" label="Select an input file from your history" optional="true" multiple="false"\n+ <param name="input_files" type="data" format="data" label="Select an input file from your history" multiple="false"\n help=""/>\n <param name="input_formats" type="select" multiple="true" l'..b'this step! </option>\n+ <option value="gentestinstall">Install in this Galaxy after generation and testing. Must have local ToolShed as in the TF Docker container</option>\n </param>\n <when value="generate">\n <param name="galaxy_apikey" value="" type="hidden" ></param>\n@@ -359,32 +413,28 @@\n <param name="galaxy_url" type="text" value="http://localhost:8080" label="URL for the Galaxy server where the new tool should be installed"\n help="Default is localhost">\n <sanitizer>\n- <valid initial="string.printable">\n- </valid>\n+ <valid initial="string.printable" />\n <mapping initial="none"/>\n </sanitizer>\n </param>\n <param name="galaxy_apikey" type="text" value="fakekey" label="API key for the Galaxy to install the new tool"\n help="Cut and paste from the admin user properties screen">\n <sanitizer>\n- <valid initial="string.ascii_letters,string.digits">\n- </valid>\n+ <valid initial="string.ascii_letters,string.digits" />\n <mapping initial="none"/>\n </sanitizer>\n </param>\n <param name="toolshed_url" type="text" value="http://localhost:9009" label="URL for the Toolshed where the new tool should be installed"\n help="Default value is localhost:9009">\n <sanitizer>\n- <valid initial="string.printable">\n- </valid>\n+ <valid initial="string.printable" />\n <mapping initial="none"/>\n </sanitizer>\n </param>\n <param name="toolshed_apikey" type="text" value="fakekey" label="API key for the local toolshed to use when installing the tool"\n help="Cut and paste from the admin user properties screen">\n <sanitizer>\n- <valid initial="string.ascii_letters,string.digits">\n- </valid>\n+ <valid initial="string.ascii_letters,string.digits" />\n <mapping initial="none"/>\n </sanitizer>\n </param>\n@@ -395,7 +445,7 @@\n </inputs>\n <outputs>\n \n- <data format="tgz" name="new_tool" label="${tool_name}_toolshed.tgz" >\n+ <data format="toolshed.gz" name="new_tool" label="${tool_name}_toolshed.gz" >\n <filter>makeMode[\'make_Tool\'] != "runonly"</filter>\n </data>\n \n@@ -413,7 +463,7 @@\n <param name="input_help" value="help" />\n <param name="tool_name" value="pyrevpos" />\n <param name="parampass" value="positional" />\n- <param name="make_Tool" value="generate" />\n+ <param name="make_Tool" value="gentest" />\n <param name="tool_version" value="0.01" />\n <param name="tool_desc" value="positional reverse" />\n <param name="help_text" value="help text goes here" />\n@@ -512,6 +562,27 @@\n o.write(\'\\n\')\n o.close()\n \n+R script to draw some plots - use a collection.\n+\n+::\n+\n+\n+ \\# note this script takes NO input because it generates random data\n+ dir.create(\'plots\')\n+ for (i in 1:10) {\n+ foo = runif(100)\n+ bar = rnorm(100)\n+ bar = foo + 0.05*bar\n+ pdf(paste(\'plots/yet\',i,"anotherplot.pdf",sep=\'_\'))\n+ plot(foo,bar,main=paste("Foo by Bar plot \\#",i),col="maroon", pch=3,cex=0.6)\n+ dev.off()\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(paste(\'plots/yet\',i,"anotherheatmap.pdf",sep=\'_\'))\n+ heatmap(bar,main=\'Random Heatmap\')\n+ dev.off()\n+ }\n+\n \n \n Paper_\n@@ -524,7 +595,7 @@\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+.. _Paper: https://academic.oup.com/bioinformatics/article/28/23/3139/192853\n \n \n </help>\n' |