diff --git a/generator.py b/generator.py index d3454c4..695fdf4 100755 --- a/generator.py +++ b/generator.py @@ -1004,8 +1004,8 @@ if param.restrictions is not None: # join all formats of the file, take mapping from supported_file if available for an entry if type(param.restrictions) is _FileFormat: - param_format = ','.join([get_supported_file_types(i, supported_file_formats) if - get_supported_file_types(i, supported_file_formats) + param_format = ','.join([get_supported_file_type(i, supported_file_formats) if + get_supported_file_type(i, supported_file_formats) else i for i in param.restrictions.formats]) else: raise InvalidModelException("Expected 'file type' restrictions for input file [%(name)s], " @@ -1048,8 +1048,9 @@ if param.restrictions.n_max is not None: param_node.attrib["max"] = str(param.restrictions.n_max) elif type(param.restrictions) is _FileFormat: - param_node.attrib["format"] = ",".join( - get_supported_file_types(param.restrictions.formats, supported_file_formats)) + param_node.attrib["format"] = ','.join([get_supported_file_type(i, supported_file_formats) if + get_supported_file_type(i, supported_file_formats) + else i for i in param.restrictions.formats]) else: raise InvalidModelException("Unrecognized restriction type [%(type)s] for parameter [%(name)s]" % {"type": type(param.restrictions), "name": param.name}) @@ -1315,6 +1316,14 @@ return data_node +# Get the supported file format for one given format +def get_supported_file_type(format_name, supported_file_formats): + if format_name in supported_file_formats.keys(): + return supported_file_formats.get(format_name, DataType(format_name, format_name)).galaxy_extension + else: + return None + + def get_supported_file_types(formats, supported_file_formats): return set([supported_file_formats.get(format_name, DataType(format_name, format_name)).galaxy_extension for format_name in formats if format_name in supported_file_formats.keys()])