diff --git a/src/workflow.py b/src/workflow.py index d5d30dfe8644a43c67f8c171af634637559042d8..f5eb436f46dfc720772e923b63fcadf37211ea0a 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -696,15 +696,18 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen tag = str(time.time()) code = self.nextflow_file.get_code() - start_code = "#!/usr/bin/env nextflow" + start_code = r"#!/usr/bin/env nextflow" + start_code_pattern = r"\#\!\s*\/usr\/bin\/env\s+nextflow" end_code = "workflow.onComplete" pos_start, pos_end= 0, len(code) if(code.find(end_code)!=-1): pos_end = code.find(end_code) code_to_replace = code[pos_start:pos_end] - if(code.find(start_code)!=-1): - pos_start = code.find(start_code)+len(start_code) + for match in re.finditer(start_code_pattern, start_code): + 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') include_section = f"//INCLUDE_SECTION_{tag}"