diff --git a/src/block.py b/src/block.py index c58d05d32044bf4af66e7458be540a9a2925fe17..7788cd748f285f5cb2f260ab0c3151b17aa0337b 100644 --- a/src/block.py +++ b/src/block.py @@ -61,6 +61,16 @@ class Block(Root): if(o.get_type()=="Call"): tab.append(o) return tab + + #These are the calls from different blocks on the same level + def get_calls_from_other_blocks_on_same_level(self): + tab = [] + for block in self.origin.get_blocks(): + #TODO perhaps add a verification for blocks with totally different codnitions eg A and !A + if(block!=self): + tab+=block.get_calls_same_level() + tab+=block.get_calls_inside_level() + return tab ############# # CHANNELS @@ -68,12 +78,22 @@ class Block(Root): def get_channels_above_level_rec(self, dico = {}): for c in self.channels: dico[c] = '' - self.origin.get_channel_from_name_above_level_rec(dico) + self.origin.get_channels_above_level_rec(dico) def get_channels_above_level(self, dico = {}): dico = {} self.origin.get_channels_above_level_rec(dico) return list(dico.keys()) + + #These are the channels from different blocks on the same level + def get_channels_from_other_blocks_on_same_level(self): + tab = [] + for block in self.origin.get_blocks(): + #TODO perhaps add a verification for blocks with totally different codnitions eg A and !A + if(block!=self): + tab+=block.get_channels_same_level() + tab+=block.get_channels_inside_level() + return tab #def check_in_channels(self, channel): # for c in self.get_channels(): diff --git a/src/call.py b/src/call.py index 7d47860ae35b3d1a19d5e1b62d3c40f583a64a89..c4ba74b60265ed6ab565e948b52ed1d167266b92 100644 --- a/src/call.py +++ b/src/call.py @@ -155,6 +155,8 @@ class Call(Executor): channels = self.origin.get_channels_from_name_inside_level(param) if(channels==[]): channels = self.origin.get_channels_from_name_above_level(param) + if(channels==[]): + channels = self.origin.get_channels_from_name_other_blocks_on_same_level(param) if(channels==[]): from .channel import Channel channel = Channel(name=param, origin=self.origin) diff --git a/src/executor.py b/src/executor.py index c7ada07e9a0559092b85cc8e97fd3012193a1af0..36911470242ea4a215e36ca901cf57df058dccf9 100644 --- a/src/executor.py +++ b/src/executor.py @@ -49,8 +49,35 @@ class Executor(Nextflow_Building_Blocks): self.origin.add_channel(channel) - def get_channels(self): - return self.origin.get_channels() + def get_channels_same_level(self): + return self.origin.get_channels_same_level() + + def get_channels_above_level(self): + return self.origin.get_channels_above_level() + + def get_channels_inside_level(self): + return self.origin.get_channels_inside_level() + + def get_channels_from_other_blocks_on_same_level(self): + return self.origin.get_channels_from_other_blocks_on_same_level() + + def get_channels_from_name_same_level(self, name): + return self.origin.get_channels_from_name_same_level(name) + + def get_channels_from_name_inside_level(self, name): + return self.origin.get_channels_from_name_inside_level(name) + + def get_channels_from_name_above_level(self, name): + return self.origin.get_channels_from_name_above_level(name) + + def get_channels_from_name_other_blocks_on_same_level(self, name): + return self.origin.get_channels_from_name_other_blocks_on_same_level(name) + + + + + #def get_channels(self): + # return self.origin.get_channels() def check_in_channels(self, channel): return self.origin.check_in_channels(channel) @@ -229,6 +256,13 @@ class Executor(Nextflow_Building_Blocks): for c in call.get_all_calls(): if(c.first_element_called.get_alias()==name): tab.append(c) + #Looking inside the other blocks + if(len(tab)==0): + for call in self.origin.get_calls_from_other_blocks_on_same_level(): + #call.initialise() + for c in call.get_all_calls(): + if(c.first_element_called.get_alias()==name): + tab.append(c) return tab else: diff --git a/src/operation.py b/src/operation.py index 6bdd6d3ba7347b0ac01c8588f783cf1ff7c89f86..96087ff0b65d0bbe8d270c617d0f92a0d7218e44 100644 --- a/src/operation.py +++ b/src/operation.py @@ -95,6 +95,8 @@ class Operation(Executor): #Finally check if the channels is defined above if(channels==[]): channels = self.origin.get_channels_from_name_above_level(name) + if(channels==[]): + channels = self.origin.get_channels_from_name_other_blocks_on_same_level(name) #If it still doesn't exist -> we create it if(channels==[]): channel = Channel(name=name, origin=self.origin) @@ -206,6 +208,8 @@ class Operation(Executor): channels = origin.get_channels_from_name_inside_level(name) if(channels==[]): channels = origin.get_channels_from_name_above_level(name) + if(channels==[]): + channels = origin.get_channels_from_name_other_blocks_on_same_level(name) if(channels==[]): channel = Channel(name=name, origin=self.origin) origin.add_channel(channel) @@ -496,7 +500,7 @@ class Operation(Executor): emited = self.check_is_emit(name) if(not emited): #TODO -> check at what extend this is used - channels = self.get_channels() + channels = self.get_channels_same_level()+self.get_channels_above_level()+self.get_channels_inside_level()+self.get_channels_from_other_blocks_on_same_level() for c in channels: if(c.get_name() in name): pos = [m.start() for m in re.finditer(c.get_name(), operation)] diff --git a/src/root.py b/src/root.py index 2e585d7be6bfd4e5ac6af1f2c4f10bcd71ed88c6..4436ea09489bfaafcd794ffef5d0d1990e8af0f2 100644 --- a/src/root.py +++ b/src/root.py @@ -45,6 +45,9 @@ class Root(Nextflow_Building_Blocks): # CHANNELS ############# + def get_channels_same_level(self): + return self.channels + def get_channels_from_name_same_level(self, name): tab = [] for c in self.channels: @@ -85,6 +88,15 @@ class Root(Nextflow_Building_Blocks): tab.append(c) return tab + def get_channels_from_other_blocks_on_same_level(self): + return [] + + def get_channels_from_name_other_blocks_on_same_level(self, name): + tab = [] + for c in self.get_channels_from_other_blocks_on_same_level(): + if(c.get_name()==name): + tab.append(c) + return tab @@ -141,6 +153,7 @@ class Root(Nextflow_Building_Blocks): for b in self.blocks: b.get_inside_executors_rec(dico) return list(dico.keys()) + #def get_calls(self): # tab = [] @@ -185,7 +198,8 @@ class Root(Nextflow_Building_Blocks): return tab - + def get_calls_from_other_blocks_on_same_level(self): + return [] diff --git a/src/subworkflow.py b/src/subworkflow.py index 432719d7204ff7fee2a1232480e4cebfbb5b8f10..804a50e91f34ac21c334dae30b848c60a207c60c 100644 --- a/src/subworkflow.py +++ b/src/subworkflow.py @@ -209,6 +209,8 @@ class Subworkflow(Main): channels = self.root.get_channels_from_name_same_level(code[i]) if(channels==[]): channels = self.root.get_channels_from_name_inside_level(code[i]) + if(channels==[]): + channels = self.root.get_channels_from_name_other_blocks_on_same_level(code[i]) if(channels!=[]): ope = Operation(code=f"emit: {code[i]}", origin=self) ope.set_as_artificial()