comparison rgToolFactory.py @ 17:903e3748f735 draft

removed dependencies
author fubar
date Sun, 23 Mar 2014 07:12:47 -0400
parents 824d21b5c773
children a986c9f88d38
comparison
equal deleted inserted replaced
16:e052aadae3e9 17:903e3748f735
155 self.myname = sys.argv[0] # get our name because we write ourselves out as a tool later 155 self.myname = sys.argv[0] # get our name because we write ourselves out as a tool later
156 self.pyfile = self.myname # crude but efficient - the cruft won't hurt muchself.tooldepfile) 156 self.pyfile = self.myname # crude but efficient - the cruft won't hurt muchself.tooldepfile)
157 self.xmlfile = '%s.xml' % self.toolname 157 self.xmlfile = '%s.xml' % self.toolname
158 s = open(self.opts.script_path,'r').readlines() 158 s = open(self.opts.script_path,'r').readlines()
159 s = [x.rstrip() for x in s] # remove pesky dos line endings if needed 159 s = [x.rstrip() for x in s] # remove pesky dos line endings if needed
160 s = [x.lstrip() for x in s] # and left padding
160 self.script = '\n'.join(s) 161 self.script = '\n'.join(s)
161 fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname,suffix=".%s" % (opts.interpreter)) 162 fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname,suffix=".%s" % (opts.interpreter))
162 tscript = open(self.sfile,'w') # use self.sfile as script source for Popen 163 tscript = open(self.sfile,'w') # use self.sfile as script source for Popen
163 tscript.write(self.script) 164 tscript.write(self.script)
164 tscript.close() 165 tscript.close()
252 %(script)s 253 %(script)s
253 </configfile> 254 </configfile>
254 </configfiles> 255 </configfiles>
255 %(tooltests)s 256 %(tooltests)s
256 <help> 257 <help>
258
257 %(help)s 259 %(help)s
260
258 </help> 261 </help>
259 </tool>""" # needs a dict with toolname, toolid, interpreter, scriptname, command, inputs as a multi line string ready to write, outputs ditto, help ditto 262 </tool>""" # needs a dict with toolname, toolid, interpreter, scriptname, command, inputs as a multi line string ready to write, outputs ditto, help ditto
260 263
261 newCommand="""<command interpreter="python"> 264 newCommand="""<command interpreter="python">
262 %(toolname)s.py --script_path "$runMe" --interpreter "%(interpreter)s" 265 %(toolname)s.py --script_path "$runMe" --interpreter "%(interpreter)s"
298 xdict['script'] = self.escapedScript 301 xdict['script'] = self.escapedScript
299 # configfile is least painful way to embed script to avoid external dependencies 302 # configfile is least painful way to embed script to avoid external dependencies
300 # but requires escaping of <, > and $ to avoid Mako parsing 303 # but requires escaping of <, > and $ to avoid Mako parsing
301 if self.opts.help_text: 304 if self.opts.help_text:
302 xdict['help'] = open(self.opts.help_text,'r').read() 305 xdict['help'] = open(self.opts.help_text,'r').read()
303 else: 306 xdict['help'] = '\n'.join([x.lstrip(x) for x in xdict['help']])
304 xdict['help'] = 'Please ask the tool author for help as none was supplied at tool generation' 307 else:
308 xdict['help'] = 'Please ask the tool author for help as none was supplied at tool generation\n'
305 coda = ['**Script**','Pressing execute will run the following code over your input file and generate some outputs in your history::'] 309 coda = ['**Script**','Pressing execute will run the following code over your input file and generate some outputs in your history::']
306 coda.append(self.indentedScript) 310 coda.append(self.indentedScript)
307 coda.append('**Attribution** This Galaxy tool was created by %s at %s\nusing the Galaxy Tool Factory.' % (self.opts.user_email,timenow())) 311 coda.append('**Attribution** This Galaxy tool was created by %s at %s\nusing the Galaxy Tool Factory.' % (self.opts.user_email,timenow()))
308 coda.append('See %s for details of that project' % (toolFactoryURL)) 312 coda.append('See %s for details of that project' % (toolFactoryURL))
309 coda.append('Please cite: Creating re-usable tools from scripts: The Galaxy Tool Factory. Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team. ') 313 coda.append('Please cite: Creating re-usable tools from scripts: The Galaxy Tool Factory. Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team. ')