Skip to content

Commit 8a57d17

Browse files
authored
Merge pull request #80 from wfcommons/nextflow_improvements
Nextflow improvements
2 parents 1c9a56b + e017fea commit 8a57d17

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

wfcommons/wfbench/translator/nextflow.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ def _generate_task_code(self, task: Task) -> str:
227227
:return: The code.
228228
:rtype: str
229229
"""
230-
231-
code = f"process {task.task_id}()" + "{\n"
230+
function_name = task.task_id.replace(".", "_")
231+
code = f"process {function_name}()" + "{\n"
232232

233233
# File variables
234234
if self._find_children(task.task_id):
@@ -318,22 +318,22 @@ def _generate_task_function(self, task: Task) -> str:
318318

319319
if self._find_parents(task.task_id):
320320
# Input channel mixing and then call
321-
code += f"\tdef {task.task_id}_necessary_input = Channel.empty()\n"
321+
code += f"\tdef {function_name}_necessary_input = Channel.empty()\n"
322322
for f in task.input_files:
323-
code += f"\t{task.task_id}_necessary_input = {task.task_id}_necessary_input.mix(inputs.{f.file_id})\n"
324-
code += f"\tdef {task.task_id}_necessary_input_future = {task.task_id}_necessary_input.collect()\n"
325-
code += f"\tdef {task.task_id}_produced_output = {task.task_id}({task.task_id}_necessary_input_future)\n"
323+
code += f"\t{function_name}_necessary_input = {function_name}_necessary_input.mix(inputs.{f.file_id})\n"
324+
code += f"\tdef {function_name}_necessary_input_future = {function_name}_necessary_input.collect()\n"
325+
code += f"\tdef {function_name}_produced_output = {function_name}({function_name}_necessary_input_future)\n"
326326
else:
327327
# Simple call
328-
code += f"\tdef {task.task_id}_produced_output = {task.task_id}()\n"
328+
code += f"\tdef {function_name}_produced_output = {function_name}()\n"
329329

330330
# Pass on the outputs
331331
code += "\n"
332332
code += "\tdef outputs = inputs.clone()\n"
333333
if self._find_children(task.task_id):
334334
counter = 0
335335
for f in task.output_files:
336-
code += f"\toutputs.{f.file_id} = {task.task_id}_produced_output.map" + "{it[" + str(counter) + "]}\n"
336+
code += f"\toutputs.{f.file_id} = {function_name}_produced_output.map" + "{it[" + str(counter) + "]}\n"
337337
counter += 1
338338
code += "\treturn outputs\n"
339339
code += "}\n\n"

0 commit comments

Comments
 (0)