diff --git a/src/nextflow_file.py b/src/nextflow_file.py index b7a523f84b13025428b79d2de2820eb0de19ba6c..0e1cbc159e183717dcd3aeff012458f48fbcc128 100644 --- a/src/nextflow_file.py +++ b/src/nextflow_file.py @@ -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 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: - 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.initialise() diff --git a/src/process.py b/src/process.py index 73d17eec0bdeecf033e2586536c94b15ee348d51..40316241ea669199454a94afd61677960e5ab7dc 100644 --- a/src/process.py +++ b/src/process.py @@ -499,8 +499,10 @@ class Process(Nextflow_Building_Blocks): else: code = self.get_code() call = [f"{self.get_name()}({self.get_parameters_call()})"] - code = code.replace(self.input_code, self.convert_input_code_to_DSL2()) - code = code.replace(self.output_code, self.convert_output_code_to_DSL2()) + if(self.input_code!=""): + 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() diff --git a/src/workflow.py b/src/workflow.py index eea41a2cc0df329ebb384abdb19294f6050e4f12..16135f87713aa58164f0c6d2fac5c91c15feed60 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -347,7 +347,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen for p in nextflow_file.get_processes(): new_process, call = p.convert_to_DSL2() 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: code = code.replace(r[0], r[1]) @@ -363,7 +363,14 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Putting || back 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 #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 raise Exception("This shoudn't happen") #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 @@ -576,7 +583,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen def rewrite_subworkflow_call(self, code, subworklfow): #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_body = subworklfow.get_work()