Package list ctdconverter / c0a2f82
Added support for positional parameters. Luis de la Garza 4 years ago
1 changed file(s) with 24 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
2727 OUTPUT_BINDING = 'outputBinding'
2828 PREFIX = 'prefix'
2929 OUTPUTS = 'outputs'
30 POSITION = 'position'
3031 VALUE_FROM = 'valueFrom'
3132 GLOB = 'glob'
3233 LABEL = 'label'
107108 create_lists_if_missing(cwl_tool, [INPUTS, OUTPUTS])
108109 # we know the only outputs are of type _OutFile
109110 # we need an input of type string that will contain the name of the output file
110 input_binding = {}
111 input_binding[PREFIX] = utils.extract_command_line_prefix(param, ctd_model)
112 if hardcoded_value is not None:
113 input_binding[VALUE_FROM] = hardcoded_value
114
115111 label = "Filename for %s output file" % param_name
116112 input_name_for_output_filename = get_input_name_for_output_filename(param)
117113 input_param = {}
118114 input_param[ID] = input_name_for_output_filename
119 input_param[INPUT_BINDING] = input_binding
120115 input_param[DOC] = label
121116 input_param[LABEL] = label
122117 if param_default is not None:
123118 input_param[DEFAULT] = param_default
124119 input_param[TYPE] = generate_cwl_param_type(param, TYPE_STRING)
120 insert_input_binding(ctd_model, param, hardcoded_value, input_param)
125121
126122 output_binding = {}
127123 output_binding[GLOB] = "$(inputs.%s)" % input_name_for_output_filename
139135 else:
140136 create_lists_if_missing(cwl_tool, [INPUTS])
141137 # we know that anything that is not an _OutFile is an input
142 input_binding = {}
143 input_binding[PREFIX] = utils.extract_command_line_prefix(param, ctd_model)
144 if hardcoded_value is not None:
145 input_binding[VALUE_FROM] = hardcoded_value
146
147138 input_param = {}
148139 input_param[ID] = cwl_fixed_param_name
149140 input_param[DOC] = param.description
150141 input_param[LABEL] = param.description
151142 if param_default is not None:
152143 input_param[DEFAULT] = param_default
153 input_param[INPUT_BINDING] = input_binding
154144 input_param[TYPE] = generate_cwl_param_type(param)
145 insert_input_binding(ctd_model, param, hardcoded_value, input_param)
155146
156147 cwl_tool[INPUTS].append(input_param)
157148
181172 def generate_cwl_param_type(param, forced_type=None):
182173 cwl_type = TYPE_TO_CWL_TYPE[param.type] if forced_type is None else forced_type
183174 return cwl_type if param.required else ['null', cwl_type]
175
176
177 # generate, and insert, the inputBinding
178 def insert_input_binding(ctd_model, param, hardcoded_value, cwl_input_param):
179 prefix = utils.extract_command_line_prefix(param, ctd_model)
180 prefix = None if prefix is None or not prefix.strip() else prefix
181
182 input_binding = {}
183
184 if prefix is not None:
185 input_binding[PREFIX] = prefix
186
187 if hardcoded_value is not None:
188 input_binding[VALUE_FROM] = hardcoded_value
189
190 if param.is_positional():
191 input_binding[POSITION] = param.position
192
193 # insert input binding if there's something in it
194 if input_binding:
195 cwl_input_param[INPUT_BINDING] = input_binding