Commit 27d04645 authored by mmassaviol's avatar mmassaviol
Browse files

Update (deal with the from param inputs)

parent 8a076abc
......@@ -58,19 +58,21 @@ def generate(name, path_yaml = "", path_input = DEFAULT_PATH_INPUT, path_output
if "rule_name" in step:
# get rule yaml
inputs_list = list()
RULE_YAML = dict()
for command in TOOL_YAML["commands"]:
if command["name"] == step["rule_name"]:
RULE_YAML = command
# Parcourir le yaml du tool, les commandes et leurs inputs
# Traiter les inputs de type liste
# Gérer les from params (ex: fasta genomes)
inputs_list_from_command = [inputt["name"] for inputt in RULE_YAML["inputs"]] # Liste des inputs dans la commande du yaml de l'outil
inputs_list_from_yaml = list() # Liste des inputs dans le steps_in du yaml du workflow
result += "def " + step["step_name"] + "__" + step["rule_name"] + "_inputs():\n"
result += "\tinputs = dict()\n"
# Parcourir le yaml du tool, les commandes et leurs inputs
# Traiter les inputs de type liste
# Gérer les "from params" (ex: fasta genomes)
if "params" in step:
for param in step["params"]:
......@@ -79,21 +81,28 @@ def generate(name, path_yaml = "", path_input = DEFAULT_PATH_INPUT, path_output
for inputt in RULE_YAML["inputs"]:
if inputt["name"] == param["input_name"]:
INPUT_YAML = inputt
# Inputs de type liste
if ("list" in INPUT_YAML and INPUT_YAML["list"]):
if param["input_name"] not in inputs_list:
inputs_list.append(param["input_name"])
if param["input_name"] not in inputs_list_from_yaml:
result += "\tinputs[\"" + param["input_name"] + "\"] = list()\n"
if "raw_" in param["origin_command"] :
result += "\tinputs[\"" + param["input_name"] + "\"].append(" + param["origin_command"]+"[\""+param["origin_name"]+"\"])\n"
else:
result += "\tinputs[\"" + param["input_name"] + "\"].append(rules." + param["origin_step"] + "__" + param["origin_command"] + ".output." + param["origin_name"] + ")\n"
# inputs classiques
else:
if "raw_" in param["origin_command"] :
result += "\tinputs[\"" + param["input_name"] + "\"] = " + param["origin_command"]+"[\""+param["origin_name"]+"\"]\n"
else:
result += "\tinputs[\"" + param["input_name"] + "\"] = rules." + param["origin_step"] + "__" + param["origin_command"] + ".output." + param["origin_name"] + "\n"
inputs_list_from_yaml.append(param["input_name"]) # input traités (ou vu une fois si de type liste)
# Pour tous les inputs d'une commande qui ne sont pas liés dans le steps_in
for inputt in RULE_YAML["inputs"]:
if inputt["name"] not in inputs_list_from_yaml and "from" in inputt and inputt["from"] == "params":
result += "\tinputs[\"" + inputt["name"] + "\"] = config[\""+ step["step_name"] + "__" + step["rule_name"] + "_" + inputt["name"] +"\"]\n"
result += "\treturn inputs\n"
result += "\n"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment