Commit 8e978b89 authored by mmassaviol's avatar mmassaviol Committed by mmassaviol
Browse files

Update generators scripts to fit step_name param

parent 6264df62
......@@ -58,7 +58,7 @@ def get_params_to_remove(pipeline):
to_remove.append(line["param_B"])
return to_remove
def generate_tool(toolname, pipeline):
def generate_tool(toolname, pipeline, step_name):
to_remove = get_params_to_remove(pipeline)
template = yaml.load(tool_template, Loader=yaml.FullLoader)
tool = read_yaml("tools/" + toolname + "/" + toolname + ".yaml")
......@@ -70,6 +70,7 @@ def generate_tool(toolname, pipeline):
for option in command["options"]:
if option not in template["content"]:
if option["name"] not in to_remove:
option["name"] = step_name + "__" + option["name"]
template["content"].append(option)
template["content"].append(
......@@ -180,7 +181,7 @@ def generate_sag_yaml(pipeline, template, outdir):
# for each tool in a step, create a box
for tool in step["tools"]:
# predefined boxes
template["App"]["pages"][page_number]["boxes"].append(generate_tool(tool,pipeline))
template["App"]["pages"][page_number]["boxes"].append(generate_tool(tool,pipeline,step["name"]))
page_number += 1
return template
......
......@@ -29,9 +29,9 @@ def generate(name):
for cmd in yaml['commands']:
result += "rule " + cmd['name'] + ":\n"
result += "rule <step_name>__" + cmd['name'] + ":\n"
rule_dir = "config[\"" + cmd['name'] + "_output_dir\"]"
rule_dir = "config[\"<step_name>__" + cmd['name'] + "_output_dir\"]"
# input
......@@ -44,7 +44,7 @@ def generate(name):
size_inputs = len(cmd_inputs)
#if(size_inputs == 0):
result += "\t\t**" + name + "_inputs(),\n"
result += "\t\t**<step_name>__" + name + "_inputs(),\n"
for input in cmd_inputs:
......@@ -75,7 +75,7 @@ def generate(name):
if option['type'] == "input_file":
if "name" in option:
result += "\t\t" + option['name'].replace(cmd["name"]+"_","").replace(name+"_","") + " = " + "config[\"" + option['name'] + "\"],\n"
result += "\t\t" + option['name'].replace(cmd["name"]+"_","").replace(name+"_","") + " = " + "config[\"<step_name>__" + option['name'] + "\"],\n"
#result += "\t\tinput_file_p" + str(count_input) + " = " + "config[\"" + option['name'] + "\"],\n"
count_input += 1
......@@ -116,6 +116,9 @@ def generate(name):
result += "\t\toutput_dir = " + result_dir + " + \"/\" + " + rule_dir + "+ \"/" + sample_output + "\",\n"
if "command" in cmd:
result += "\t\tcommand = config[\"<step_name>__" + cmd['name'] + "_command\"],\n"
if "options" in cmd:
cmd_options = cmd['options']
......@@ -128,8 +131,7 @@ def generate(name):
if "_threads" not in option['name']:
result += "\t\t" + option['name'].replace(cmd["name"]+"_","").replace(name+"_","") + " = " + "config[\""+option['name']+"\"],\n"
result += "\t\t" + option['name'].replace(cmd["name"]+"_","").replace(name+"_","") + " = " + "config[\"<step_name>__"+option['name']+"\"],\n"
# log
......@@ -137,7 +139,7 @@ def generate(name):
result += "\n\tlog: \n"
result += "\t\t" + result_dir + " + \"/logs/" + cmd['name'] + "/" + sample + cmd['name'] + "_log.txt\"\n"
result += "\t\t" + result_dir + " + \"/logs/\" + " + rule_dir + " + \"/" + sample + cmd['name'] + "_log.txt\"\n"
# threads
......@@ -150,7 +152,7 @@ def generate(name):
if "name" in option:
if "_threads" in option['name']:
result += "\n\t\tconfig[\"" + option['name'] + "\"]\n"
result += "\n\t\tconfig[\"<step_name>__" + option['name'] + "\"]\n"
count_thread += 1
if count_thread == 0:
......@@ -167,7 +169,7 @@ def generate(name):
#for shell in cmd_shell:
# result += "\t\t\"" + shell + "\"\n"
result += "\t\t\"" + cmd_shell + "\"\n"
result += "\t\t\"{params.command}\"\n"
# End cmd
......@@ -176,7 +178,7 @@ def generate(name):
# End loop cmd
# print(result)
#print(result)
path_snakefile = PATH_INPUT + "/" + name + "/" + name + ".rule.snakefile"
f = open(path_snakefile, "w")
......
This diff is collapsed.
......@@ -70,15 +70,15 @@ def generate(name):
if "rule_name" in step:
result += "def " + step["rule_name"] + "_inputs():\n"
result += "def " + step["step_name"] + "__" + step["rule_name"] + "_inputs():\n"
result += "\tinputs = dict()\n"
if "params" in step:
for param in step["params"]:
if "raw_" in param["origin_command"] :
result += "\tinputs[\"" + param["input_name"] + "\"] = "+param["origin_command"]+"[\""+param["origin_name"]+"\"]\n"
result += "\tinputs[\"" + param["input_name"] + "\"] = " + param["origin_command"]+"[\""+param["origin_name"]+"\"]\n"
else:
result += "\tinputs[\"" + param["input_name"] + "\"] = rules." + param["origin_command"] + ".output." + param["origin_name"] + "\n"
result += "\tinputs[\"" + param["input_name"] + "\"] = rules." + param["origin_step"] + "__" + param["origin_command"] + ".output." + param["origin_name"] + "\n"
result += "\treturn inputs\n"
result += "\n"
......@@ -111,7 +111,7 @@ def generate(name):
if ("_PE" in step["rule_name"]):
add = "and config['SeOrPe'] == 'PE'"
result += "\tif (step == \"" + step["step_name"] + "\" " + add + " ):\n"
result += "\t\toutputs = rules." + step["rule_name"] + ".output\n"
result += "\t\toutputs = rules." + step["step_name"] + "__" + step["rule_name"] + ".output\n"
result += "\t\t\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