# HG changeset patch # User fubar # Date 1597211026 14400 # Node ID a30536c100bf1a965190bb11c71e5ed6cd21a7d6 # Parent 099047ee7094382d84f349df17bed1fe2d5ebe6f Updated history outputs diff -r 099047ee7094 -r a30536c100bf toolfactory/galaxyxml/__init__.py --- a/toolfactory/galaxyxml/__init__.py Mon Aug 10 23:25:51 2020 -0400 +++ b/toolfactory/galaxyxml/__init__.py Wed Aug 12 01:43:46 2020 -0400 @@ -1,5 +1,6 @@ +from builtins import object from builtins import str -from builtins import object + from lxml import etree @@ -17,11 +18,7 @@ """Recursive data sanitisation """ if isinstance(data, dict): - return { - k: cls.coerce(v, kill_lists=kill_lists) - for k, v in list(data.items()) - if v is not None - } + return {k: cls.coerce(v, kill_lists=kill_lists) for k, v in list(data.items()) if v is not None} elif isinstance(data, list): if kill_lists: return cls.coerce(data[0]) diff -r 099047ee7094 -r a30536c100bf toolfactory/galaxyxml/__pycache__/__init__.cpython-36.pyc Binary file toolfactory/galaxyxml/__pycache__/__init__.cpython-36.pyc has changed diff -r 099047ee7094 -r a30536c100bf toolfactory/galaxyxml/tool/__init__.py --- a/toolfactory/galaxyxml/tool/__init__.py Mon Aug 10 23:25:51 2020 -0400 +++ b/toolfactory/galaxyxml/tool/__init__.py Wed Aug 12 01:43:46 2020 -0400 @@ -1,8 +1,10 @@ import copy import logging + +from galaxyxml import GalaxyXML, Util +from galaxyxml.tool.parameters import XMLParam + from lxml import etree -from galaxyxml import Util, GalaxyXML -from galaxyxml.tool.parameters import XMLParam VALID_TOOL_TYPES = ("data_source", "data_source_async") VALID_URL_METHODS = ("get", "post") @@ -12,6 +14,7 @@ class Tool(GalaxyXML): + def __init__( self, name, @@ -51,9 +54,7 @@ if tool_type is not None: if tool_type not in VALID_TOOL_TYPES: - raise Exception( - "Tool type must be one of %s" % ",".join(VALID_TOOL_TYPES) - ) + raise Exception("Tool type must be one of %s" % ",".join(VALID_TOOL_TYPES)) else: kwargs["tool_type"] = tool_type @@ -61,9 +62,7 @@ if URL_method in VALID_URL_METHODS: kwargs["URL_method"] = URL_method else: - raise Exception( - "URL_method must be one of %s" % ",".join(VALID_URL_METHODS) - ) + raise Exception("URL_method must be one of %s" % ",".join(VALID_URL_METHODS)) description_node = etree.SubElement(self.root, "description") description_node.text = description @@ -150,16 +149,10 @@ if getattr(self, "command", None): command_node.text = etree.CDATA(export_xml.command) else: - logger.warning( - "The tool does not have any old command stored. " - + "Only the command line is written." - ) + logger.warning("The tool does not have any old command stored. " + "Only the command line is written.") command_node.text = export_xml.executable else: - actual_cli = "%s %s" % ( - export_xml.executable, - export_xml.clean_command_string(command_line), - ) + actual_cli = "%s %s" % (export_xml.executable, export_xml.clean_command_string(command_line)) command_node.text = etree.CDATA(actual_cli.strip()) try: diff -r 099047ee7094 -r a30536c100bf toolfactory/galaxyxml/tool/__pycache__/__init__.cpython-36.pyc Binary file toolfactory/galaxyxml/tool/__pycache__/__init__.cpython-36.pyc has changed diff -r 099047ee7094 -r a30536c100bf toolfactory/galaxyxml/tool/import_xml.py --- a/toolfactory/galaxyxml/tool/import_xml.py Mon Aug 10 23:25:51 2020 -0400 +++ b/toolfactory/galaxyxml/tool/import_xml.py Wed Aug 12 01:43:46 2020 -0400 @@ -1,5 +1,6 @@ import logging import xml.etree.ElementTree as ET + import galaxyxml.tool as gxt import galaxyxml.tool.parameters as gxtp @@ -115,9 +116,7 @@ value = req.text if req.tag == "requirement": version = req.attrib.get("version", None) - tool.requirements.append( - gxtp.Requirement(req_type, value, version=version) - ) + tool.requirements.append(gxtp.Requirement(req_type, value, version=version)) elif req.tag == "container": tool.requirements.append(gxtp.Container(req_type, value)) else: @@ -350,9 +349,7 @@ """ root.append( gxtp.SelectOption( - option.attrib.get("value", None), - option.text, - selected=option.attrib.get("selected", False), + option.attrib.get("value", None), option.text, selected=option.attrib.get("selected", False) ) ) @@ -432,13 +429,9 @@ # Deal with child nodes (usually option and options) for sel_child in sel_param: try: - getattr(self, "_load_{}_select".format(sel_child.tag))( - select_param, sel_child - ) + getattr(self, "_load_{}_select".format(sel_child.tag))(select_param, sel_child) except AttributeError: - logger.warning( - sel_child.tag + " tag is not processed for ." - ) + logger.warning(sel_child.tag + " tag is not processed for .") root.append(select_param) def _load_param(self, root, param_root): @@ -539,12 +532,7 @@ try: getattr(self, "_load_{}".format(inp_child.tag))(root, inp_child) except AttributeError: - logger.warning( - inp_child.tag - + " tag is not processed for <" - + inputs_root.tag - + "> tag." - ) + logger.warning(inp_child.tag + " tag is not processed for <" + inputs_root.tag + "> tag.") class OutputsParser(object): @@ -589,9 +577,7 @@ for chfmt_child in chfmt_root: change_format.append( gxtp.ChangeFormatWhen( - chfmt_child.attrib["input"], - chfmt_child.attrib["format"], - chfmt_child.attrib["value"], + chfmt_child.attrib["input"], chfmt_child.attrib["format"], chfmt_child.attrib["value"] ) ) root.append(change_format) @@ -618,9 +604,7 @@ try: getattr(self, "_load_{}".format(coll_child.tag))(collection, coll_child) except AttributeError: - logger.warning( - coll_child.tag + " tag is not processed for ." - ) + logger.warning(coll_child.tag + " tag is not processed for .") outputs_root.append(collection) def _load_discover_datasets(self, root, disc_root): @@ -725,7 +709,5 @@ try: getattr(self, "_load_{}".format(test_child.tag))(test, test_child) except AttributeError: - logger.warning( - test_child.tag + " tag is not processed within ." - ) + logger.warning(test_child.tag + " tag is not processed within .") root.append(test) diff -r 099047ee7094 -r a30536c100bf toolfactory/galaxyxml/tool/parameters/__init__.py --- a/toolfactory/galaxyxml/tool/parameters/__init__.py Mon Aug 10 23:25:51 2020 -0400 +++ b/toolfactory/galaxyxml/tool/parameters/__init__.py Wed Aug 12 01:43:46 2020 -0400 @@ -1,7 +1,10 @@ +from builtins import object from builtins import str -from builtins import object + +from galaxyxml import Util + from lxml import etree -from galaxyxml import Util + class XMLParam(object): @@ -23,13 +26,11 @@ self.children.append(sub_node) else: raise Exception( - "Child was unacceptable to parent (%s is not appropriate for %s)" - % (type(self), type(sub_node)) + "Child was unacceptable to parent (%s is not appropriate for %s)" % (type(self), type(sub_node)) ) else: raise Exception( - "Child was unacceptable to parent (%s is not appropriate for %s)" - % (type(self), type(sub_node)) + "Child was unacceptable to parent (%s is not appropriate for %s)" % (type(self), type(sub_node)) ) def validate(self): @@ -155,9 +156,7 @@ # This bodes to be an issue -__- def acceptable_child(self, child): - return issubclass(type(child), Requirement) or issubclass( - type(child), Container - ) + return issubclass(type(child), Requirement) or issubclass(type(child), Container) class Requirement(XMLParam): @@ -187,9 +186,7 @@ name = "configfiles" def acceptable_child(self, child): - return issubclass(type(child), Configfile) or issubclass( - type(child), ConfigfileDefaultInputs - ) + return issubclass(type(child), Configfile) or issubclass(type(child), ConfigfileDefaultInputs) class Configfile(XMLParam): @@ -217,15 +214,7 @@ name = "inputs" # This bodes to be an issue -__- - def __init__( - self, - action=None, - check_value=None, - method=None, - target=None, - nginx_upload=None, - **kwargs, - ): + def __init__(self, action=None, check_value=None, method=None, target=None, nginx_upload=None, **kwargs): params = Util.clean_kwargs(locals().copy()) super(Inputs, self).__init__(**params) @@ -262,9 +251,7 @@ # TODO: replace with positional attribute if len(self.flag()) > 0: if kwargs["label"] is None: - kwargs[ - "label" - ] = "Author did not provide help for this parameter... " + kwargs["label"] = "Author did not provide help for this parameter... " if not self.positional: kwargs["argument"] = self.flag() @@ -297,11 +284,7 @@ if self.positional: return self.mako_name() else: - return "%s%s%s" % ( - self.flag(), - self.space_between_arg, - self.mako_name(), - ) + return "%s%s%s" % (self.flag(), self.space_between_arg, self.mako_name()) def mako_name(self): # TODO: enhance logic to check up parents for things like @@ -353,9 +336,7 @@ super(Conditional, self).__init__(**params) def acceptable_child(self, child): - return issubclass(type(child), InputParameter) and not isinstance( - child, Conditional - ) + return issubclass(type(child), InputParameter) and not isinstance(child, Conditional) def validate(self): # Find a way to check if one of the kids is a WHEN @@ -383,22 +364,16 @@ super(Param, self).__init__(**params) if type(self) == Param: - raise Exception( - "Param class is not an actual parameter type, use a subclass of Param" - ) + raise Exception("Param class is not an actual parameter type, use a subclass of Param") def acceptable_child(self, child): - return issubclass( - type(child, InputParameter) or isinstance(child), ValidatorParam - ) + return issubclass(type(child, InputParameter) or isinstance(child), ValidatorParam) class TextParam(Param): type = "text" - def __init__( - self, name, optional=None, label=None, help=None, value=None, **kwargs - ): + def __init__(self, name, optional=None, label=None, help=None, value=None, **kwargs): params = Util.clean_kwargs(locals().copy()) super(TextParam, self).__init__(**params) @@ -413,17 +388,7 @@ class _NumericParam(Param): - def __init__( - self, - name, - value, - optional=None, - label=None, - help=None, - min=None, - max=None, - **kwargs, - ): + def __init__(self, name, value, optional=None, label=None, help=None, min=None, max=None, **kwargs): params = Util.clean_kwargs(locals().copy()) super(_NumericParam, self).__init__(**params) @@ -440,15 +405,7 @@ type = "boolean" def __init__( - self, - name, - optional=None, - label=None, - help=None, - checked=False, - truevalue=None, - falsevalue=None, - **kwargs, + self, name, optional=None, label=None, help=None, checked=False, truevalue=None, falsevalue=None, **kwargs ): params = Util.clean_kwargs(locals().copy()) @@ -477,16 +434,7 @@ class DataParam(Param): type = "data" - def __init__( - self, - name, - optional=None, - label=None, - help=None, - format=None, - multiple=None, - **kwargs, - ): + def __init__(self, name, optional=None, label=None, help=None, format=None, multiple=None, **kwargs): params = Util.clean_kwargs(locals().copy()) super(DataParam, self).__init__(**params) @@ -505,7 +453,7 @@ multiple=None, options=None, default=None, - **kwargs, + **kwargs ): params = Util.clean_kwargs(locals().copy()) del params["options"] @@ -544,14 +492,7 @@ class Options(InputParameter): name = "options" - def __init__( - self, - from_dataset=None, - from_file=None, - from_data_table=None, - from_parameter=None, - **kwargs, - ): + def __init__(self, from_dataset=None, from_file=None, from_data_table=None, from_parameter=None, **kwargs): params = Util.clean_kwargs(locals().copy()) super(Options, self).__init__(None, **params) @@ -583,7 +524,7 @@ value=None, ref_attribute=None, index=None, - **kwargs, + **kwargs ): params = Util.clean_kwargs(locals().copy()) super(Filter, self).__init__(**params) @@ -602,7 +543,7 @@ line_startswith=None, min=None, max=None, - **kwargs, + **kwargs ): params = Util.clean_kwargs(locals().copy()) super(ValidatorParam, self).__init__(**params) @@ -630,7 +571,7 @@ label=None, from_work_dir=None, hidden=False, - **kwargs, + **kwargs ): # TODO: validate format_source&metadata_source against something in the # XMLParam children tree. @@ -659,11 +600,7 @@ return flag + self.mako_identifier def acceptable_child(self, child): - return ( - isinstance(child, OutputFilter) - or isinstance(child, ChangeFormat) - or isinstance(child, DiscoverDatasets) - ) + return isinstance(child, OutputFilter) or isinstance(child, ChangeFormat) or isinstance(child, DiscoverDatasets) class OutputFilter(XMLParam): @@ -713,25 +650,19 @@ type_source=None, structured_like=None, inherit_format=None, - **kwargs, + **kwargs ): params = Util.clean_kwargs(locals().copy()) super(OutputCollection, self).__init__(**params) def acceptable_child(self, child): - return ( - isinstance(child, OutputData) - or isinstance(child, OutputFilter) - or isinstance(child, DiscoverDatasets) - ) + return isinstance(child, OutputData) or isinstance(child, OutputFilter) or isinstance(child, DiscoverDatasets) class DiscoverDatasets(XMLParam): name = "discover_datasets" - def __init__( - self, pattern, directory=None, format=None, ext=None, visible=None, **kwargs - ): + def __init__(self, pattern, directory=None, format=None, ext=None, visible=None, **kwargs): params = Util.clean_kwargs(locals().copy()) super(DiscoverDatasets, self).__init__(**params) @@ -773,7 +704,7 @@ compare=None, lines_diff=None, delta=None, - **kwargs, + **kwargs ): params = Util.clean_kwargs(locals().copy()) super(TestOutput, self).__init__(**params) diff -r 099047ee7094 -r a30536c100bf toolfactory/galaxyxml/tool/parameters/__pycache__/__init__.cpython-36.pyc Binary file toolfactory/galaxyxml/tool/parameters/__pycache__/__init__.cpython-36.pyc has changed diff -r 099047ee7094 -r a30536c100bf toolfactory/rgToolFactory2.py --- a/toolfactory/rgToolFactory2.py Mon Aug 10 23:25:51 2020 -0400 +++ b/toolfactory/rgToolFactory2.py Wed Aug 12 01:43:46 2020 -0400 @@ -1,3 +1,4 @@ +#!/usr/bin/env python # rgToolFactory.py # see https://github.com/fubar2/toolfactory # @@ -33,40 +34,45 @@ import galaxyxml.tool as gxt import galaxyxml.tool.parameters as gxtp + import lxml -foo = lxml.__name__ # fug you, flake8. Say my name! Please accept the PR, Helena! - -progname = os.path.split(sys.argv[0])[1] myversion = "V2.1 July 2020" verbose = True debug = True toolFactoryURL = "https://github.com/fubar2/toolfactory" ourdelim = "~~~" -# --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label~~~$input_help" +# --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label +# ~~~$input_help" IPATHPOS = 0 ICLPOS = 1 IFMTPOS = 2 ILABPOS = 3 IHELPOS = 4 IOCLPOS = 5 + # --output_files "$otab.history_name~~~$otab.history_format~~~$otab.CL ONAMEPOS = 0 OFMTPOS = 1 OCLPOS = 2 OOCLPOS = 3 -# --additional_parameters="$i.param_name~~~$i.param_value~~~$i.param_label~~~$i.param_help~~~$i.param_type~~~$i.CL" +# --additional_parameters="$i.param_name~~~$i.param_value~~~ +# $i.param_label~~~$i.param_help~~~$i.param_type~~~$i.CL~~~i$.param_CLoverride" ANAMEPOS = 0 AVALPOS = 1 ALABPOS = 2 AHELPPOS = 3 ATYPEPOS = 4 ACLPOS = 5 -AOCLPOS = 6 +AOVERPOS = 6 +AOCLPOS = 7 +foo = len(lxml.__version__) +# fug you, flake8. Say my name! + def timenow(): """return current time as a string """ @@ -108,9 +114,11 @@ citation_tuples = [] for citation in citations: if citation.startswith("doi"): - citation_tuples.append(("doi", citation[len("doi"):].strip())) + citation_tuples.append(("doi", citation[len("doi") :].strip())) else: - citation_tuples.append(("bibtex", citation[len("bibtex"):].strip())) + citation_tuples.append( + ("bibtex", citation[len("bibtex") :].strip()) + ) return citation_tuples @@ -144,7 +152,6 @@ ], 'Parameter passing in args.parampass must be "0","positional" or "argparse"' self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name) self.tool_id = self.tool_name - self.xmlfile = "%s.xml" % self.tool_name if self.args.interpreter_name: exe = "$runMe" else: @@ -177,25 +184,41 @@ clsuffix = [] xclsuffix = [] for i, p in enumerate(self.infiles): - appendme = [p[IOCLPOS], p[ICLPOS], p[IPATHPOS]] + if p[IOCLPOS] == "STDIN": + appendme = [ + p[IOCLPOS], + p[ICLPOS], + p[IPATHPOS], + "< %s" % p[IPATHPOS], + ] + xappendme = [ + p[IOCLPOS], + p[ICLPOS], + p[IPATHPOS], + "< $%s" % p[ICLPOS], + ] + else: + appendme = [p[IOCLPOS], p[ICLPOS], p[IPATHPOS], ""] + xappendme = [p[IOCLPOS], p[ICLPOS], "$%s" % p[ICLPOS], ""] clsuffix.append(appendme) - xclsuffix.append([p[IOCLPOS], p[ICLPOS], "$%s" % p[ICLPOS]]) + xclsuffix.append(xappendme) # print('##infile i=%d, appendme=%s' % (i,appendme)) for i, p in enumerate(self.outfiles): if p[OOCLPOS] == "STDOUT": self.lastclredirect = [">", p[ONAMEPOS]] self.lastxclredirect = [">", "$%s" % p[OCLPOS]] - # print('##outfiles i=%d lastclredirect = %s' % (i,self.lastclredirect)) else: - appendme = [p[OOCLPOS], p[OCLPOS], p[ONAMEPOS]] - clsuffix.append(appendme) - xclsuffix.append([p[OOCLPOS], p[OCLPOS], "$%s" % p[ONAMEPOS]]) - # print('##outfiles i=%d' % i,'appendme',appendme) + clsuffix.append([p[OOCLPOS], p[OCLPOS], p[ONAMEPOS], ""]) + xclsuffix.append( + [p[OOCLPOS], p[OCLPOS], "$%s" % p[ONAMEPOS], ""] + ) for p in self.addpar: - appendme = [p[AOCLPOS], p[ACLPOS], p[AVALPOS]] - clsuffix.append(appendme) - xclsuffix.append([p[AOCLPOS], p[ACLPOS], '"$%s"' % p[ANAMEPOS]]) - # print('##adpar %d' % i,'appendme=',appendme) + clsuffix.append( + [p[AOCLPOS], p[ACLPOS], p[AVALPOS], p[AOVERPOS]] + ) + xclsuffix.append( + [p[AOCLPOS], p[ACLPOS], '"$%s"' % p[ANAMEPOS], p[AOVERPOS]] + ) clsuffix.sort() xclsuffix.sort() self.xclsuffix = xclsuffix @@ -213,13 +236,17 @@ assert len(rxcheck) > 0, "Supplied script is empty. Cannot run" self.script = "\n".join(rx) fhandle, self.sfile = tempfile.mkstemp( - prefix=self.tool_name, suffix=".%s" % (self.args.interpreter_name) + prefix=self.tool_name, suffix="_%s" % (self.args.interpreter_name) ) tscript = open(self.sfile, "w") tscript.write(self.script) tscript.close() - self.indentedScript = " %s" % "\n".join([" %s" % html_escape(x) for x in rx]) - self.escapedScript = "%s" % "\n".join([" %s" % html_escape(x) for x in rx]) + self.indentedScript = " %s" % "\n".join( + [" %s" % html_escape(x) for x in rx] + ) + self.escapedScript = "%s" % "\n".join( + [" %s" % html_escape(x) for x in rx] + ) art = "%s.%s" % (self.tool_name, self.args.interpreter_name) artifact = open(art, "wb") artifact.write(bytes(self.script, "utf8")) @@ -282,13 +309,13 @@ def clpositional(self): # inputs in order then params aCL = self.cl.append - for (o_v, k, v) in self.clsuffix: + for (o_v, k, v, koverride) in self.clsuffix: if " " in v: aCL("%s" % v) else: aCL(v) aXCL = self.xmlcl.append - for (o_v, k, v) in self.xclsuffix: + for (o_v, k, v, koverride) in self.xclsuffix: aXCL(v) if self.lastxclredirect: aXCL(self.lastxclredirect[0]) @@ -300,15 +327,19 @@ aCL = self.cl.append aXCL = self.xmlcl.append # inputs then params in argparse named form - for (o_v, k, v) in self.xclsuffix: - if len(k.strip()) == 1: + for (o_v, k, v, koverride) in self.xclsuffix: + if koverride > "": + k = koverride + elif len(k.strip()) == 1: k = "-%s" % k else: k = "--%s" % k aXCL(k) aXCL(v) - for (o_v, k, v) in self.clsuffix: - if len(k.strip()) == 1: + for (o_v, k, v, koverride) in self.clsuffix: + if koverride > "": + k = koverride + elif len(k.strip()) == 1: k = "-%s" % k else: k = "--%s" % k @@ -339,7 +370,9 @@ aparm.positional = int(oldcl) aparm.command_line_override = "$%s" % newcl self.toutputs.append(aparm) - tp = gxtp.TestOutput(name=newcl, value="%s_sample" % newcl, format=newfmt) + tp = gxtp.TestOutput( + name=newcl, value="%s_sample" % newcl, format=newfmt + ) self.testparam.append(tp) for p in self.infiles: newname = p[ICLPOS] @@ -363,7 +396,7 @@ tparm = gxtp.TestParam(name=newname, value="%s_sample" % newname) self.testparam.append(tparm) for p in self.addpar: - newname, newval, newlabel, newhelp, newtype, newcl, oldcl = p + newname, newval, newlabel, newhelp, newtype, newcl, override, oldcl = p if not len(newlabel) > 0: newlabel = newname ndash = self.getNdash(newname) @@ -434,7 +467,9 @@ anout.command_line_override = "> $%s" % newname anout.positional = self.is_positional self.toutputs.append(anout) - tp = gxtp.TestOutput(name=newname, value="%s_sample" % newname, format=newfmt) + tp = gxtp.TestOutput( + name=newname, value="%s_sample" % newname, format=newfmt + ) self.testparam.append(tp) def makeXML(self): @@ -445,7 +480,7 @@ """ self.tool.command_line_override = self.xmlcl if self.args.interpreter_name: - self.tool.interpreter = self.interp + self.tool.interpreter = self.args.interpreter_name if self.args.help_text: helptext = open(self.args.help_text, "r").readlines() helptext = [html_escape(x) for x in helptext] @@ -462,7 +497,9 @@ if self.args.interpreter_name: if self.args.interpreter_name == "python": requirements.append( - gxtp.Requirement("package", "python", self.args.interpreter_version) + gxtp.Requirement( + "package", "python", self.args.interpreter_version + ) ) elif self.args.interpreter_name not in ["bash", "sh"]: requirements.append( @@ -476,14 +513,16 @@ if self.args.exe_package and self.args.parampass != "system": requirements.append( gxtp.Requirement( - "package", self.args.exe_package, self.args.exe_package_version + "package", + self.args.exe_package, + self.args.exe_package_version, ) ) self.tool.requirements = requirements if self.args.parampass == "0": - self.doXMLNoparam() + self.doNoXMLparam() else: - self.doXMLParam() + self.doXMLparam() self.tool.outputs = self.toutputs self.tool.inputs = self.tinputs if self.args.runmode not in ["Executable", "system"]: @@ -505,7 +544,7 @@ "Cite: Creating re-usable tools from scripts doi: 10.1093/bioinformatics/bts573" ) exml = self.tool.export() - xf = open(self.xmlfile, "w") + xf = open('%s.xml' % self.tool_name, "w") xf.write(exml) xf.write("\n") xf.close() @@ -520,7 +559,9 @@ """ retval = self.run() if retval: - sys.stderr.write("## Run failed. Cannot build yet. Please fix and retry") + sys.stderr.write( + "## Run failed. Cannot build yet. Please fix and retry" + ) sys.exit(1) tdir = "tfout" if not os.path.exists(tdir): @@ -549,19 +590,32 @@ shutil.copyfile(pth, dest) if os.path.exists(self.tlog) and os.stat(self.tlog).st_size > 0: - shutil.copyfile(self.tlog, os.path.join(testdir, "test1_log.txt")) + shutil.copyfile(self.tlog, os.path.join(testdir, "test1_log_outfiletxt")) if self.args.runmode not in ["Executable", "system"]: stname = os.path.join(tdir, "%s" % (self.sfile)) if not os.path.exists(stname): shutil.copyfile(self.sfile, stname) - xtname = os.path.join(tdir, self.xmlfile) - if not os.path.exists(xtname): - shutil.copyfile(self.xmlfile, xtname) + xreal = '%s.xml' % self.tool_name + xout = os.path.join(tdir,xreal) + shutil.copyfile(xreal, xout) tarpath = "toolfactory_%s.tgz" % self.tool_name tf = tarfile.open(tarpath, "w:gz") tf.add(name=tdir, arcname=self.tool_name) tf.close() shutil.copyfile(tarpath, self.args.new_tool) + shutil.copyfile(xreal,"tool_xml.txt") + repdir = "TF_run_report_tempdir" + if not os.path.exists(repdir): + os.mkdir(repdir) + repoutnames = [x[OCLPOS] for x in self.outfiles] + with os.scandir('.') as outs: + for entry in outs: + if entry.name.endswith('.tgz') or not entry.is_file(): + continue + if entry.name in repoutnames: + shutil.copyfile(entry.name,os.path.join(repdir,entry.name)) + elif entry.name == "%s.xml" % self.tool_name: + shutil.copyfile(entry.name,os.path.join(repdir,"new_tool_xml")) return retval def run(self): @@ -577,12 +631,15 @@ if self.args.parampass != "0": ste = open(self.elog, "wb") if self.lastclredirect: - sto = open(self.lastclredirect[1], "wb") # is name of an output file + sto = open( + self.lastclredirect[1], "wb" + ) # is name of an output file else: sto = open(self.tlog, "wb") sto.write( bytes( - "## Executing Toolfactory generated command line = %s\n" % scl, + "## Executing Toolfactory generated command line = %s\n" + % scl, "utf8", ) ) @@ -654,17 +711,23 @@ 'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file' % (args.bad_user, args.bad_user) ) - assert args.tool_name, "## Tool Factory expects a tool name - eg --tool_name=DESeq" + assert ( + args.tool_name + ), "## Tool Factory expects a tool name - eg --tool_name=DESeq" assert ( args.interpreter_name or args.exe_package ), "## Tool Factory wrapper expects an interpreter or an executable package" assert args.exe_package or ( len(args.script_path) > 0 and os.path.isfile(args.script_path) ), "## Tool Factory wrapper expects a script path - eg --script_path=foo.R if no executable" - args.input_files = [x.replace('"', "").replace("'", "") for x in args.input_files] + args.input_files = [ + x.replace('"', "").replace("'", "") for x in args.input_files + ] # remove quotes we need to deal with spaces in CL params for i, x in enumerate(args.additional_parameters): - args.additional_parameters[i] = args.additional_parameters[i].replace('"', "") + args.additional_parameters[i] = args.additional_parameters[i].replace( + '"', "" + ) r = ScriptRunner(args) if args.make_Tool: retcode = r.makeTooltar() diff -r 099047ee7094 -r a30536c100bf toolfactory/rgToolFactory2.xml --- a/toolfactory/rgToolFactory2.xml Mon Aug 10 23:25:51 2020 -0400 +++ b/toolfactory/rgToolFactory2.xml Wed Aug 12 01:43:46 2020 -0400 @@ -1,10 +1,10 @@ - + Scripts into tools - @@ -12,7 +12,7 @@ - @@ -20,33 +20,31 @@ + help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation"> - + - + - - + - @@ -54,10 +52,10 @@ - + - + @@ -65,14 +63,14 @@ - - @@ -80,23 +78,25 @@ + help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation" > - - + + + - - @@ -108,9 +108,9 @@ - - @@ -130,15 +130,15 @@ #if not $dev_env and ( $__user_email__ not in $__admin_users__ ): $__tool_directory__/rgToolFactory2.py --bad_user $__user_email__ #else: -$__tool_directory__/rgToolFactory2.py +$__tool_directory__/rgToolFactory2.py --runmode "$interexe.interpreter" #if str($interexe.interpreter)=="Executable" or str($interexe.interpreter)=="system": ---exe_package="$interexe.exe_package" - #if str($interexe.exe_package_version) != 'None' : ---exe_package_version="$interexe.exe_package_version" +--exe_package="$interexe.exe_package" + #if str($interexe.exe_package_version) != 'None' : +--exe_package_version="$interexe.exe_package_version" #end if #else: ---interpreter_name="$interexe.interpreter" --script_path "$runme" +--interpreter_name="$interexe.interpreter" --script_path "$runme" #if str($interexe.interpreter_version) != 'None': --interpreter_version="$interexe.interpreter_version" #end if @@ -153,10 +153,10 @@ #end if #if $ppass.parampass != '0': #if str($ppass.edit_params) == "yes": ---edit_additional_parameters +--edit_additional_parameters #end if #for apar in $ppass.additional_parameters: ---additional_parameters="$apar.param_name~~~$apar.param_value~~~$apar.param_label~~~$apar.param_help~~~$apar.param_type~~~$apar.param_CL" +--additional_parameters="$apar.param_name~~~$apar.param_value~~~$apar.param_label~~~$apar.param_help~~~$apar.param_type~~~$apar.param_CL~~~$apar.param_CLprefixed" #end for #end if @@ -168,7 +168,7 @@ #for $otab in $ppass.history_outputs: --output_files "$otab.history_name~~~$otab.history_format~~~$otab.history_CL" #end for - #end if + #end if ]]> @@ -202,14 +202,14 @@ - - + @@ -223,11 +223,11 @@ - - + + - + @@ -253,9 +253,9 @@ - - - + + + @@ -268,22 +268,21 @@ - + - + - - + @@ -297,11 +296,11 @@ - - @@ -315,15 +314,19 @@ - + - - - - + + makeMode['make_Tool'] == "yes" + + + + + + @@ -342,27 +345,25 @@ - - - - + + .. class:: warningmark -**Details and attribution** +**Details and attribution** (see GTF_) -**Local Admins ONLY** +**Local Admins ONLY** Only users whose IDs found in the local admin_user configuration setting in universe_wsgi.ini can run this tool. -**If you find a bug** +**If you find a bug** Please raise an issue, or even better, submit a pull request fixing it, on the github repository GTF_ -**What it does** +**What it does** This tool optionally generates normal workflow compatible first class Galaxy tools Generated tools can run existing binary packages that become requirements, existing scripts, or new scripts pasted into this tool form. @@ -382,7 +383,7 @@ .. class:: warningmark -**Note to system administrators** +**Note to system administrators** This tool offers *NO* built in protection against malicious scripts. It should only be installed on private/personnal Galaxy instances. Admin_users will have the power to do anything they want as the Galaxy user if you install this tool. @@ -412,7 +413,7 @@ o.close() With argparse style parameters: - + :: # reverse order of text by row @@ -433,7 +434,7 @@ o.write(''.join(rs)) o.write('\n') o.close() - + Paper_ : @@ -441,7 +442,7 @@ Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573 -**Licensing** +**Licensing** Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012 All rights reserved. diff -r 099047ee7094 -r a30536c100bf toolfactory/testtf.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolfactory/testtf.sh Wed Aug 12 01:43:46 2020 -0400 @@ -0,0 +1,2 @@ +planemo test --no_cleanup --no_dependency_resolution --skip_venv --galaxy_root ~/galaxy ~/galaxy/tools/tool_makers/toolfactory &>foo +