Mercurial > repos > fubar > rglasso_1_9_8
comparison rgToolFactory.py @ 7:ef0297b352d8 draft
Uploaded
| author | fubar | 
|---|---|
| date | Fri, 19 Dec 2014 18:22:38 -0500 | 
| parents | 42637d352d09 | 
| children | 4b62ea84c318 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 6:42637d352d09 | 7:ef0297b352d8 | 
|---|---|
| 151 artifact.close() | 151 artifact.close() | 
| 152 self.cl = [] | 152 self.cl = [] | 
| 153 self.html = [] | 153 self.html = [] | 
| 154 a = self.cl.append | 154 a = self.cl.append | 
| 155 a(opts.interpreter) | 155 a(opts.interpreter) | 
| 156 if self.treatbashSpecial and opts.interpreter in ['bash','sh']: | 156 # cannot use pipe input on test - change so always eg Rscript myscript.R | 
| 157 a(self.sfile) | 157 #if self.treatbashSpecial and opts.interpreter in ['bash','sh']: | 
| 158 else: | 158 # a(self.sfile) | 
| 159 a('-') # stdin | 159 #else: | 
| 160 a(opts.input_tab) | 160 # a('-') # stdin | 
| 161 a(opts.output_tab) | 161 #a(opts.input_tab) | 
| 162 #a(opts.output_tab) | |
| 163 a(self.sfile) | |
| 162 self.outFormats = 'tabular' # TODO make this an option at tool generation time | 164 self.outFormats = 'tabular' # TODO make this an option at tool generation time | 
| 163 self.inputFormats = 'tabular' # TODO make this an option at tool generation time | 165 self.inputFormats = 'tabular' # TODO make this an option at tool generation time | 
| 164 self.test1Input = '%s_test1_input.xls' % self.toolname | 166 self.test1Input = '%s_test1_input.xls' % self.toolname | 
| 165 self.test1Output = '%s_test1_output.xls' % self.toolname | 167 self.test1Output = '%s_test1_output.xls' % self.toolname | 
| 166 self.test1HTML = '%s_test1_output.html' % self.toolname | 168 self.test1HTML = '%s_test1_output.html' % self.toolname | 
| 536 htmlf.write('\n'.join(html)) | 538 htmlf.write('\n'.join(html)) | 
| 537 htmlf.write('\n') | 539 htmlf.write('\n') | 
| 538 htmlf.close() | 540 htmlf.close() | 
| 539 self.html = html | 541 self.html = html | 
| 540 | 542 | 
| 541 | |
| 542 def run(self): | 543 def run(self): | 
| 543 """ | 544 """ | 
| 544 scripts must be small enough not to fill the pipe! | 545 scripts must be small enough not to fill the pipe! | 
| 545 """ | 546 """ | 
| 546 my_env = os.environ.copy() | 547 my_env = os.environ.copy() | 
| 547 if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']: | 548 if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']: | 
| 548 retval = self.runBash(pth) | 549 retval = self.runBash() | 
| 550 else: | |
| 551 if self.opts.output_dir: | |
| 552 ste = open(self.elog,'w') | |
| 553 sto = open(self.tlog,'w') | |
| 554 sto.write('## Toolfactory running %s as %s script\n' % (self.toolname,self.opts.interpreter)) | |
| 555 sto.flush() | |
| 556 p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=ste,cwd=self.opts.output_dir,env=my_env) | |
| 557 else: | |
| 558 p = subprocess.Popen(self.cl,shell=False,cwd=self.opts.output_dir,env=my_env) | |
| 559 # p.stdin.write(self.script) | |
| 560 #print >> p.stdin, self.script | |
| 561 #p.stdin.close() | |
| 562 retval = p.wait() | |
| 563 if self.opts.output_dir: | |
| 564 sto.close() | |
| 565 ste.close() | |
| 566 # get stderr, allowing for case where it's very large | |
| 567 tmp_stderr = open( self.elog, 'rb' ) | |
| 568 stderr = '' | |
| 569 try: | |
| 570 while True: | |
| 571 stderr += tmp_stderr.read( buffsize ) | |
| 572 if not stderr or len( stderr ) % buffsize != 0: | |
| 573 break | |
| 574 except OverflowError: | |
| 575 pass | |
| 576 tmp_stderr.close() | |
| 577 if self.opts.make_HTML: | |
| 578 self.makeHtml() | |
| 579 return retval | |
| 580 | |
| 581 def old_run(self): | |
| 582 """ | |
| 583 can't use pipe as stdin on test. go figure | |
| 584 scripts must be small enough not to fill the pipe! | |
| 585 """ | |
| 586 my_env = os.environ.copy() | |
| 587 if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']: | |
| 588 retval = self.runBash() | |
| 549 else: | 589 else: | 
| 550 if self.opts.output_dir: | 590 if self.opts.output_dir: | 
| 551 ste = open(self.elog,'w') | 591 ste = open(self.elog,'w') | 
| 552 sto = open(self.tlog,'w') | 592 sto = open(self.tlog,'w') | 
| 553 sto.write('## Toolfactory running %s as %s script\n' % (self.toolname,self.opts.interpreter)) | 593 sto.write('## Toolfactory running %s as %s script\n' % (self.toolname,self.opts.interpreter)) | 
