Mercurial > repos > fubar > tool_factory_2
comparison toolfactory/rgToolFactory2.py @ 131:72d190989c68 draft
Uploaded
author | fubar |
---|---|
date | Fri, 09 Apr 2021 23:23:12 +0000 |
parents | e8e8071c9d0c |
children | 65b5e9acf98a |
comparison
equal
deleted
inserted
replaced
130:e8e8071c9d0c | 131:72d190989c68 |
---|---|
42 myversion = "V2.2 February 2021" | 42 myversion = "V2.2 February 2021" |
43 verbose = True | 43 verbose = True |
44 debug = True | 44 debug = True |
45 toolFactoryURL = "https://github.com/fubar2/toolfactory" | 45 toolFactoryURL = "https://github.com/fubar2/toolfactory" |
46 foo = len(lxml.__version__) | 46 foo = len(lxml.__version__) |
47 # fug you, flake8. Say my name! | |
48 FAKEEXE = "~~~REMOVE~~~ME~~~" | 47 FAKEEXE = "~~~REMOVE~~~ME~~~" |
49 # need this until a PR/version bump to fix galaxyxml prepending the exe even | 48 # need this until a PR/version bump to fix galaxyxml prepending the exe even |
50 # with override. | 49 # with override. |
51 | 50 |
52 | 51 |
214 for c in clp: | 213 for c in clp: |
215 aCL(c) | 214 aCL(c) |
216 aXCL(c) | 215 aXCL(c) |
217 | 216 |
218 def clsimple(self): | 217 def clsimple(self): |
219 """no parameters - uses < and > for i/o""" | 218 """no parameters or repeats - uses < and > for i/o""" |
220 aCL = self.cl.append | 219 aCL = self.cl.append |
221 aXCL = self.xmlcl.append | 220 aXCL = self.xmlcl.append |
222 if len(self.infiles) > 0: | 221 if len(self.infiles) > 0: |
223 aCL("<") | 222 aCL("<") |
224 aCL(self.infiles[0]["infilename"]) | 223 aCL(self.infiles[0]["infilename"]) |
256 self.lastxclredirect = [">", "$%s" % p["name"]] | 255 self.lastxclredirect = [">", "$%s" % p["name"]] |
257 else: | 256 else: |
258 clsuffix.append([p["name"], p["name"], ""]) | 257 clsuffix.append([p["name"], p["name"], ""]) |
259 xclsuffix.append([p["name"], "$%s" % p["name"], ""]) | 258 xclsuffix.append([p["name"], "$%s" % p["name"], ""]) |
260 for p in self.addpar: | 259 for p in self.addpar: |
261 clsuffix.append([p["CL"], p["name"], p["override"]]) | 260 nam = p["name"] |
262 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) | 261 rep = p["repeat"] == "1" |
262 if rep: | |
263 over = f" #for $rep in $R_{nam}:\n--{nam} $rep.{nam}\n#end for" | |
264 else: | |
265 over = p["override"] | |
266 clsuffix.append([p["CL"], nam, over]) | |
267 xclsuffix.append([p["CL"], nam, over]) | |
263 for p in self.selpar: | 268 for p in self.selpar: |
264 clsuffix.append([p["CL"], p["name"], p["override"]]) | 269 clsuffix.append([p["CL"], p["name"], p["override"]]) |
265 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) | 270 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) |
266 clsuffix.sort() | |
267 xclsuffix.sort() | |
268 self.xclsuffix = xclsuffix | 271 self.xclsuffix = xclsuffix |
269 self.clsuffix = clsuffix | 272 self.clsuffix = clsuffix |
270 | 273 |
271 def prepclpos(self): | 274 def prepclpos(self): |
272 clsuffix = [] | 275 clsuffix = [] |
294 self.lastxclredirect = [">", "$%s" % p["name"]] | 297 self.lastxclredirect = [">", "$%s" % p["name"]] |
295 else: | 298 else: |
296 clsuffix.append([p["CL"], p["name"], ""]) | 299 clsuffix.append([p["CL"], p["name"], ""]) |
297 xclsuffix.append([p["CL"], "$%s" % p["name"], ""]) | 300 xclsuffix.append([p["CL"], "$%s" % p["name"], ""]) |
298 for p in self.addpar: | 301 for p in self.addpar: |
299 clsuffix.append([p["CL"], p["name"], p["override"]]) | 302 nam = p["name"] |
300 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) | 303 rep = p["repeat"] == "1" # repeats make NO sense |
304 if rep: | |
305 print(f'### warning. Repeats for {nam} ignored - not permitted in positional parameter command lines!') | |
306 over = p["override"] | |
307 clsuffix.append([p["CL"], nam, over]) | |
308 xclsuffix.append([p["CL"], nam, over]) | |
301 for p in self.selpar: | 309 for p in self.selpar: |
302 clsuffix.append([p["CL"], p["name"], p["override"]]) | 310 clsuffix.append([p["CL"], p["name"], p["override"]]) |
303 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) | 311 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]]) |
304 clsuffix.sort() | 312 clsuffix.sort() |
305 xclsuffix.sort() | 313 xclsuffix.sort() |
386 # inputs then params in argparse named form | 394 # inputs then params in argparse named form |
387 | 395 |
388 for (k, v, koverride) in self.xclsuffix: | 396 for (k, v, koverride) in self.xclsuffix: |
389 if koverride > "": | 397 if koverride > "": |
390 k = koverride | 398 k = koverride |
391 elif len(k.strip()) == 1: | 399 aXCL(k) |
392 k = "-%s" % k | 400 else: |
393 else: | 401 if len(k.strip()) == 1: |
394 k = "--%s" % k | 402 k = "-%s" % k |
395 aXCL(k) | 403 else: |
396 aXCL(v) | 404 k = "--%s" % k |
405 aXCL(k) | |
406 aXCL(v) | |
397 for (k, v, koverride) in self.clsuffix: | 407 for (k, v, koverride) in self.clsuffix: |
398 if koverride > "": | 408 if koverride > "": |
399 k = koverride | 409 k = koverride |
400 elif len(k.strip()) == 1: | 410 elif len(k.strip()) == 1: |
401 k = "-%s" % k | 411 k = "-%s" % k |
478 self.testparam.append(tp) | 488 self.testparam.append(tp) |
479 for p in self.infiles: | 489 for p in self.infiles: |
480 newname = p["infilename"] | 490 newname = p["infilename"] |
481 newfmt = p["format"] | 491 newfmt = p["format"] |
482 ndash = self.getNdash(newname) | 492 ndash = self.getNdash(newname) |
493 reps = p.get("repeat",0) == 1 | |
483 if not len(p["label"]) > 0: | 494 if not len(p["label"]) > 0: |
484 alab = p["CL"] | 495 alab = p["CL"] |
485 else: | 496 else: |
486 alab = p["label"] | 497 alab = p["label"] |
487 aninput = gxtp.DataParam( | 498 aninput = gxtp.DataParam( |
499 aninput.positional = 9999998 | 510 aninput.positional = 9999998 |
500 aninput.command_line_override = "> $%s" % newname | 511 aninput.command_line_override = "> $%s" % newname |
501 else: | 512 else: |
502 aninput.positional = int(p["origCL"]) | 513 aninput.positional = int(p["origCL"]) |
503 aninput.command_line_override = "$%s" % newname | 514 aninput.command_line_override = "$%s" % newname |
504 self.tinputs.append(aninput) | 515 if reps: |
505 tparm = gxtp.TestParam(name=newname, value="%s_sample" % newname) | 516 repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {newlabel} as needed") |
506 self.testparam.append(tparm) | 517 repe.append(aninput) |
518 self.tinputs.append(repe) | |
519 tparm = gxtp.TestRepeat(name=f"R_{newname}") | |
520 tparm2 = gxtp.TestParam(newname, value="%s_sample" % newname) | |
521 tparm.append(tparm2) | |
522 self.testparam.append(tparm) | |
523 else: | |
524 self.tinputs.append(aninput) | |
525 tparm = gxtp.TestParam(newname, value="%s_sample" % newname) | |
526 self.testparam.append(tparm) | |
507 for p in self.addpar: | 527 for p in self.addpar: |
508 newname = p["name"] | 528 newname = p["name"] |
509 newval = p["value"] | 529 newval = p["value"] |
510 newlabel = p["label"] | 530 newlabel = p["label"] |
511 newhelp = p["help"] | 531 newhelp = p["help"] |
512 newtype = p["type"] | 532 newtype = p["type"] |
513 newcl = p["CL"] | 533 newcl = p["CL"] |
514 oldcl = p["origCL"] | 534 oldcl = p["origCL"] |
535 reps = p["repeat"] == "1" | |
515 if not len(newlabel) > 0: | 536 if not len(newlabel) > 0: |
516 newlabel = newname | 537 newlabel = newname |
517 ndash = self.getNdash(newname) | 538 ndash = self.getNdash(newname) |
518 if newtype == "text": | 539 if newtype == "text": |
519 aparm = gxtp.TextParam( | 540 aparm = gxtp.TextParam( |
554 % (newtype, newname) | 575 % (newtype, newname) |
555 ) | 576 ) |
556 aparm.positional = self.is_positional | 577 aparm.positional = self.is_positional |
557 if self.is_positional: | 578 if self.is_positional: |
558 aparm.positional = int(oldcl) | 579 aparm.positional = int(oldcl) |
559 self.tinputs.append(aparm) | 580 if reps: |
560 tparm = gxtp.TestParam(newname, value=newval) | 581 repe = gxtp.Repeat(name=f"R_{newname}", title=f"Add as many {newlabel} as needed") |
561 self.testparam.append(tparm) | 582 repe.append(aparm) |
583 self.tinputs.append(repe) | |
584 tparm = gxtp.TestRepeat(name=f"R_{newname}") | |
585 tparm2 = gxtp.TestParam(newname, value=newval) | |
586 tparm.append(tparm2) | |
587 self.testparam.append(tparm) | |
588 else: | |
589 self.tinputs.append(aparm) | |
590 tparm = gxtp.TestParam(newname, value=newval) | |
591 self.testparam.append(tparm) | |
562 for p in self.selpar: | 592 for p in self.selpar: |
563 newname = p["name"] | 593 newname = p["name"] |
564 newval = p["value"] | 594 newval = p["value"] |
565 newlabel = p["label"] | 595 newlabel = p["label"] |
566 newhelp = p["help"] | 596 newhelp = p["help"] |
604 disc = gxtp.DiscoverDatasets( | 634 disc = gxtp.DiscoverDatasets( |
605 pattern=newdisc, directory=f"{newname}", visible="false" | 635 pattern=newdisc, directory=f"{newname}", visible="false" |
606 ) | 636 ) |
607 collect.append(disc) | 637 collect.append(disc) |
608 self.toutputs.append(collect) | 638 self.toutputs.append(collect) |
609 tparm = gxtp.TestOutputCollection(newname) | 639 try: |
610 self.testparam.append(tparm) | 640 tparm = gxtp.TestOutputCollection(newname) # broken until PR merged. |
641 self.testparam.append(tparm) | |
642 except Exception: | |
643 print("#### WARNING: Galaxyxml version does not have the PR merged yet - tests for collections must be over-ridden until then!") | |
611 | 644 |
612 def doNoXMLparam(self): | 645 def doNoXMLparam(self): |
613 """filter style package - stdin to stdout""" | 646 """filter style package - stdin to stdout""" |
614 if len(self.infiles) > 0: | 647 if len(self.infiles) > 0: |
615 alab = self.infiles[0]["label"] | 648 alab = self.infiles[0]["label"] |