annotate fill_ctd.py @ 11:401f500aae50 draft default tip

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