changeset 131:72d190989c68 draft

Uploaded
author fubar
date Fri, 09 Apr 2021 23:23:12 +0000
parents e8e8071c9d0c
children 65b5e9acf98a
files toolfactory/rgToolFactory2.py toolfactory/rgToolFactory2.xml
diffstat 2 files changed, 58 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/toolfactory/rgToolFactory2.py	Tue Apr 06 03:12:56 2021 +0000
+++ b/toolfactory/rgToolFactory2.py	Fri Apr 09 23:23:12 2021 +0000
@@ -44,7 +44,6 @@
 debug = True
 toolFactoryURL = "https://github.com/fubar2/toolfactory"
 foo = len(lxml.__version__)
-# fug you, flake8. Say my name!
 FAKEEXE = "~~~REMOVE~~~ME~~~"
 # need this until a PR/version bump to fix galaxyxml prepending the exe even
 # with override.
@@ -216,7 +215,7 @@
                 aXCL(c)
 
     def clsimple(self):
-        """no parameters - uses < and > for i/o"""
+        """no parameters or repeats - uses < and > for i/o"""
         aCL = self.cl.append
         aXCL = self.xmlcl.append
         if len(self.infiles) > 0:
@@ -258,13 +257,17 @@
                 clsuffix.append([p["name"], p["name"], ""])
                 xclsuffix.append([p["name"], "$%s" % p["name"], ""])
         for p in self.addpar:
-            clsuffix.append([p["CL"], p["name"], p["override"]])
-            xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
+            nam = p["name"]
+            rep = p["repeat"] == "1"
+            if rep:
+                over = f" #for $rep in $R_{nam}:\n--{nam} $rep.{nam}\n#end for"
+            else:
+                over = p["override"]
+            clsuffix.append([p["CL"], nam, over])
+            xclsuffix.append([p["CL"], nam, over])
         for p in self.selpar:
             clsuffix.append([p["CL"], p["name"], p["override"]])
             xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
-        clsuffix.sort()
-        xclsuffix.sort()
         self.xclsuffix = xclsuffix
         self.clsuffix = clsuffix
 
@@ -296,8 +299,13 @@
                 clsuffix.append([p["CL"], p["name"], ""])
                 xclsuffix.append([p["CL"], "$%s" % p["name"], ""])
         for p in self.addpar:
-            clsuffix.append([p["CL"], p["name"], p["override"]])
-            xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
+            nam = p["name"]
+            rep = p["repeat"] == "1"  # repeats make NO sense
+            if rep:
+                print(f'### warning. Repeats for {nam} ignored - not permitted in positional parameter command lines!')
+            over = p["override"]
+            clsuffix.append([p["CL"], nam, over])
+            xclsuffix.append([p["CL"], nam, over])
         for p in self.selpar:
             clsuffix.append([p["CL"], p["name"], p["override"]])
             xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
@@ -388,12 +396,14 @@
         for (k, v, koverride) in self.xclsuffix:
             if koverride > "":
                 k = koverride
-            elif len(k.strip()) == 1:
-                k = "-%s" % k
+                aXCL(k)
             else:
-                k = "--%s" % k
-            aXCL(k)
-            aXCL(v)
+                if len(k.strip()) == 1:
+                    k = "-%s" % k
+                else:
+                    k = "--%s" % k
+                aXCL(k)
+                aXCL(v)
         for (k, v, koverride) in self.clsuffix:
             if koverride > "":
                 k = koverride
@@ -480,6 +490,7 @@
             newname = p["infilename"]
             newfmt = p["format"]
             ndash = self.getNdash(newname)
+            reps = p.get("repeat",0) == 1
             if not len(p["label"]) > 0:
                 alab = p["CL"]
             else:
@@ -501,9 +512,18 @@
                 else:
                     aninput.positional = int(p["origCL"])
                     aninput.command_line_override = "$%s" % newname
-            self.tinputs.append(aninput)
-            tparm = gxtp.TestParam(name=newname, value="%s_sample" % newname)
-            self.testparam.append(tparm)
+            if reps:
+                repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {newlabel} as needed")
+                repe.append(aninput)
+                self.tinputs.append(repe)
+                tparm = gxtp.TestRepeat(name=f"R_{newname}")
+                tparm2 = gxtp.TestParam(newname, value="%s_sample" % newname)
+                tparm.append(tparm2)
+                self.testparam.append(tparm)
+            else:
+                self.tinputs.append(aninput)
+                tparm = gxtp.TestParam(newname, value="%s_sample" % newname)
+                self.testparam.append(tparm)
         for p in self.addpar:
             newname = p["name"]
             newval = p["value"]
