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

Updated the DSL1 conversion

parent 3f14e951
No related branches found
No related tags found
No related merge requests found
Pipeline #14457 failed with stage
in 2 minutes and 18 seconds
...@@ -333,9 +333,16 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -333,9 +333,16 @@ class Nextflow_File(Nextflow_Building_Blocks):
#Replacing the processes and functions defined with their identifiers -> this is to simplifly the analysis with the conditions #Replacing the processes and functions defined with their identifiers -> this is to simplifly the analysis with the conditions
for process in self.processes: for process in self.processes:
code = code.replace(process.get_code(), f"process: {str(process)}") temp = code
code = code.replace(process.get_code(get_OG = True), f"process: {str(process)}")
if(temp==code):
print(process.get_code())
raise Exception("Something went wrong the code hasn't changed")
for function in self.functions: for function in self.functions:
code = code.replace(function.get_code(), f"function: {str(function)}") temp = code
code = code.replace(function.get_code(get_OG = True), f"function: {str(function)}")
if(temp==code):
raise Exception("Something went wrong the code hasn't changed")
self.main = Main(code= code, nextflow_file=self) self.main = Main(code= code, nextflow_file=self)
self.main.initialise() self.main.initialise()
......
...@@ -499,8 +499,10 @@ class Process(Nextflow_Building_Blocks): ...@@ -499,8 +499,10 @@ class Process(Nextflow_Building_Blocks):
else: else:
code = self.get_code() code = self.get_code()
call = [f"{self.get_name()}({self.get_parameters_call()})"] call = [f"{self.get_name()}({self.get_parameters_call()})"]
code = code.replace(self.input_code, self.convert_input_code_to_DSL2()) if(self.input_code!=""):
code = code.replace(self.output_code, self.convert_output_code_to_DSL2()) code = code.replace(self.input_code, self.convert_input_code_to_DSL2())
if(self.output_code!=""):
code = code.replace(self.output_code, self.convert_output_code_to_DSL2())
channels_to_flatten = self.get_channels_to_flatten() channels_to_flatten = self.get_channels_to_flatten()
......
...@@ -347,7 +347,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -347,7 +347,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
for p in nextflow_file.get_processes(): for p in nextflow_file.get_processes():
new_process, call = p.convert_to_DSL2() new_process, call = p.convert_to_DSL2()
processes.append(new_process) processes.append(new_process)
to_replace.append((p.get_code(), call)) to_replace.append((p.get_code(get_OG = True), call))
for r in to_replace: for r in to_replace:
code = code.replace(r[0], r[1]) code = code.replace(r[0], r[1])
...@@ -363,7 +363,14 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -363,7 +363,14 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
#Putting || back #Putting || back
code = code.replace("$OR$", "||") code = code.replace("$OR$", "||")
self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=False)
#Somethimes this is incorrect but that's due to the fact that the DSL1 analysis isn't as clean as the DSL2 analyse (concerning the conditions)
#What i mean that when searching for channels, DSL1 doesn't consider the conditions when searching from the processes while DSL2 does
#The conversion works well but it's just comparing to the old DSL1 workflow doesn't make sense
#If you want to put this line back you need #TODO update the DSL1 parsing to consider the blocks when defining the processes
#A good example is KevinMenden/hybrid-assembly
#self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=True)
return code return code
#This methods generates a random set of processes to consider as relavant #This methods generates a random set of processes to consider as relavant
...@@ -474,7 +481,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -474,7 +481,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
raise Exception("This shoudn't happen") raise Exception("This shoudn't happen")
#Simplifying main #Simplifying main
code = code.replace(self.get_workflow_main().get_code(), self.get_workflow_main().simplify_code()) code = code.replace(self.get_workflow_main().get_code(get_OG = True), self.get_workflow_main().simplify_code())
#Adding processes into code #Adding processes into code
...@@ -576,7 +583,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen ...@@ -576,7 +583,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
def rewrite_subworkflow_call(self, code, subworklfow): def rewrite_subworkflow_call(self, code, subworklfow):
#Remove the defintion from the code #Remove the defintion from the code
code = code.replace(subworklfow.get_code(), "") code = code.replace(subworklfow.get_code(get_OG = True), "")
OG_call = subworklfow.get_call() OG_call = subworklfow.get_call()
OG_body = subworklfow.get_work() OG_body = subworklfow.get_work()
......
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