Commit 35c65e31 authored by jlopez's avatar jlopez
Browse files

Update workflows generate snakefile

parent 5aa95db8
......@@ -66,22 +66,28 @@ def generate(name):
result += "# Tools inputs functions\n"
if "steps" in yaml:
if "steps_in" in yaml:
for step in yaml["steps"]:
for step in yaml["steps_in"]:
if "tools" in step:
if "rule_name" in step:
for tool in step["tools"]:
result += "def " + step["rule_name"] + "_inputs():\n"
result += "\tinputs = dict()\n"
if tool != "null":
if "params" in step:
result += "def " + tool + "_inputs():\n"
result += "\tinputs = dict()\n"
result += "\t# TODO Complete inputs\n"
result += "\t# inputs = raw_reads()\n"
result += "\treturn inputs\n"
result += "\n"
for param in step["params"]:
if param["origin_command"] == "raw_reads":
result += "\tinputs[\"" + param["input_name"] + "\"] = raw_reads()[\"read\"]\n"
else:
result += "\tinputs[\"" + param["input_name"] + "\"] = rules." + param["origin_command"] + ".output." + param["origin_name"] + "\n"
result += "\treturn inputs\n"
result += "\n"
result += "\n"
......@@ -100,16 +106,14 @@ def generate(name):
result += "def step_outputs(step):\n"
result += "\toutputs = list()\n"
if "steps" in yaml:
if "steps_in" in yaml:
for step in yaml["steps"]:
for step in yaml["steps_in"]:
if "name" in step:
if ("step_name" in step) and ("tool_name" in step):
result += "\tif (step == \"" + step["name"] + "\"):\n"
result += "\t\t# TODO Complete step\n"
result += "\t\t# outputs = rules.rule_name.output\n"
result += "\t\tpass\n"
result += "\tif (step == \"" + step["step_name"] + "\"):\n"
result += "\t\toutputs = rules." + step["tool_name"] + ".output\n"
result += "\t\t\n"
......@@ -142,12 +146,14 @@ def generate(name):
result += "{import global_rules}\n"
# print(result)
print(result)
path_snakefile = PATH_INPUT + "/" + name + "/" + name + ".snakefile"
f = open(path_snakefile, "w")
f.write(result)
f.close()
#path_snakefile = PATH_INPUT + "/" + name + "/" + name + ".snakefile"
#f = open(path_snakefile, "w")
#f.write(result)
#f.close()
......
......@@ -35,13 +35,32 @@
},
],
steps_in: [
{ step_name: find_overlaps, tool_name: minimap2_overlap_self, rule_name: minimap2_overlap_self, input_name: reads, origin_command: raw_reads, origin_name: read },
{ step_name: assembly, tool_name: miniasm, rule_name: miniasm, input_name: reads, origin_command: raw_reads, origin_name: read },
{ step_name: assembly, tool_name: miniasm, rule_name: miniasm, input_name: paf, origin_command: minimap2_overlap_self, origin_name: reads_overlaps },
{ step_name: mapping, tool_name: minimap2_reference, rule_name: minimap2_reference, input_name: reads, origin_command: raw_reads, origin_name: read },
{ step_name: mapping, tool_name: minimap2_reference, rule_name: minimap2_reference, input_name: fasta, origin_command: miniasm, origin_name: assembly_fasta },
{ step_name: correction, tool_name: racon, rule_name: racon, input_name: reads, origin_command: raw_reads, origin_name: read },
{ step_name: correction, tool_name: racon, rule_name: racon, input_name: assembly, origin_command: miniasm, origin_name: assembly_fasta },
{ step_name: correction, tool_name: racon, rule_name: racon, input_name: overlaps, origin_command: minimap2_reference, origin_name: reads_mapping }
{ step_name: find_overlaps, tool_name: minimap2_overlap_self, rule_name: minimap2_overlap_self,
params: [
{input_name: reads, origin_command: raw_reads, origin_name: read }
]
},
{ step_name: assembly, tool_name: miniasm, rule_name: miniasm,
params: [
{ input_name: reads, origin_command: raw_reads, origin_name: read },
{ input_name: paf, origin_command: minimap2_overlap_self, origin_name: reads_overlaps }
]
},
{ step_name: mapping, tool_name: minimap2_reference, rule_name: minimap2_reference,
params: [
{ input_name: reads, origin_command: raw_reads, origin_name: read },
{ input_name: fasta, origin_command: miniasm, origin_name: assembly_fasta }
]
},
{ step_name: correction, tool_name: racon, rule_name: racon,
params: [
{ input_name: reads, origin_command: raw_reads, origin_name: read },
{ input_name: assembly, origin_command: miniasm, origin_name: assembly_fasta },
{ input_name: overlaps, origin_command: minimap2_reference, origin_name: reads_mapping }
]
}
],
}
\ No newline at end of file
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