@@ -512,6 +532,7 @@
             newtype = p["type"]
             newcl = p["CL"]
             oldcl = p["origCL"]
+            reps = p["repeat"] == "1"
             if not len(newlabel) > 0:
                 newlabel = newname
             ndash = self.getNdash(newname)
@@ -556,9 +577,18 @@
             aparm.positional = self.is_positional
             if self.is_positional:
                 aparm.positional = int(oldcl)
-            self.tinputs.append(aparm)
-            tparm = gxtp.TestParam(newname, value=newval)
-            self.testparam.append(tparm)
+            if reps:
+                repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {newlabel} as needed")
+                repe.append(aparm)
+                self.tinputs.append(repe)
+                tparm = gxtp.TestRepeat(name=f"R_{newname}")
+                tparm2 = gxtp.TestParam(newname, value=newval)
+                tparm.append(tparm2)
+                self.testparam.append(tparm)
+            else:
+                self.tinputs.append(aparm)
+                tparm = gxtp.TestParam(newname, value=newval)
+                self.testparam.append(tparm)
         for p in self.selpar:
             newname = p["name"]
             newval = p["value"]
@@ -606,8 +636,11 @@
             )
             collect.append(disc)
             self.toutputs.append(collect)
-            tparm = gxtp.TestOutputCollection(newname)
-            self.testparam.append(tparm)
+            try:
+                tparm = gxtp.TestOutputCollection(newname)  # broken until PR merged.
+                self.testparam.append(tparm)
+            except Exception:
+                print("#### WARNING: Galaxyxml version does not have the PR merged yet - tests for collections must be over-ridden until then!")
 
     def doNoXMLparam(self):
         """filter style package - stdin to stdout"""
--- a/toolfactory/rgToolFactory2.xml	Tue Apr 06 03:12:56 2021 +0000
+++ b/toolfactory/rgToolFactory2.xml	Fri Apr 09 23:23:12 2021 +0000
@@ -81,7 +81,7 @@
             <param name="input_CL" type="text" label="Positional: ordinal integer. Argparse: argument name. STDIN if the executable/script expects it"
               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="">
             </param>
-            <param name="input_repeat" type="hidden" checked="False" truevalue="1"  falsevalue="0" label="Allow user to repeat this input as many times as needed." />
+            <param name="input_repeat" type="boolean" checked="False" truevalue="1"  falsevalue="0" label="Allow user to repeat this input as many times as wanted - script/executable must parse these."/>
         </repeat>
         <repeat name="history_outputs" title="one or more new history items output by the executable to appear in the user history after the tool runs"
              help="The name will become a history item for users of the new tool you are making containing one of it's outputs">
@@ -173,14 +173,14 @@
               help="Using positional parameters, enter the integer ordinal for this parameter on the command line. Using Argparse style, '--' will be prepended on the CL" value="" />
           <param name="param_CLprefixed" type="text" label="Override the generated default argparse name prefix if not empty - eg ----foo if needed"
               help="Some targets like Planemo expect an unadorned action like 'test' before --galaxy_root." value="" />
-          <param name="param_repeat" type="hidden" checked="False" truevalue="1"  falsevalue="0" label="Allow user to repeat this as many times as needed." />
+          <param name="param_repeat" type="boolean" checked="False" truevalue="1"  falsevalue="0" label="Allow user to repeat this as many times as needed." />
         </repeat>
         </section>
      </xml>
   </macros>
 
 <requirements>
-   <requirement type="package" version="0.4.12">galaxyxml</requirement>
+   <requirement type="package" version="0.4.13">galaxyxml</requirement>
    <requirement type="package" version="0.14.0">bioblend</requirement>
    <requirement type="package" version="0.10.6">ephemeris</requirement>
    <requirement type="package" version="0.74.3">planemo</requirement>
@@ -253,7 +253,7 @@
      #end for
    #end if
      #for $intab in $io_param.ppass.io.history_inputs:
---input_files '{"name": "$intab.input_files", "CL": "$intab.input_CL", "format": "$intab.input_formats", "label": "$intab.input_label", "help": "$intab.input_help"}'
+--input_files '{"name": "$intab.input_files", "CL": "$intab.input_CL", "format": "$intab.input_formats", "label": "$intab.input_label", "help": "$intab.input_help", "repeat": "$intab.input_repeat"}'
      #end for
      #for $otab in $io_param.ppass.io.history_outputs:
 --output_files '{"name": "$otab.history_name", "format": "$otab.history_format", "CL": "$otab.history_CL", "test": "$otab.history_test"}'