comparison toolfactory/rgToolFactory2.py @ 46:f8700bed1e17 draft

Uploaded
author fubar
date Tue, 18 Aug 2020 08:25:43 -0400
parents e7e9732ebed6
children
comparison
equal deleted inserted replaced
45:668c37cc8962 46:f8700bed1e17
171 self.tinputs = gxtp.Inputs() 171 self.tinputs = gxtp.Inputs()
172 self.toutputs = gxtp.Outputs() 172 self.toutputs = gxtp.Outputs()
173 self.testparam = [] 173 self.testparam = []
174 if ( 174 if (
175 self.args.runmode == "Executable" or self.args.runmode == "system" 175 self.args.runmode == "Executable" or self.args.runmode == "system"
176 ): # binary - no need 176 ):
177 aCL(self.args.exe_package) # this little CL will just run 177 if len(self.args.cl_override) > 0:
178 for x in self.args.cl_override.split(' '):
179 aCL(x)
180 else:
181 aCL(self.args.exe_package) # this little CL will just run
178 else: 182 else:
179 self.prepScript() 183 self.prepScript()
184 aCL(self.args.interpreter_name)
185 aCL(self.sfile)
186
180 self.elog = "%s_error_log.txt" % self.tool_name 187 self.elog = "%s_error_log.txt" % self.tool_name
181 self.tlog = "%s_runner_log.txt" % self.tool_name 188 self.tlog = "%s_runner_log.txt" % self.tool_name
182 189
183 if self.args.parampass == "0": 190 if self.args.parampass == "0":
184 self.clsimple() 191 self.clsimple()
229 self.clpositional() 236 self.clpositional()
230 else: 237 else:
231 self.clargparse() 238 self.clargparse()
232 239
233 def prepScript(self): 240 def prepScript(self):
234 aCL = self.cl.append
235 rx = open(self.args.script_path, "r").readlines() 241 rx = open(self.args.script_path, "r").readlines()
236 rx = [x.rstrip() for x in rx] 242 rx = [x.rstrip() for x in rx]
237 rxcheck = [x.strip() for x in rx if x.strip() > ""] 243 rxcheck = [x.strip() for x in rx if x.strip() > ""]
238 assert len(rxcheck) > 0, "Supplied script is empty. Cannot run" 244 assert len(rxcheck) > 0, "Supplied script is empty. Cannot run"
239 self.script = "\n".join(rx) 245 self.script = "\n".join(rx)
253 artifact = open(art, "wb") 259 artifact = open(art, "wb")
254 if self.args.interpreter_name == "python": 260 if self.args.interpreter_name == "python":
255 artifact.write(bytes("#!/usr/bin/env python\n", "utf8")) 261 artifact.write(bytes("#!/usr/bin/env python\n", "utf8"))
256 artifact.write(bytes(self.script, "utf8")) 262 artifact.write(bytes(self.script, "utf8"))
257 artifact.close() 263 artifact.close()
258 aCL(self.args.interpreter_name) 264
259 aCL(self.sfile) 265
260 266
261 def cleanuppar(self): 267 def cleanuppar(self):
262 """ positional parameters are complicated by their numeric ordinal""" 268 """ positional parameters are complicated by their numeric ordinal"""
263 for i, p in enumerate(self.infiles): 269 for i, p in enumerate(self.infiles):
264 if self.args.parampass == "positional": 270 if self.args.parampass == "positional":
265 assert p[ICLPOS].isdigit(), ( 271 assert p[ICLPOS].isdigit(), (
480 """ 486 """
481 Create a Galaxy xml tool wrapper for the new script 487 Create a Galaxy xml tool wrapper for the new script
482 Uses galaxyhtml 488 Uses galaxyhtml
483 Hmmm. How to get the command line into correct order... 489 Hmmm. How to get the command line into correct order...
484 """ 490 """
485 self.tool.command_line_override = self.xmlcl 491 if self.args.cl_override:
492 self.tool.command_line_override = self.args.cl_override.split(' ') + self.xmlcl
493 else:
494 self.tool.command_line_override = self.xmlcl
486 if self.args.interpreter_name: 495 if self.args.interpreter_name:
487 self.tool.interpreter = self.args.interpreter_name 496 self.tool.interpreter = self.args.interpreter_name
488 if self.args.help_text: 497 if self.args.help_text:
489 helptext = open(self.args.help_text, "r").readlines() 498 helptext = open(self.args.help_text, "r").readlines()
490 helptext = [html_escape(x) for x in helptext] 499 helptext = [html_escape(x) for x in helptext]
497 ) 506 )
498 self.tool.version_command = None # do not want 507 self.tool.version_command = None # do not want
499 requirements = gxtp.Requirements() 508 requirements = gxtp.Requirements()
500 509
501 if self.args.interpreter_name: 510 if self.args.interpreter_name:
511 if self.args.dependencies:
512 for d in self.args.dependencies.split(','):
513 requirements.append(
514 gxtp.Requirement(
515 "package", d, ""
516 )
517 )
502 if self.args.interpreter_name == "python": 518 if self.args.interpreter_name == "python":
503 requirements.append( 519 requirements.append(
504 gxtp.Requirement( 520 gxtp.Requirement(
505 "package", "python", self.args.interpreter_version 521 "package", "python", self.args.interpreter_version
506 ) 522 )
689 </command> 705 </command>
690 """ 706 """
691 parser = argparse.ArgumentParser() 707 parser = argparse.ArgumentParser()
692 a = parser.add_argument 708 a = parser.add_argument
693 a("--script_path", default="") 709 a("--script_path", default="")
710 a("--dependencies", default="")
711 a("--cl_override", default="")
694 a("--tool_name", default=None) 712 a("--tool_name", default=None)
695 a("--interpreter_name", default=None) 713 a("--interpreter_name", default=None)
696 a("--interpreter_version", default=None) 714 a("--interpreter_version", default=None)
697 a("--exe_package", default=None) 715 a("--exe_package", default=None)
698 a("--exe_package_version", default=None) 716 a("--exe_package_version", default=None)