diff toolfactory/rgToolFactory2.py @ 131:72d190989c68 draft

Uploaded
author fubar
date Fri, 09 Apr 2021 23:23:12 +0000
parents e8e8071c9d0c
children 65b5e9acf98a
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"""