From 6c864700eb8c6f23764a0af60d00dac6bb114d26 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Mon, 13 Jan 2025 14:42:14 +0100
Subject: [PATCH] FIX: remove shebang in the main workflow -> example in
 "isugifNF/blast"

---
 src/workflow.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/workflow.py b/src/workflow.py
index d5d30df..f5eb436 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}"
-- 
GitLab