Previous changeset 74:3d4324df911b (2020-11-14) Next changeset 76:46db8143adb7 (2020-11-16) |
Commit message:
Uploaded |
modified:
toolfactory/rgToolFactory2.py |
b |
diff -r 3d4324df911b -r 25dd9364a32a toolfactory/rgToolFactory2.py --- a/toolfactory/rgToolFactory2.py Sat Nov 14 21:52:39 2020 +0000 +++ b/toolfactory/rgToolFactory2.py Sat Nov 14 23:35:27 2020 +0000 |
[ |
b'@@ -24,7 +24,6 @@\n \n \n import argparse\n-import copy\n import logging\n import os\n import re\n@@ -35,7 +34,7 @@\n import tempfile\n import time\n \n-from bioblend import galaxy\n+\n from bioblend import toolshed\n \n import galaxyxml.tool as gxt\n@@ -92,8 +91,7 @@\n \n \n def timenow():\n- """return current time as a string\n- """\n+ """return current time as a string"""\n return time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(time.time()))\n \n \n@@ -126,8 +124,7 @@\n \n \n def parse_citations(citations_text):\n- """\n- """\n+ """"""\n citations = [c for c in citations_text.split("**ENTRY**") if c.strip()]\n citation_tuples = []\n for citation in citations:\n@@ -291,9 +288,11 @@\n """ positional parameters are complicated by their numeric ordinal"""\n for i, p in enumerate(self.infiles):\n if self.args.parampass == "positional":\n- assert p[ICLPOS].isdigit(), (\n- "Positional parameters must be ordinal integers - got %s for %s"\n- % (p[ICLPOS], p[ILABPOS])\n+ assert p[\n+ ICLPOS\n+ ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % (\n+ p[ICLPOS],\n+ p[ILABPOS],\n )\n p.append(p[ICLPOS])\n if p[ICLPOS].isdigit() or self.args.parampass == "0":\n@@ -304,9 +303,11 @@\n self.outfiles\n ): # trying to automagically gather using extensions\n if self.args.parampass == "positional" and p[OCLPOS] != "STDOUT":\n- assert p[OCLPOS].isdigit(), (\n- "Positional parameters must be ordinal integers - got %s for %s"\n- % (p[OCLPOS], p[ONAMEPOS])\n+ assert p[\n+ OCLPOS\n+ ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % (\n+ p[OCLPOS],\n+ p[ONAMEPOS],\n )\n p.append(p[OCLPOS])\n if p[OCLPOS].isdigit() or p[OCLPOS] == "STDOUT":\n@@ -315,9 +316,11 @@\n self.outfiles[i] = p\n for i, p in enumerate(self.addpar):\n if self.args.parampass == "positional":\n- assert p[ACLPOS].isdigit(), (\n- "Positional parameters must be ordinal integers - got %s for %s"\n- % (p[ACLPOS], p[ANAMEPOS])\n+ assert p[\n+ ACLPOS\n+ ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % (\n+ p[ACLPOS],\n+ p[ANAMEPOS],\n )\n p.append(p[ACLPOS])\n if p[ACLPOS].isdigit():\n@@ -326,8 +329,7 @@\n self.addpar[i] = p\n \n def clsimple(self):\n- """ no parameters - uses < and > for i/o\n- """\n+ """no parameters - uses < and > for i/o"""\n aCL = self.cl.append\n aXCL = self.xmlcl.append\n \n@@ -358,8 +360,7 @@\n aXCL(self.lastxclredirect[1])\n \n def clargparse(self):\n- """ argparse style\n- """\n+ """argparse style"""\n aCL = self.cl.append\n aXCL = self.xmlcl.append\n # inputs then params in argparse named form\n@@ -520,7 +521,9 @@\n anout.command_line_override = "> $%s" % newname\n anout.positional = self.is_positional\n self.toutputs.append(anout)\n- tp = gxtp.TestOutput(name=newname, value="%s_sample" % newname, format=newfmt)\n+ tp = gxtp.TestOutput(\n+ name=newname, value="%s_sample" % newname, format=newfmt\n+ )\n self.testparam.append(tp)\n \n def makeXML(self):\n@@ -537,11 +540,14 @@\n helptext = open(self.args.help_text, "r").readlines()\n safertext = [html_escape(x) for x in helptext]\n if False and self.args.script_path:\n- scrp = self.script.split(\'\\n\')\n- scrpt '..b'\n+ stdout=dummy,\n+ )\n else:\n- cll = ["planemo", "test", "--galaxy_root",\n+ cll = [\n+ "planemo",\n+ "test",\n+ "--galaxy_root",\n self.args.galaxy_root,\n- xreal,]\n+ xreal,\n+ ]\n p = subprocess.run(\n- cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout\n- )\n+ cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout\n+ )\n tout.close()\n return p.returncode\n \n-\n-\n def writeShedyml(self):\n- """for planemo\n- """\n+ """for planemo"""\n yuser = self.args.user_email.split("@")[0]\n yfname = os.path.join(self.tooloutdir, ".shed.yml")\n yamlf = open(yfname, "w")\n@@ -875,8 +899,7 @@\n yamlf.close()\n \n def makeTool(self):\n- """write xmls and input samples into place\n- """\n+ """write xmls and input samples into place"""\n self.makeXML()\n if self.args.script_path:\n stname = os.path.join(self.tooloutdir, "%s" % (self.sfile))\n@@ -893,12 +916,17 @@\n shutil.copyfile(pth, dest)\n \n def makeToolTar(self):\n- """ move outputs into test-data and prepare the tarball\n- """\n+ """move outputs into test-data and prepare the tarball"""\n excludeme = "tool_test_output"\n+\n def exclude_function(tarinfo):\n- filename = tarinfo.name\n- return None if filename.startswith(excludeme) or os.path.splitext(filename)[1].startswith(excludeme) else tarinfo\n+ filename = tarinfo.name\n+ return (\n+ None\n+ if filename.startswith(excludeme) or \\\n+ os.path.splitext(filename)[1].startswith(excludeme)\n+ else tarinfo\n+ )\n \n for p in self.outfiles:\n src = p[ONAMEPOS]\n@@ -919,8 +947,7 @@\n shutil.copyfile(self.newtarpath, self.args.new_tool)\n \n def moveRunOutputs(self):\n- """need to move planemo or run outputs into toolfactory collection\n- """\n+ """need to move planemo or run outputs into toolfactory collection"""\n with os.scandir(self.tooloutdir) as outs:\n for entry in outs:\n if not entry.is_file() or entry.name.startswith("."):\n@@ -968,15 +995,16 @@\n a("--tfout", default="./tfout")\n a("--new_tool", default="new_tool")\n a("--galaxy_url", default="http://localhost:8080")\n- a("--toolshed_url", default="http://localhost:9009") # make sure this is NOT 127.0.0.1 - it won\'t work if tool_sheds_conf.xml has localhost\n- #a("--galaxy_api_key", default="1e62ddad74fe9bf112859f4e9efea48b")\n- #a("--toolshed_api_key", default="9154c91f2a162bf12fda15764f43846c")\n+ a(\n+ "--toolshed_url", default="http://localhost:9009"\n+ ) # make sure this is NOT 127.0.0.1 - it won\'t work if tool_sheds_conf.xml has localhost\n+ # a("--galaxy_api_key", default="1e62ddad74fe9bf112859f4e9efea48b")\n+ # a("--toolshed_api_key", default="9154c91f2a162bf12fda15764f43846c")\n \n a("--toolshed_api_key", default="fakekey")\n a("--galaxy_api_key", default="fakekey")\n a("--galaxy_root", default="/galaxy-central")\n \n-\n args = parser.parse_args()\n assert not args.bad_user, (\n \'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file\'\n@@ -1004,11 +1032,10 @@\n retcode = r.planemo_test(genoutputs=False)\n r.moveRunOutputs()\n if args.make_Tool == "gentestinstall":\n- retcode = r.planemo_shedload() #r.shedLoad()\n- print(f\'planemo_shedload returned {retcode}\')\n+ retcode = r.planemo_shedload() # r.shedLoad()\n+ print(f"planemo_shedload returned {retcode}")\n r.eph_galaxy_load()\n \n \n-\n if __name__ == "__main__":\n main()\n' |