Mercurial > repos > galaxyp > openms_mapstatistics
annotate fill_ctd.py @ 13:a3ae12b9217a draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
| author | galaxyp | 
|---|---|
| date | Thu, 27 Aug 2020 23:12:49 +0000 | 
| parents | |
| children | a26195928b17 | 
| rev | line source | 
|---|---|
| 13 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 1 import collections | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 2 import json | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 3 import operator | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 4 import os | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 5 import re | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 6 import subprocess | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 7 import sys | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 8 from functools import reduce # forward compatibility for Python 3 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 9 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 10 from CTDopts.CTDopts import ( | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 11 _Choices, | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 12 _InFile, | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 13 _Null, | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 14 _NumericRange, | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 15 CTDModel | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 16 ) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 17 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 18 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 19 def getFromDict(dataDict, mapList): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 20 return reduce(operator.getitem, mapList, dataDict) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 21 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 22 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 23 def setInDict(dataDict, mapList, value): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 24 getFromDict(dataDict, mapList[:-1])[mapList[-1]] = value | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 25 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 26 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 27 def mergeDicts(d, e): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 28 """ | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 29 insert values from the dict e into dict d | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 30 no values of d are overwritten | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 31 """ | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 32 for k, v in e.items(): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 33 if (k in d and isinstance(d[k], dict) and isinstance(e[k], collections.abc.Mapping)): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 34 mergeDicts(d[k], e[k]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 35 elif k not in d and not isinstance(e[k], collections.abc.Mapping): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 36 d[k] = e[k] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 37 else: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 38 sys.stderr.write("fill_ctd.py: could not merge key %s for %s in %s" % (k, d, e)) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 39 sys.exit(1) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 40 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 41 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 42 def _json_object_hook_noenvlookup(d): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 43 return _json_object_hook(d, envlookup=False) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 44 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 45 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 46 def _json_object_hook(d, envlookup=True): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 47 """ | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 48 wee helper to transform the json written by galaxy | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 49 while loading | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 50 - True/False (bool objects) -> "true"/"false" (lowercase string) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 51 - data inputs with multiple and optional true give [None] if no file is given -> [] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 52 - None -> "" (empty string) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 53 - replace bash expressions (if envlookup is True): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 54 - environment variables (need to consist capital letters and _) by their value | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 55 - expressions | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 56 """ | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 57 for k in d.keys(): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 58 # if type(d[k]) is bool: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 59 # d[k] = str(d[k]).lower() | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 60 # else | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 61 if type(d[k]) is list and len(d[k]) == 1 and d[k][0] is None: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 62 d[k] = [] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 63 elif d[k] is None: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 64 d[k] = "" | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 65 elif envlookup and type(d[k]) is str and d[k].startswith("$"): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 66 m = re.fullmatch(r"\$([A-Z_]+)", d[k]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 67 if m: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 68 d[k] = os.environ.get(m.group(1), "") | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 69 continue | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 70 m = re.fullmatch(r"\$(\{[A-Z_]+):-(.*)\}", d[k]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 71 if m: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 72 d[k] = os.environ.get(m.group(1), m.group(2)) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 73 continue | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 74 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 75 try: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 76 p = subprocess.run("echo %s" % d[k], shell=True, check=True, stdout=subprocess.PIPE, encoding="utf8") | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 77 d[k] = p.stdout.strip() | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 78 except subprocess.CalledProcessError: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 79 sys.stderr.write("fill_ctd error: Could not evaluate %s" % d[k]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 80 continue | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 81 return d | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 82 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 83 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 84 def qstring2list(qs): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 85 """ | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 86 transform a space separated string that is quoted by " into a list | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 87 """ | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 88 lst = list() | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 89 qs = qs.split(" ") | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 90 quoted = False | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 91 for p in qs: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 92 if p == "": | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 93 continue | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 94 if p.startswith('"') and p.endswith('"'): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 95 lst.append(p[1:-1]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 96 elif p.startswith('"'): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 97 quoted = True | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 98 lst.append(p[1:] + " ") | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 99 elif p.endswith('"'): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 100 quoted = False | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 101 lst[-1] += p[:-1] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 102 else: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 103 if quoted: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 104 lst[-1] += p + " " | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 105 else: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 106 lst.append(p) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 107 return lst | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 108 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 109 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 110 def fix_underscores(args): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 111 if type(args) is dict: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 112 for k in list(args.keys()): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 113 v = args[k] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 114 if type(v) is dict: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 115 fix_underscores(args[k]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 116 if k.startswith("_"): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 117 args[k[1:]] = v | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 118 del args[k] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 119 elif type(args) is list: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 120 for i, v in enumerate(args): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 121 if type(v) is dict: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 122 fix_underscores(args[i]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 123 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 124 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 125 input_ctd = sys.argv[1] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 126 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 127 # load user specified parameters from json | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 128 with open(sys.argv[2]) as fh: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 129 args = json.load(fh, object_hook=_json_object_hook_noenvlookup) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 130 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 131 # load hardcoded parameters from json | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 132 with open(sys.argv[3]) as fh: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 133 hc_args = json.load(fh, object_hook=_json_object_hook) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 134 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 135 # insert the hc_args into the args | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 136 mergeDicts(args, hc_args) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 137 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 138 if "adv_opts_cond" in args: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 139 args.update(args["adv_opts_cond"]) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 140 del args["adv_opts_cond"] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 141 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 142 # IDMapper has in and spectra:in params, in is used in out as format_source", | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 143 # which does not work in Galaxy: https://github.com/galaxyproject/galaxy/pull/9493" | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 144 # therefore hardcoded params change the name of spectra:in to spectra:_in | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 145 # which is corrected here again | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 146 # TODO remove once PR is in and adapt profile accordingly | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 147 fix_underscores(args) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 148 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 149 model = CTDModel(from_file=input_ctd) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 150 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 151 # transform values from json that correspond to | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 152 # - old style booleans (string + restrictions) -> transformed to a str | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 153 # - unrestricted ITEMLIST which are represented as strings | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 154 # ("=quoted and space separated) in Galaxy -> transform to lists | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 155 # - optional data input parameters that have defaults and for which no | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 156 # value is given -> overwritte with the default | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 157 for p in model.get_parameters(): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 158 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 159 # check if the parameter is in the arguments from the galaxy tool | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 160 # (from the json file(s)), since advanced parameters are absent | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 161 # if the conditional is set to basic parameters | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 162 try: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 163 getFromDict(args, p.get_lineage(name_only=True)) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 164 except KeyError: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 165 # few tools use dashes in parameters which are automatically replaced | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 166 # by underscores by Galaxy. in these cases the dictionary needs to be | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 167 # updated | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 168 # TODO might be removed later https://github.com/OpenMS/OpenMS/pull/4529 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 169 try: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 170 lineage = [_.replace("-", "_") for _ in p.get_lineage(name_only=True)] | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 171 val = getFromDict(args, lineage) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 172 except KeyError: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 173 continue | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 174 else: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 175 setInDict(args, lineage, val) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 176 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 177 if p.type is str and type(p.restrictions) is _Choices and set(p.restrictions.choices) == set(["true", "false"]): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 178 v = getFromDict(args, p.get_lineage(name_only=True)) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 179 setInDict(args, p.get_lineage(name_only=True), str(v).lower()) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 180 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 181 elif p.is_list and (p.restrictions is None or type(p.restrictions) is _NumericRange): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 182 v = getFromDict(args, p.get_lineage(name_only=True)) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 183 if type(v) is str: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 184 setInDict(args, p.get_lineage(name_only=True), qstring2list(v)) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 185 elif p.type is _InFile and not (p.default is None or type(p.default) is _Null): | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 186 v = getFromDict(args, p.get_lineage(name_only=True)) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 187 if v in [[], ""]: | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 188 setInDict(args, p.get_lineage(name_only=True), p.default) | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 189 | 
| 
a3ae12b9217a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 galaxyp parents: diff
changeset | 190 model.write_ctd(input_ctd, arg_dict=args) | 
