From ab0d24f1abca09c9c5c8b07b87c0d5b676f6571e Mon Sep 17 00:00:00 2001 From: Tomnl Date: Fri, 5 Jul 2019 17:25:07 +0200 Subject: [PATCH 1/2] Order Galaxy XML to IUC recommendations --- galaxy/converter.py | 24 ++++++++++++++++++------ galaxy/macros.xml | 5 +++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/galaxy/converter.py b/galaxy/converter.py index 08c2f422..aea6b1ea 100755 --- a/galaxy/converter.py +++ b/galaxy/converter.py @@ -241,14 +241,23 @@ def _convert_internal(parsed_ctds, **kwargs): else: logger.info("Converting %s (source %s)" % (model.name, utils.get_filename(origin_file)), 0) tool = create_tool(model) - write_header(tool, model) - create_description(tool, model) - expand_macros(tool, model, **kwargs) + import_macros(tool, model, **kwargs) + if 'references' in kwargs['macros_to_expand']: + macros_to_skip = ['references'] + else: + macros_to_skip = [] + + expand_macros(tool, macros_to_skip=macros_to_skip, **kwargs) + create_command(tool, model, **kwargs) create_inputs(tool, model, **kwargs) create_outputs(tool, model, **kwargs) create_help(tool, model) + if 'references' in kwargs['macros_to_expand']: + kwargs['macros_to_expand'] = ['references'] + expand_macros(tool, **kwargs) + # wrap our tool element into a tree to be able to serialize it tree = ElementTree(tool) logger.info("Writing to %s" % utils.get_filename(output_file), 1) @@ -421,8 +430,7 @@ def create_command(tool, model, **kwargs): # creates the xml elements needed to import the needed macros files -# and to "expand" the macros -def expand_macros(tool, model, **kwargs): +def import_macros(tool, model, **kwargs): macros_node = add_child_node(tool, "macros") token_node = add_child_node(macros_node, "token") token_node.attrib["name"] = "@EXECUTABLE@" @@ -434,12 +442,16 @@ def expand_macros(tool, model, **kwargs): import_node = add_child_node(macros_node, "import") # do not add the path of the file, rather, just its basename import_node.text = os.path.basename(macro_file.name) + +# and to "expand" the macros +def expand_macros(tool, **kwargs): # add nodes for expand_macro in kwargs["macros_to_expand"]: + if 'macros_to_skip' in kwargs and expand_macro in kwargs['macros_to_skip']: + continue expand_node = add_child_node(tool, "expand") expand_node.attrib["macro"] = expand_macro - def get_galaxy_parameter_name(param): return "param_%s" % utils.extract_param_name(param).replace(":", "_").replace("-", "_") diff --git a/galaxy/macros.xml b/galaxy/macros.xml index a582994f..d1da7d62 100644 --- a/galaxy/macros.xml +++ b/galaxy/macros.xml @@ -28,4 +28,9 @@ + + + + + From f2cfbf3450d3999f0b51218870f8aa52b7249d06 Mon Sep 17 00:00:00 2001 From: Thomas N Lawson Date: Mon, 8 Jul 2019 09:39:43 +0100 Subject: [PATCH 2/2] Re-add header and description output --- galaxy/converter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/galaxy/converter.py b/galaxy/converter.py index aea6b1ea..f744b7f1 100755 --- a/galaxy/converter.py +++ b/galaxy/converter.py @@ -241,12 +241,14 @@ def _convert_internal(parsed_ctds, **kwargs): else: logger.info("Converting %s (source %s)" % (model.name, utils.get_filename(origin_file)), 0) tool = create_tool(model) + write_header(tool, model) + create_description(tool, model) + import_macros(tool, model, **kwargs) if 'references' in kwargs['macros_to_expand']: macros_to_skip = ['references'] else: macros_to_skip = [] - expand_macros(tool, macros_to_skip=macros_to_skip, **kwargs) create_command(tool, model, **kwargs)