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

First workflow (EpiDiverse/snp) works A to Z by rewritting and then running

parent 68168d9f
No related branches found
No related tags found
No related merge requests found
Pipeline #14469 failed with stage
in 2 minutes and 30 seconds
...@@ -273,6 +273,26 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -273,6 +273,26 @@ class Nextflow_File(Nextflow_Building_Blocks):
modules+=list(include.defines.values()) modules+=list(include.defines.values())
return modules return modules
def get_calls_made_outside_of_main(self):
#Code without processes
code = self.get_code()
for proecess in self.processes:
code = code.replace(proecess.get_code(), "")
for sub in self.subworkflows:
code = code.replace(sub.get_code(), "")
for fun in self.functions:
code = code.replace(fun.get_code(), "")
if(self.first_file and self.main!=None):
code = code.replace(self.main.get_code(), "")
for include in self.includes:
code = code.replace(include.get_code(), "")
from .root import Root
self.root = Root(code=code, origin= self, modules_defined=self.get_modules_defined(), subworkflow_inputs = [])
self.root.initialise()
calls = {}
self.root.get_all_calls_in_subworkflow(calls=calls)
return list(calls.keys())
#---------------------- #----------------------
#INITIALISE #INITIALISE
......
...@@ -461,21 +461,18 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -461,21 +461,18 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
ankers = function_section+ "\n"*3 + process_section+ "\n"*3 + subworkflow_section ankers = function_section+ "\n"*3 + process_section+ "\n"*3 + subworkflow_section
to_replace = []
for match in re.finditer(constant.FULL_INLCUDE_2, code):
to_replace.append(match.group(0))
if(to_replace==[]): #Place ankers
pos_start = 0 pos_start = 0
start_code_pattern = r"\#\!\s*\/usr\/bin\/env\s+nextflow" start_code_pattern = r"\#\!\s*\/usr\/bin\/env\s+nextflow"
for match in re.finditer(start_code_pattern, code): for match in re.finditer(start_code_pattern, code):
pos_start = match.span(0)[1]+1 pos_start = match.span(0)[1]+1
code = code[:pos_start]+ankers+code[pos_start:] code = code[:pos_start]+ankers+code[pos_start:]
else:
for r in to_replace:
code = code.replace(r, ankers)
ankers = ""
#Remove the includes
for match in re.finditer(constant.FULL_INLCUDE_2, code):
code = re.sub(fr"{re.escape(match.group(0))}.*", "", code)
processes, subworkflows, functions = [], [], [] processes, subworkflows, functions = [], [], []
for c in self.get_workflow_main().get_all_calls_in_workflow(): for c in self.get_workflow_main().get_all_calls_in_workflow():
...@@ -488,6 +485,14 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -488,6 +485,14 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
functions.append(ele) functions.append(ele)
else: else:
raise Exception("This shoudn't happen") raise Exception("This shoudn't happen")
#Get calls to functions made outside of themain which might have been imported -> so we need to add them
for c in self.get_first_file().get_calls_made_outside_of_main():
ele = c.get_first_element_called()
if(ele.get_type()=="Function"):
functions.append(ele)
else:
raise Exception("This shoudn't happen -> either a call to a process or subworkflow outside of main or subworkflow")
#Simplifying main #Simplifying main
code = code.replace(self.get_workflow_main().get_code(get_OG = True), self.get_workflow_main().simplify_code()) code = code.replace(self.get_workflow_main().get_code(get_OG = True), self.get_workflow_main().simplify_code())
......
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