Mercurial > repos > galaxyp > openms_mapalignerposeclustering
comparison fill_ctd.py @ 2:1c2a75a8d12b 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:24:24 +0000 |
| parents | be2c8a814fa6 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:be2c8a814fa6 | 2:1c2a75a8d12b |
|---|---|
| 148 | 148 |
| 149 model = CTDModel(from_file=input_ctd) | 149 model = CTDModel(from_file=input_ctd) |
| 150 | 150 |
| 151 # transform values from json that correspond to | 151 # transform values from json that correspond to |
| 152 # - old style booleans (string + restrictions) -> transformed to a str | 152 # - old style booleans (string + restrictions) -> transformed to a str |
| 153 # - new style booleans that get a string (happens for hidden parameters [-test]) | |
| 154 # are transformed to a bool | |
| 153 # - unrestricted ITEMLIST which are represented as strings | 155 # - unrestricted ITEMLIST which are represented as strings |
| 154 # ("=quoted and space separated) in Galaxy -> transform to lists | 156 # ("=quoted and space separated) in Galaxy -> transform to lists |
| 155 # - optional data input parameters that have defaults and for which no | 157 # - optional data input parameters that have defaults and for which no |
| 156 # value is given -> overwritte with the default | 158 # value is given -> overwritte with the default |
| 157 for p in model.get_parameters(): | 159 for p in model.get_parameters(): |
| 162 try: | 164 try: |
| 163 getFromDict(args, p.get_lineage(name_only=True)) | 165 getFromDict(args, p.get_lineage(name_only=True)) |
| 164 except KeyError: | 166 except KeyError: |
| 165 # few tools use dashes in parameters which are automatically replaced | 167 # few tools use dashes in parameters which are automatically replaced |
| 166 # by underscores by Galaxy. in these cases the dictionary needs to be | 168 # by underscores by Galaxy. in these cases the dictionary needs to be |
| 167 # updated | 169 # updated (better: then dash and the underscore variant are in the dict) |
| 168 # TODO might be removed later https://github.com/OpenMS/OpenMS/pull/4529 | 170 # TODO might be removed later https://github.com/OpenMS/OpenMS/pull/4529 |
| 169 try: | 171 try: |
| 170 lineage = [_.replace("-", "_") for _ in p.get_lineage(name_only=True)] | 172 lineage = [_.replace("-", "_") for _ in p.get_lineage(name_only=True)] |
| 171 val = getFromDict(args, lineage) | 173 val = getFromDict(args, lineage) |
| 172 except KeyError: | 174 except KeyError: |
| 173 continue | 175 continue |
| 174 else: | 176 else: |
| 175 setInDict(args, lineage, val) | 177 setInDict(args, p.get_lineage(name_only=True), val) |
| 176 | 178 |
| 177 if p.type is str and type(p.restrictions) is _Choices and set(p.restrictions.choices) == set(["true", "false"]): | 179 if p.type is str and type(p.restrictions) is _Choices and set(p.restrictions.choices) == set(["true", "false"]): |
| 178 v = getFromDict(args, p.get_lineage(name_only=True)) | 180 v = getFromDict(args, p.get_lineage(name_only=True)) |
| 179 setInDict(args, p.get_lineage(name_only=True), str(v).lower()) | 181 setInDict(args, p.get_lineage(name_only=True), str(v).lower()) |
| 180 | 182 elif p.type is bool: |
| 183 v = getFromDict(args, p.get_lineage(name_only=True)) | |
| 184 if isinstance(v, str): | |
| 185 v = (v.lower() == "true") | |
| 186 setInDict(args, p.get_lineage(name_only=True), v) | |
| 181 elif p.is_list and (p.restrictions is None or type(p.restrictions) is _NumericRange): | 187 elif p.is_list and (p.restrictions is None or type(p.restrictions) is _NumericRange): |
| 182 v = getFromDict(args, p.get_lineage(name_only=True)) | 188 v = getFromDict(args, p.get_lineage(name_only=True)) |
| 183 if type(v) is str: | 189 if type(v) is str: |
| 184 setInDict(args, p.get_lineage(name_only=True), qstring2list(v)) | 190 setInDict(args, p.get_lineage(name_only=True), qstring2list(v)) |
| 185 elif p.type is _InFile and not (p.default is None or type(p.default) is _Null): | 191 elif p.type is _InFile and not (p.default is None or type(p.default) is _Null): |
