Mercurial > repos > galaxyp > maxquant
comparison mqparam.py @ 6:2133b0be850a draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
author | galaxyp |
---|---|
date | Wed, 06 May 2020 13:35:51 -0400 |
parents | dcd39bcc7481 |
children | d253b379322b |
comparison
equal
deleted
inserted
replaced
5:7f432d87c82c | 6:2133b0be850a |
---|---|
306 if node is None: | 306 if node is None: |
307 raise ValueError('Element {} not found in parameter file' | 307 raise ValueError('Element {} not found in parameter file' |
308 .format(key)) | 308 .format(key)) |
309 node.text = str(value) | 309 node.text = str(value) |
310 | 310 |
311 def set_list_param(self, key, values): | |
312 """Set a list parameter. | |
313 Args: | |
314 key: (string) XML tag of the parameter | |
315 values: the lit of values of the parameter XML node | |
316 Returns: | |
317 None | |
318 """ | |
319 node = self._root.find(key) | |
320 if node is None: | |
321 raise ValueError('Element {} not found in parameter file' | |
322 .format(key)) | |
323 node.clear() | |
324 node.tag = key | |
325 for e in values: | |
326 et_add_child(node, name='string', text=e) | |
327 | |
311 def _from_yaml(self, conf): | 328 def _from_yaml(self, conf): |
312 """Read a yaml config file. | 329 """Read a yaml config file. |
313 Args: | 330 Args: |
314 conf: (string) path to the yaml conf file | 331 conf: (string) path to the yaml conf file |
315 Returns: | 332 Returns: |
316 None | 333 None |
317 """ | 334 """ |
318 with open(conf) as f: | 335 with open(conf) as f: |
319 conf_dict = yaml.safe_load(f.read()) | 336 conf_dict = yaml.safe_load(f.read()) |
337 | |
320 paramGroups = conf_dict.pop('paramGroups') | 338 paramGroups = conf_dict.pop('paramGroups') |
321 self.add_infiles([pg.pop('files') for pg in paramGroups]) | 339 self.add_infiles([pg.pop('files') for pg in paramGroups]) |
322 for i, pg in enumerate(paramGroups): | 340 for i, pg in enumerate(paramGroups): |
323 silac = pg.pop('labelMods', False) | 341 silac = pg.pop('labelMods', False) |
324 if silac: | 342 if silac: |
337 if fastafiles: | 355 if fastafiles: |
338 self.add_fasta_files(fastafiles, parse_rules=conf_dict.pop('parseRules', {})) | 356 self.add_fasta_files(fastafiles, parse_rules=conf_dict.pop('parseRules', {})) |
339 else: | 357 else: |
340 raise Exception('No fasta files provided.') | 358 raise Exception('No fasta files provided.') |
341 for key in conf_dict: | 359 for key in conf_dict: |
342 self.set_simple_param(key, conf_dict[key]) | 360 if key in ['restrictMods']: |
361 self.set_list_param(key, conf_dict[key]) | |
362 else: | |
363 self.set_simple_param(key, conf_dict[key]) | |
343 | 364 |
344 def write(self, mqpar_out): | 365 def write(self, mqpar_out): |
345 """Write pretty formatted xml parameter file. | 366 """Write pretty formatted xml parameter file. |
346 Compose it from global parameters and parameter Groups. | 367 Compose it from global parameters and parameter Groups. |
347 """ | 368 """ |