Previous changeset 49:35a912ce0c83 (2020-08-27) Next changeset 51:4b71b252eacb (2020-08-30) |
Commit message:
Uploaded |
modified:
toolfactory/rgToolFactory2.py toolfactory/rgToolFactory2.xml |
added:
toolfactory/tool_dependencies.xml |
b |
diff -r 35a912ce0c83 -r bf432f4486c7 toolfactory/rgToolFactory2.py --- a/toolfactory/rgToolFactory2.py Thu Aug 27 23:11:01 2020 -0400 +++ b/toolfactory/rgToolFactory2.py Sun Aug 30 01:45:27 2020 -0400 |
[ |
b'@@ -23,7 +23,6 @@\n # Be simpler to write the tool, then run it with planemo and soak up the test outputs.\n \n \n-\n import argparse\n import logging\n import os\n@@ -47,7 +46,7 @@\n debug = True\n toolFactoryURL = "https://github.com/fubar2/toolfactory"\n ourdelim = "~~~"\n-ALOT = 10000000 # srsly. command or test overrides use read() so just in case\n+ALOT = 10000000 # srsly. command or test overrides use read() so just in case\n STDIOXML = """<stdio>\n <exit_code range="100:" level="debug" description="shite happens" />\n </stdio>"""\n@@ -172,15 +171,13 @@\n ], \'args.parampass must be "0","positional" or "argparse"\'\n self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name)\n self.tool_id = self.tool_name\n- self.tool = gxt.Tool(\n+ self.newtool = gxt.Tool(\n self.args.tool_name,\n self.tool_id,\n self.args.tool_version,\n self.args.tool_desc,\n- FAKEEXE, \n+ FAKEEXE,\n )\n- if self.args.script_path:\n- self.tool.interpreter = self.executeme\n self.tooloutdir = "tfout"\n self.repdir = "TF_run_report_tempdir"\n self.testdir = os.path.join(self.tooloutdir, "test-data")\n@@ -205,7 +202,7 @@\n self.test_override = [x.rstrip() for x in stos]\n else:\n self.test_override = None\n- if self.args.cl_prefix: # DIY CL start\n+ if self.args.cl_prefix: # DIY CL start\n clp = self.args.cl_prefix.split(" ")\n for c in clp:\n aCL(c)\n@@ -215,6 +212,7 @@\n if self.args.script_path:\n aCL(self.executeme)\n aCL(self.sfile)\n+ aXCL(self.executeme)\n aXCL("$runme")\n else:\n aCL(self.executeme) # this little CL will just run\n@@ -223,12 +221,13 @@\n if self.args.script_path:\n aCL(self.executeme)\n aCL(self.sfile)\n+ aXCL(self.executeme)\n aXCL("$runme")\n else:\n aCL(self.executeme) # this little CL will just run\n aXCL(self.executeme)\n- self.elog = os.path.join(self.repdir,"%s_error_log.txt" % self.tool_name)\n- self.tlog = os.path.join(self.repdir,"%s_runner_log.txt" % self.tool_name)\n+ self.elog = os.path.join(self.repdir, "%s_error_log.txt" % self.tool_name)\n+ self.tlog = os.path.join(self.repdir, "%s_runner_log.txt" % self.tool_name)\n \n if self.args.parampass == "0":\n self.clsimple()\n@@ -412,15 +411,21 @@\n self.toutputs.append(aparm)\n usetest = None\n ld = None\n- if test > \'\':\n- if test.startswith(\'diff\'):\n- usetest = \'diff\'\n- if test.split(\':\')[1].isdigit:\n- ld = int(test.split(\':\')[1])\n+ if test > "":\n+ if test.startswith("diff"):\n+ usetest = "diff"\n+ if test.split(":")[1].isdigit:\n+ ld = int(test.split(":")[1])\n else:\n usetest = test\n- tp = gxtp.TestOutput(name=newcl, value="%s_sample" % newcl, format=newfmt,\n- compare=usetest, lines_diff=ld, delta=None,)\n+ tp = gxtp.TestOutput(\n+ name=newcl,\n+ value="%s_sample" % newcl,\n+ format=newfmt,\n+ compare=usetest,\n+ lines_diff=ld,\n+ delta=None,\n+ )\n self.testparam.append(tp)\n for p in self.infiles:\n newname = p[ICLPOS]\n@@ -526,22 +531,28 @@\n Hmmm. How to get the command line into correct order...\n """\n if self.command_override:\n- self.tool.command_line_override = self.command_override # config file\n+ self.newtool.command_line_o'..b'src)\n+ shutil.copyfile(src, dest)\n+ dest = os.path.join(self.repdir, "%s.%s" % (src, p[OFMTPOS]))\n+ shutil.copyfile(src, dest)\n+ else:\n+ print(\n+ "### problem - output file %s not found in tooloutdir %s"\n+ % (src, self.tooloutdir)\n+ )\n+ self.newtarpath = "toolfactory_%s.tgz" % self.tool_name\n+ tf = tarfile.open(self.newtarpath, "w:gz")\n+ tf.add(name=self.tooloutdir, arcname=self.tool_name)\n+ tf.close()\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+ with os.scandir(self.tooloutdir) as outs:\n+ for entry in outs:\n+ if not entry.is_file() or entry.name.startswith("."):\n+ continue\n+ if "." in entry.name:\n+ nayme, ext = os.path.splitext(entry.name)\n+ else:\n+ ext = ".txt"\n+ ofn = "%s%s" % (entry.name.replace(".", "_"), ext)\n+ dest = os.path.join(self.repdir, ofn)\n+ src = os.path.join(self.tooloutdir, entry.name)\n+ shutil.copyfile(src, dest)\n+\n \n def main():\n """\n@@ -857,10 +889,10 @@\n a("--new_tool", default="new_tool")\n a("--runmode", default=None)\n a("--galaxy_url", default="http://localhost:8080")\n- a("--galaxy_api_key", default="fbdd3c2eecd191e88939fffc02eeeaf8")\n+ a("--galaxy_api_key", default="fakekey")\n a("--toolshed_url", default="http://localhost:9009")\n- a("--toolshed_api_key", default="d46e5ed0e242ed52c6e1f506b5d7f9f7")\n- a("--galaxy_root", default="/home/ross/galaxy")\n+ a("--toolshed_api_key", default="fakekey")\n+ a("--galaxy_root", default="/galaxy-central")\n \n args = parser.parse_args()\n assert not args.bad_user, (\n@@ -878,7 +910,16 @@\n r = ScriptRunner(args)\n r.writeShedyml()\n r.makeTool()\n- if args.make_Tool == "runonly":\n+ if args.command_override or args.test_override:\n+ retcode = r.planemo_test(genoutputs=True) # this fails :( - see PR\n+ r.moveRunOutputs()\n+ r.makeToolTar()\n+ retcode = r.planemo_test(genoutputs=False)\n+ r.moveRunOutputs()\n+ if args.make_Tool == "gentestinstall":\n+ r.planemo_shedload()\n+ r.eph_galaxy_load()\n+ else:\n retcode = r.run()\n if retcode:\n sys.stderr.write(\n@@ -888,32 +929,13 @@\n sys.exit(1)\n else:\n r.moveRunOutputs()\n- elif args.make_Tool in ["gentestinstall", "generate", "gentest"]:\n- retcode = r.run()\n- if retcode:\n- sys.stderr.write(\n- "## Run failed with return code %d. Cannot build yet. Please fix and retry"\n- % retcode\n- )\n- sys.exit(1)\n- r.moveRunOutputs()\n- r.makeToolTar()\n- if args.make_Tool in ["gentestinstall","gentest"]:\n- r.planemo_test(genoutputs=False)\n- r.moveRunOutputs()\n- r.planemo_shedload()\n- r.eph_galaxy_load()\n- else:\n- retcode = r.planemo_test(genoutputs=True) # this fails :(\n- r.moveRunOutputs()\n- r.makeToolTar()\n- retcode = r.planemo_test(genoutputs=False)\n- r.moveRunOutputs()\n- if args.make_Tool == "planemotestinstall":\n- r.planemo_shedload() \n- r.eph_galaxy_load()\n- # if retcode:\n- # sys.exit(retcode) # indicate failure to job runner\n+ r.makeToolTar()\n+ if args.make_Tool in ["gentestinstall", "gentest"]:\n+ r.planemo_test(genoutputs=False)\n+ r.moveRunOutputs()\n+ if args.make_Tool == "gentestinstall":\n+ r.planemo_shedload()\n+ r.eph_galaxy_load()\n \n \n if __name__ == "__main__":\n' |
b |
diff -r 35a912ce0c83 -r bf432f4486c7 toolfactory/rgToolFactory2.xml --- a/toolfactory/rgToolFactory2.xml Thu Aug 27 23:11:01 2020 -0400 +++ b/toolfactory/rgToolFactory2.xml Sun Aug 30 01:45:27 2020 -0400 |
[ |
b'@@ -1,7 +1,7 @@\n <tool id="rgTF2" name="toolfactory" version="2.00" profile="16.04" >\n <description>Scripts into tools</description>\n <macros>\n- <xml name="planemo_steps">\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 <param name="tool_desc" label="Tool Description" type="text" value=""\n@@ -130,22 +130,16 @@\n </repeat>\n </xml>\n </macros>\n- <requirements>\n- <requirement type="package">python</requirement>\n- <requirement type="package">perl</requirement>\n- <requirement type="package">r-base</requirement>\n- <requirement type="package">galaxyxml</requirement>\n- <requirement type="package">planemo</requirement>\n- <requirement type="package">yaml</requirement>\n- <requirement type="package">lxml</requirement>\n- </requirements>\n- <command interpreter="python"><![CDATA[\n+<requirements>\n+ <requirement type="package" version="0.1">planemoenv</requirement>\n+</requirements>\n+ <command ><![CDATA[\n #import os\n #set dev_env = os.environ.get(\'GALAXY_DEVELOPMENT_ENVIRONMENT\', \'0\') == \'1\'\n #if not $dev_env and ( $__user_email__ not in $__admin_users__ ):\n-$__tool_directory__/rgToolFactory2.py --bad_user $__user_email__\n+python3 $__tool_directory__/rgToolFactory2.py --bad_user $__user_email__\n #else:\n-$__tool_directory__/rgToolFactory2.py\n+python3 $__tool_directory__/rgToolFactory2.py\n #if len(str($cl_prefix)) > 3:\n --cl_prefix "$cl_prefix"\n #end if\n@@ -191,9 +185,7 @@\n ]]></command>\n <configfiles>\n <configfile name="runme">\n-#if $usescript.choosescript == \'yes\':\n $usescript.dynScript\n-#end if\n </configfile>\n <configfile name="commandoverride">\n #if $cover.commover == "yes" and len(str($cover.command_override).strip()) > 1:\n@@ -239,32 +231,32 @@\n <conditional name="interexe">\n <param name="dependency_model" type="select" label="Dependency model: Conda managed external dependency or existing system executable"\n help = "If managed, the supplied package will become a requirement so must match the tool dependency resolver package name in conda.">\n- <option value="managed" selected="true" >Use Conda managed dependencies</option>\n- <option value="system" >Use a non-dependency managed system executable like bash or awk</option>\n+ <option value="managed" selected="true" >Use Conda managed dependencies for scripting (python, R,....) or command line packages (bwa,samtools)</option>\n+ <option value="system" >Use a non-dependency managed system executable for scripting like bash or command line driven like sed or awk</option>\n </param>\n <when value="managed">\n- <param name="packages" type="text" value="" label="Package name[:version, name:version...] for Conda. First will be called on generated command line" optional="false"\n- help="Use colon to append specific versiion like \'bwa:0.17.0\'. Default is latest if no version. Will be used every time the tool is (re)run." /> \n+ <param name="packages" type="text" value="" label="Package name[:version, name:version...] for Conda. First (e.g. python) will be called on generated command line" \n+ optional="false" help="Use :[ver] for specific version - \'bwa:0.17.0\'. Default is latest. Will be used every time the tool is (re)run." /> \n <param name="sysexe" type="hidden" value="" />\n </when>\n <when value="system">\n- <param name="sysexe" type="text" value="" label="System executable to run. Supplied/managed by the operating system - not Conda" optional="false"\n+ <param name="sysexe" type="text" value="" label="System executable to run. OS version - not Conda managed" optio'..b'd archive containing the new tool. NOT suitable for command/test overriden tools</option>\n- <option value="gentest">Run, generate and test the new tool with planemo. NOT suitable for command/test overriden tools</option>\n- <option value="gentestinstall">Run, generate, planemo test and install (via the local toolshed) the new tool. NOT suitable for command/test overriden tools</option>\n- <option value="planemogenerate">Planemo test twice - once to generate test outputs. Suitable for tools with or without command/test overrides but takes time</option>\n- <option value="planemogeninstall">Planemo test twice and install. Suitable for tools with or without command/test overrides.</option>\n+ <param name="make_Tool" type="select" display="radio" label="Choose the steps you want to run. The TF Docker container is recommended for local installation"\n+ help="Testing and installation in this Galaxy are optional" >\n+ <option value="runonly">Run this configuration in Galaxy (will run Planemo if command or test override in play)</option>\n+ <option value="generate">Generate a toolshed ready archive.</option>\n+ <option value="gentest" selected="true">Test with planemo after generating.</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="runonly"/>\n <when value="generate">\n- <expand macro="planemo_steps" />\n+ <expand macro="tool_metadata" />\n </when>\n <when value="gentest">\n- <expand macro="planemo_steps" />\n+ <expand macro="tool_metadata" />\n </when>\n <when value="gentestinstall">\n- <expand macro="planemo_steps" />\n- </when>\n- <when value="planemogenerate">\n- <expand macro="planemo_steps" />\n- </when>\n- <when value="planemogeninstall">\n- <expand macro="planemo_steps" />\n+ <expand macro="tool_metadata" />\n </when>\n </conditional>\n \n@@ -361,11 +345,10 @@\n <collection name="TF_run_report" type="list" label="${tool_name} outputs">\n <discover_datasets pattern="__name_and_ext__" directory="TF_run_report_tempdir" />\n </collection>\n-\n-\n </outputs>\n <tests>\n <test>\n+ <param name="user_email" value="admin@galaxy.org"/>\n <param name="input_files" value="input1_sample" />\n <param name="input_CL" value="1" />\n <param name="input_formats" value="txt" />\n@@ -377,13 +360,14 @@\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- <param name="interpreter" value="python"/>\n- <param name="history_name" value="output2_sample" />\n+ <param name="packages" value="python"/>\n+ <param name="history_name" value="output2" />\n <param name="history_format" value="txt" />\n <param name="history_CL" value="2" />\n <param name="dynScript" value="import sys; inp = sys.argv[1]; outp = sys.argv[2]; inlist = open(inp,\'r\').readlines(); o = open(outp,\'w\'); rs = [\'\'.join(list(reversed(x.rstrip()))) for x in inlist]; o.write(\'\\n\'.join(rs)); o.close()"/>\n+ <param name="choosescript" value="yes" />\n+ <param name="script_path" value="$runme"/>\n <output name="new_tool" file="toolfactory_pyrevpos_tgz_sample" compare="sim_size" delta="6000" />\n- <!-- <output name="output" file="output2_sample" ftype="txt" compare="diff" lines_diff = "10" /> -->\n </test>\n </tests>\n <help>\n@@ -472,13 +456,10 @@\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+Paper_ \n \n-**Licensing**\n+*Licensing*\n \n Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012\n All rights reserved.\n' |
b |
diff -r 35a912ce0c83 -r bf432f4486c7 toolfactory/tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/tool_dependencies.xml Sun Aug 30 01:45:27 2020 -0400 |
b |
@@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="planemoenv"> + <install version="0.1"> + <actions> + <action python="3.6" type="setup_virtualenv"> + planemo==0.72.0.dev0 + bioblend==0.14.0 + ephemeris==0.10.6 + galaxyxml==0.4.10 + lxml==4.5.1 + </action> + </actions> + </install> + </package> +</tool_dependency> |