From e505c92fd74b81d54f54d2eee3c152d74e4f55a0 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Mon, 10 Mar 2025 10:18:38 +0100
Subject: [PATCH] Adding case the workflow is just written in one file -> so no
 includes (no ankers for rewrite)

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

diff --git a/src/workflow.py b/src/workflow.py
index 36e6c96..ace12fe 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -444,9 +444,17 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
         to_replace = []
         for match in re.finditer(constant.FULL_INLCUDE_2, code):
             to_replace.append(match.group(0))
-        for r in to_replace:
-            code = code.replace(r, ankers)
-            ankers = ""
+
+        if(to_replace==[]):
+            pos_start = 0
+            start_code_pattern = r"\#\!\s*\/usr\/bin\/env\s+nextflow"
+            for match in re.finditer(start_code_pattern, code):
+                pos_start = match.span(0)[1]+1
+            code = code[:pos_start]+ankers+code[pos_start:]
+        else:
+            for r in to_replace:
+                code = code.replace(r, ankers)
+                ankers = ""
         
 
         processes, subworkflows, functions = [], [], []
-- 
GitLab