Mercurial > repos > fubar > tool_factory_2
comparison rgToolFactory2.py @ 7:61381bad936d draft
Uploaded
author | fubar |
---|---|
date | Mon, 12 Jan 2015 05:01:29 -0500 |
parents | 81198714ac8e |
children | 9d58cc32a12d |
comparison
equal
deleted
inserted
replaced
6:81198714ac8e | 7:61381bad936d |
---|---|
143 "&": "&", | 143 "&": "&", |
144 ">": ">", | 144 ">": ">", |
145 "<": "<", | 145 "<": "<", |
146 "$": "\$" | 146 "$": "\$" |
147 } | 147 } |
148 | 148 html_unescape_table = dict(zip(html_escape_table.values(),html_escape_table.keys())) |
149 def html_escape(text): | 149 def html_escape(text): |
150 """Produce entities within text.""" | 150 """Produce entities within text.""" |
151 return "".join(html_escape_table.get(c,c) for c in text) | 151 return "".join(html_escape_table.get(c,c) for c in text) |
152 | 152 |
153 | |
154 def html_unescape(text): | |
155 """Revert entities within text.""" | |
156 return "".join(html_unescape_table.get(c,c) for c in text) | |
157 | |
153 def cmd_exists(cmd): | 158 def cmd_exists(cmd): |
154 return subprocess.call("type " + cmd, shell=True, | 159 return subprocess.call("type " + cmd, shell=True, |
155 stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0 | 160 stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0 |
156 | 161 |
157 def parse_citations(citations_text): | 162 def parse_citations(citations_text): |
243 a('--INNAMES "%s"' % (self.infile_names)) | 248 a('--INNAMES "%s"' % (self.infile_names)) |
244 if self.opts.output_tab: | 249 if self.opts.output_tab: |
245 a('--OUTPATH "%s"' % self.opts.output_tab) | 250 a('--OUTPATH "%s"' % self.opts.output_tab) |
246 for p in opts.additional_parameters: | 251 for p in opts.additional_parameters: |
247 p = p.replace('"','') | 252 p = p.replace('"','') |
248 ps = p.split(',') | 253 psplit = p.split(',') |
249 a('%s="%s"' % (ps[0],ps[1])) | 254 param = html_unescape(psplit[0]) |
255 value = html_unescape(psplit[1]) | |
256 a('%s="%s"' % (param,value)) | |
250 if (self.opts.interpreter == 'Rscript'): | 257 if (self.opts.interpreter == 'Rscript'): |
251 # pass params on command line | 258 # pass params on command line |
252 if self.opts.input_tab: | 259 if self.opts.input_tab: |
253 a('INPATHS="%s"' % self.infile_paths) | 260 a('INPATHS="%s"' % self.infile_paths) |
254 a('INNAMES="%s"' % self.infile_names) | 261 a('INNAMES="%s"' % self.infile_names) |
255 if self.opts.output_tab: | 262 if self.opts.output_tab: |
256 a('OUTPATH="%s"' % self.opts.output_tab) | 263 a('OUTPATH="%s"' % self.opts.output_tab) |
257 for p in opts.additional_parameters: | 264 for p in opts.additional_parameters: |
258 p = p.replace('"','') | 265 p = p.replace('"','') |
259 ps = p.split(',') | 266 psplit = p.split(',') |
260 a('%s="%s"' % (ps[0],ps[1])) | 267 param = html_unescape(psplit[0]) |
268 value = html_unescape(psplit[1]) | |
269 a('%s="%s"' % (param,value)) | |
261 if (self.opts.interpreter == 'perl'): | 270 if (self.opts.interpreter == 'perl'): |
262 # pass params on command line | 271 # pass params on command line |
263 if self.opts.input_tab: | 272 if self.opts.input_tab: |
264 a('%s' % self.infile_paths) | 273 a('%s' % self.infile_paths) |
265 a('%s' % self.infile_names) | 274 a('%s' % self.infile_names) |
266 if self.opts.output_tab: | 275 if self.opts.output_tab: |
267 a('%s' % self.opts.output_tab) | 276 a('%s' % self.opts.output_tab) |
268 for p in opts.additional_parameters: | 277 for p in opts.additional_parameters: |
269 p = p.replace('"','') | 278 p = p.replace('"','') |
270 ps = p.split(',') | 279 psplit = p.split(',') |
271 param = ps[0] | 280 param = html_unescape(psplit[0]) |
272 value = ps[1] | 281 value = html_unescape(psplit[1]) |
273 if (value.find(' ') <> -1): | 282 if (value.find(' ') <> -1): |
274 a('%s="%s"' % (param,value)) | 283 a('%s="%s"' % (param,value)) |
275 else: | 284 else: |
276 a('%s=%s' % (param,value)) | 285 a('%s=%s' % (param,value)) |
277 if self.opts.interpreter == 'sh' or self.opts.interpreter == 'bash': | 286 if self.opts.interpreter == 'sh' or self.opts.interpreter == 'bash': |
283 if self.opts.output_tab: | 292 if self.opts.output_tab: |
284 self.cl.insert(3,'OUTPATH=%s' % (self.opts.output_tab)) | 293 self.cl.insert(3,'OUTPATH=%s' % (self.opts.output_tab)) |
285 a('OUTPATH=%s' % (self.opts.output_tab)) | 294 a('OUTPATH=%s' % (self.opts.output_tab)) |
286 # sets those environment variables for the script | 295 # sets those environment variables for the script |
287 # additional params appear in CL - yes, it's confusing | 296 # additional params appear in CL - yes, it's confusing |
288 for i,param in enumerate(opts.additional_parameters): | 297 for i,p in enumerate(opts.additional_parameters): |
289 psplit = param.split(',') | 298 psplit = p.split(',') |
290 n = psplit[0] | 299 param = html_unescape(psplit[0]) |
291 v = psplit[1] | 300 value = html_unescape(psplit[1]) |
292 if (v.find(' ') <> -1): | 301 if (value.find(' ') <> -1): |
293 a('%s="%s"' % (n,v)) | 302 a('%s="%s"' % (param,value)) |
294 self.cl.insert(4+i,'%s="%s"' % (n,v)) | 303 self.cl.insert(4+i,'%s="%s"' % (param,value)) |
295 else: | 304 else: |
296 a('%s=%s' % (n,v)) | 305 a('%s=%s' % (param,value)) |
297 self.cl.insert(4+i,'%s=%s' % (n,v)) | 306 self.cl.insert(4+i,'%s=%s' % (param,value)) |
298 | 307 |
299 | 308 |
300 self.outFormats = opts.output_format | 309 self.outFormats = opts.output_format |
301 self.inputFormats = opts.input_formats | 310 self.inputFormats = opts.input_formats |
302 self.test1Output = '%s_test1_output.xls' % self.toolname | 311 self.test1Output = '%s_test1_output.xls' % self.toolname |