Mercurial > repos > galaxyp > openms_tofcalibration
annotate fill_ctd.py @ 11:57905fb0008f draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
| author | galaxyp | 
|---|---|
| date | Wed, 23 Sep 2020 13:16:22 +0000 | 
| parents | bfc2c3b46325 | 
| children | 
| rev | line source | 
|---|---|
| 
10
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
1 import collections | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
2 import json | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
3 import operator | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
4 import os | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
5 import re | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
6 import subprocess | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
7 import sys | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
9 | 
| 
 
bfc2c3b46325
"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 ( | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
11 _Choices, | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
12 _InFile, | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
13 _Null, | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
14 _NumericRange, | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
15 CTDModel | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
16 ) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
17 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
18 | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"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) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
21 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
22 | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
25 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
26 | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
28 """ | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
31 """ | 
| 
 
bfc2c3b46325
"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(): | 
| 
 
bfc2c3b46325
"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)): | 
| 
 
bfc2c3b46325
"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]) | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"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] | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
37 else: | 
| 
 
bfc2c3b46325
"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)) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
39 sys.exit(1) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
40 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
41 | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"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) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
44 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
45 | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
47 """ | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
49 while loading | 
| 
 
bfc2c3b46325
"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) | 
| 
 
bfc2c3b46325
"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 -> [] | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
52 - None -> "" (empty string) | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
55 - expressions | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
56 """ | 
| 
 
bfc2c3b46325
"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(): | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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() | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
60 # else | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
62 d[k] = [] | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
64 d[k] = "" | 
| 
 
bfc2c3b46325
"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("$"): | 
| 
 
bfc2c3b46325
"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]) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
67 if m: | 
| 
 
bfc2c3b46325
"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), "") | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
69 continue | 
| 
 
bfc2c3b46325
"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]) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
71 if m: | 
| 
 
bfc2c3b46325
"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)) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
73 continue | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
74 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
75 try: | 
| 
 
bfc2c3b46325
"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") | 
| 
 
bfc2c3b46325
"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() | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
78 except subprocess.CalledProcessError: | 
| 
 
bfc2c3b46325
"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]) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
80 continue | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
81 return d | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
82 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
83 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
84 def qstring2list(qs): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
85 """ | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
87 """ | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
88 lst = list() | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
89 qs = qs.split(" ") | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
90 quoted = False | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
92 if p == "": | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
93 continue | 
| 
 
bfc2c3b46325
"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('"'): | 
| 
 
bfc2c3b46325
"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]) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
96 elif p.startswith('"'): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
97 quoted = True | 
| 
 
bfc2c3b46325
"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:] + " ") | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
99 elif p.endswith('"'): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
100 quoted = False | 
| 
 
bfc2c3b46325
"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] | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
102 else: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
103 if quoted: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
104 lst[-1] += p + " " | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
105 else: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
106 lst.append(p) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
107 return lst | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
108 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
109 | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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()): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
113 v = args[k] | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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]) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
116 if k.startswith("_"): | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
118 del args[k] | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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): | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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]) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
123 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
124 | 
| 
 
bfc2c3b46325
"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] | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
126 | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
130 | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
134 | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"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) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
137 | 
| 
 
bfc2c3b46325
"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: | 
| 
 
bfc2c3b46325
"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"]) | 
| 
 
bfc2c3b46325
"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"] | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
141 | 
| 
 
bfc2c3b46325
"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", | 
| 
 
bfc2c3b46325
"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" | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
147 fix_underscores(args) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
148 | 
| 
 
bfc2c3b46325
"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) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
150 | 
| 
 
bfc2c3b46325
"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 | 
| 
 
bfc2c3b46325
"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 | 
| 
11
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
153 # - new style booleans that get a string (happens for hidden parameters [-test]) | 
| 
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
154 # are transformed to a bool | 
| 
10
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
155 # - unrestricted ITEMLIST which are represented as strings | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
156 # ("=quoted and space separated) in Galaxy -> transform to lists | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
157 # - optional data input parameters that have defaults and for which no | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
158 # value is given -> overwritte with the default | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
159 for p in model.get_parameters(): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
160 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
161 # check if the parameter is in the arguments from the galaxy tool | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
162 # (from the json file(s)), since advanced parameters are absent | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
163 # if the conditional is set to basic parameters | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
164 try: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
165 getFromDict(args, p.get_lineage(name_only=True)) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
166 except KeyError: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
167 # few tools use dashes in parameters which are automatically replaced | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
168 # by underscores by Galaxy. in these cases the dictionary needs to be | 
| 
11
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
169 # updated (better: then dash and the underscore variant are in the dict) | 
| 
10
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
170 # TODO might be removed later https://github.com/OpenMS/OpenMS/pull/4529 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
171 try: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
172 lineage = [_.replace("-", "_") for _ in p.get_lineage(name_only=True)] | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
173 val = getFromDict(args, lineage) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
174 except KeyError: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
175 continue | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
176 else: | 
| 
11
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
177 setInDict(args, p.get_lineage(name_only=True), val) | 
| 
10
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
178 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
179 if p.type is str and type(p.restrictions) is _Choices and set(p.restrictions.choices) == set(["true", "false"]): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
180 v = getFromDict(args, p.get_lineage(name_only=True)) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
181 setInDict(args, p.get_lineage(name_only=True), str(v).lower()) | 
| 
11
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
182 elif p.type is bool: | 
| 
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
183 v = getFromDict(args, p.get_lineage(name_only=True)) | 
| 
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
184 if isinstance(v, str): | 
| 
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
185 v = (v.lower() == "true") | 
| 
 
57905fb0008f
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit f5fcdd54599554099fb00b1973cc91a766ad246a"
 
galaxyp 
parents: 
10 
diff
changeset
 | 
186 setInDict(args, p.get_lineage(name_only=True), v) | 
| 
10
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
187 elif p.is_list and (p.restrictions is None or type(p.restrictions) is _NumericRange): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
188 v = getFromDict(args, p.get_lineage(name_only=True)) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
189 if type(v) is str: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
190 setInDict(args, p.get_lineage(name_only=True), qstring2list(v)) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
191 elif p.type is _InFile and not (p.default is None or type(p.default) is _Null): | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
192 v = getFromDict(args, p.get_lineage(name_only=True)) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
193 if v in [[], ""]: | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
194 setInDict(args, p.get_lineage(name_only=True), p.default) | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
195 | 
| 
 
bfc2c3b46325
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/openms commit ddf41e8bda1ba065f5cdec98e93dee8165ffc1b9"
 
galaxyp 
parents:  
diff
changeset
 | 
196 model.write_ctd(input_ctd, arg_dict=args) | 
