Skip to content
Snippets Groups Projects
Commit 0858c4e0 authored by George Marchment's avatar George Marchment
Browse files

Small update to DSL1 converter

parent 6ad5b661
No related branches found
No related tags found
No related merge requests found
Pipeline #14689 failed with stage
in 3 minutes and 15 seconds
......@@ -328,6 +328,15 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
nextflow_file = self.get_first_file()
code = nextflow_file.get_code()
#Move the workflow.complete to end of the workflow if it's not already done
for match in re.finditer(r"workflow\.onComplete\s*{", code):
start = match.span(0)[0]
end = extract_curly(code, match.span(0)[1])#This function is defined in the functions file
workflow_on_complete = code[start:end]
code = code.replace(workflow_on_complete, "")
code+="\n"*2+workflow_on_complete
start_code = r"#!/usr/bin/env nextflow"
start_code_pattern = r"\#\!\s*\/usr\/bin\/env\s+nextflow"
end_code = "workflow.onComplete"
......@@ -340,14 +349,13 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
pos_start = match.span(0)[1]+1
#if(code.find(start_code)!=-1):
# pos_start = code.find(start_code)+len(start_code)
body = code[pos_start:pos_end]#.replace('\n', '\n\t')
body = code[pos_start:pos_end].strip()#.replace('\n', '\n\t')
include_section = f"//INCLUDE_SECTION_{tag}"
params_section = f"//PARAMS_SECTION_{tag}"
function_section = f"//FUNCTION_SECTION_{tag}"
process_section = f"//PROCESS_SECTION_{tag}"
code = code.replace(code_to_replace, f"""{start_code}\n\n\n{include_section}\n\n\n{params_section}\n\n\n{function_section}\n\n\n{process_section}\n\n\nworkflow{{\n\n{body}\n}}\n\n""")
##I've out this in a comment cause since it's a DSL1
......@@ -1632,8 +1640,6 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
pattern= fr"[\s\(,]({re.escape(old)})[^\w]"
temp = code
code = replace_group1(code, pattern, new)
if(temp==code and old!=new):
raise Exception("The old wasn't update")
#code = code.replace(old, new)
#Since i've added the conditions myself -> i can just count them by searching for this simple pattern
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment