# HG changeset patch # User fubar # Date 1421029935 18000 # Node ID 6a3c292412fa54c86deadda929767c0ce594c906 # Parent 323982517b308bfe159ccb5e6fafdbb8a6311f4e Uploaded diff -r 323982517b30 -r 6a3c292412fa rgToolFactory2.py --- a/rgToolFactory2.py Sat Jan 10 19:39:33 2015 -0500 +++ b/rgToolFactory2.py Sun Jan 11 21:32:15 2015 -0500 @@ -121,7 +121,7 @@ """ -toolhtmldepskel = """ +emptytoolhtmldepskel = """ %s @@ -230,48 +230,56 @@ self.test1Inputs = '' # we always pass path,name pairs in using python optparse append # but the command line has to be different - self.infile_paths = ','.join([x.split(',')[0] for x in self.opts.input_tab]) - self.infile_names = ','.join([x.split(',')[1] for x in self.opts.input_tab]) + self.infile_paths = '' + self.infile_names = '' + if self.opts.input_tab: + self.infile_paths = ','.join([x.split(',')[0].strip() for x in self.opts.input_tab]) + self.infile_names = ','.join([x.split(',')[1].strip() for x in self.opts.input_tab]) if self.opts.interpreter == 'python': # yes, this is how additional parameters are always passed in python - to the TF itself and to # scripts to avoid having unknown parameter names (yes, they can be parsed but...) on the command line - a('--INPATHS "%s"' % (self.infile_paths)) - a('--INNAMES "%s"' % (self.infile_names)) + if self.opts.input_tab: + a('--INPATHS "%s"' % (self.infile_paths)) + a('--INNAMES "%s"' % (self.infile_names)) if self.opts.output_tab: a('--OUTPATH "%s"' % self.opts.output_tab) for p in opts.additional_parameters: p = p.replace('"','') - psplit=p.split(',') - param = psplit[0] - value = psplit[1] - a('--additional_parameters "%s,%s"' % (param,value)) + ps = p.split(',') + a('%s="%s"' % (ps[0],ps[1])) if (self.opts.interpreter == 'Rscript'): # pass params on command line - a('INPATHS "%s"' % self.infile_paths) - a('INNAMES "%s"' % self.infile_names) + if self.opts.input_tab: + a('INPATHS="%s"' % self.infile_paths) + a('INNAMES="%s"' % self.infile_names) if self.opts.output_tab: - a('OUTPATH "%s"' % self.opts.output_tab) - for param in opts.additional_parameters: - param, value=param.split(',') - a('%s="%s"' % (param,value)) + a('OUTPATH="%s"' % self.opts.output_tab) + for p in opts.additional_parameters: + p = p.replace('"','') + ps = p.split(',') + a('%s="%s"' % (ps[0],ps[1])) if (self.opts.interpreter == 'perl'): # pass params on command line - a('%s' % self.infile_paths) - a('%s' % self.infile_names) + if self.opts.input_tab: + a('%s' % self.infile_paths) + a('%s' % self.infile_names) if self.opts.output_tab: a('%s' % self.opts.output_tab) - for param in opts.additional_parameters: - param, value=param.split(',') + for p in opts.additional_parameters: + p = p.replace('"','') + ps = p.split(',') + param = ps[0] + value = ps[1] if (value.find(' ') <> -1): a('%s="%s"' % (param,value)) else: a('%s=%s' % (param,value)) - if self.opts.interpreter == 'sh' or self.opts.interpreter == 'bash': # more is better - now move all params into environment AND drop on to command line. self.cl.insert(0,'env') - self.cl.insert(1,'INPATHS=%s' % (self.infile_paths)) - self.cl.insert(2,'INNAMES=%s' % (self.infile_names)) + if self.opts.input_tab: + self.cl.insert(1,'INPATHS=%s' % (self.infile_paths)) + self.cl.insert(2,'INNAMES=%s' % (self.infile_names)) if self.opts.output_tab: self.cl.insert(3,'OUTPATH=%s' % (self.opts.output_tab)) a('OUTPATH=%s' % (self.opts.output_tab)) @@ -415,9 +423,9 @@ xdict['additionalInputs'] = '' if self.opts.additional_parameters: if self.opts.edit_additional_parameters: # add to new tool form with default value set to original value - xdict['additionalInputs'] = '\n'.join(['' % (x.split(',')[0],x.split(',')[1],x.split(',')[2], - x.split(',')[3], x.split(',')[4]) for x in self.opts.additional_parameters]) - xdict['additionalParams'] = '\n'.join(['' % (x.split(',')[0],x.split(',')[1]) for x in self.opts.additional_parameters]) + xdict['additionalInputs'] = '\n'.join(['' % (x.split(',')[0],html_escape(x.split(',')[1]),html_escape(x.split(',')[2]), + html_escape(x.split(',')[3]), x.split(',')[4]) for x in self.opts.additional_parameters]) + xdict['additionalParams'] = '\n'.join(['' % (x.split(',')[0],html_escape(x.split(',')[1])) for x in self.opts.additional_parameters]) xdict['requirements'] = '' if self.opts.make_HTML: if self.opts.include_dependencies == "yes": @@ -455,10 +463,11 @@ xdict['tooldesc'] = '' xdict['command_outputs'] = '' xdict['outputs'] = '' - if self.opts.input_tab <> 'None': + if self.opts.input_tab: cins = ['\n',] + cins.append('--input_formats %s' % self.opts.input_formats) cins.append('#for intab in $input1:') - cins.append('--input_tab "$intab,$intab.name"') + cins.append('--input_tab "${intab},${intab.name}"') cins.append('#end for\n') xdict['command_inputs'] = '\n'.join(cins) xdict['inputs'] = ''' 0): cins = ['\n',] for params in self.opts.additional_parameters: - if self.opts.edit_additional_parameters: psplit = params.split(',') # name,value... - psplit[1] = '$%s' % psplit[0] # replace with form value - cins.append('--additional_parameters "%s"' % ','.join(psplit)) - else: - cins.append('--additional_parameters "%s"' % params) + psplit[3] = html_escape(psplit[3]) + if self.opts.edit_additional_parameters: + psplit[1] = '$%s' % psplit[0] # replace with form value + else: + psplit[1] = html_escape(psplit[1]) # leave prespecified value + cins.append('--additional_parameters """%s"""' % ','.join(psplit)) xdict['command_inputs'] = '%s\n%s' % (xdict['command_inputs'],'\n'.join(cins)) xdict['inputs'] += ' \n' % self.toolname xdict['toolname'] = self.toolname @@ -520,20 +530,19 @@ tdir = self.toolname os.mkdir(tdir) self.makeXML() - if self.opts.make_HTML: - if self.opts.help_text: - hlp = open(self.opts.help_text,'r').read() - else: - hlp = 'Please ask the tool author for help as none was supplied at tool generation\n' - if self.opts.include_dependencies == "yes": - tooldepcontent = toolhtmldepskel % hlp - else: - tooldepcontent = emptytoolhtmldepskel % hlp - depf = open(os.path.join(tdir,'tool_dependencies.xml'),'w') - depf.write(tooldepcontent) - depf.write('\n') - depf.close() - if self.opts.input_tab <> 'None': # no reproducible test otherwise? TODO: maybe.. + if self.opts.help_text: + hlp = open(self.opts.help_text,'r').read() + else: + hlp = 'Please ask the tool author for help as none was supplied at tool generation\n' + if self.opts.include_dependencies == "yes": + tooldepcontent = toolhtmldepskel % hlp + else: + tooldepcontent = emptytoolhtmldepskel % hlp + depf = open(os.path.join(tdir,'tool_dependencies.xml'),'w') + depf.write(tooldepcontent) + depf.write('\n') + depf.close() + if self.opts.input_tab: # no reproducible test otherwise? TODO: maybe.. testdir = os.path.join(tdir,'test-data') os.mkdir(testdir) # make tests directory for i,intab in enumerate(self.opts.input_tab): @@ -544,7 +553,7 @@ dest = os.path.join(testdir,os.path.basename(si)) if si <> dest: shutil.copyfile(si,dest) - if self.opts.output_tab <> None: + if self.opts.output_tab: shutil.copyfile(self.opts.output_tab,os.path.join(testdir,self.test1Output)) if self.opts.make_HTML: shutil.copyfile(self.opts.output_html,os.path.join(testdir,self.test1HTML)) diff -r 323982517b30 -r 6a3c292412fa rgToolFactory2.xml --- a/rgToolFactory2.xml Sat Jan 10 19:39:33 2015 -0500 +++ b/rgToolFactory2.xml Sun Jan 11 21:32:15 2015 -0500 @@ -40,10 +40,12 @@ #else: --output_dir "." #end if - #if $input_tab != 'None': + #if len($input_tab) != 0: --input_formats "$input_formats" - #for intab in $input_tab: - --input_tab "$intab,$intab.name" + #for $intab in $input_tab: + #if $intab.ext != 'data': + --input_tab "${intab},${intab.name}" + #end if #end for #end if #end if @@ -153,34 +155,34 @@ - + - - + - - + + - - + + - + @@ -394,7 +396,6 @@ ]]> -**Citation** Paper_ : @@ -403,7 +404,6 @@ Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573 - **Licensing** Copyright Ross Lazarus (ross period lazarus at gmail period com) May 2012 @@ -417,7 +417,9 @@ - + + doi: 10.1093/bioinformatics/bts573 +