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

Updated extracting inputs DSL1 + started fixing a thing which was quite...

Updated extracting inputs DSL1 + started fixing a thing which was quite complicated -> added error see at what extend it is used (it's when there is an ambiguous emit)
parent 021df27d
No related branches found
No related tags found
No related merge requests found
Pipeline #14461 failed with stage
in 2 minutes and 8 seconds
......@@ -123,7 +123,8 @@ END_PIPE_OPERATOR = r"\s*(\s*\|\s*\w+)+"
# PROCESS
#--------------------------
FILE = r'file +(\w+) *\n|file +\( *(\w+) *\) *\n'
FILE = r'file +(\w+) *\n|file *\( *(\w+) *\) *\n'
PATH = r'path +(\w+) *\n|path *\( *(\w+) *\) *\n'
FROM = r' from ([^\n]+)\n'
INPUT = r"\n\s*input *:"
INTO = r'into +([\w, ]+)'
......
......@@ -16,6 +16,9 @@ class Emitted(Channel):
self.source.append(emitted_by)
self.emits = None #->this is the channel it's emits -> in the case of a subworkflow
def get_all_conditions(self):
return self.origin.get_all_conditions()
def simplify_code(self):
code = self.get_code(get_OG=True)
thing_which_emits = self.emitted_by.get_first_element_called()
......
......@@ -912,15 +912,47 @@ class Operation(Executor):
# return f"{head}\noperation_{operation_id}_{index} = {lines[-1]}"
to_add = []
dico_origin_2_replace = {}
for o in self.origins:
try:
tmp = dico_origin_2_replace[o.get_code(get_OG=True)]
except:
dico_origin_2_replace[o.get_code(get_OG=True)] = []
if(o.get_type()=="Call"):
#If it's not a function -> then we rewrite it
if(o.get_first_element_called().get_type()!="Function"):
to_add.append(add_origin_equals(o, index))
code = code.replace(o.get_code(get_OG=True), f"operation_{operation_id}_{index}")
dico_origin_2_replace[o.get_code(get_OG=True)].append(f"operation_{operation_id}_{index}")
elif(o.get_type()=="Emitted"):
code = code.replace(o.get_code(get_OG=True), o.simplify_code())
dico_origin_2_replace[o.get_code(get_OG=True)].append(o)
index += 1
temporary_index = 1
for origin in dico_origin_2_replace:
if(len(dico_origin_2_replace[origin])<=1):
for val in dico_origin_2_replace[origin]:
if(type(val)==str):
code = code.replace(origin, val)
else:
code = code.replace(origin, val.simplify_code())
#Case there are mutiple origins then:
else:
#TODO -> fix this problem if you have the courage to -> see at what extend it is used
raise BioFlowInsightError("TODO (update): The output of a emit is ambiguous -> there are multiple instance where it exits")
#print(dico_origin_2_replace)
#for e in dico_origin_2_replace[origin]:
# print(e.get_all_conditions())
temporary_index+=1
#for o in self.origins:
# if(o.get_type()=="Call"):
# #If it's not a function -> then we rewrite it
# if(o.get_first_element_called().get_type()!="Function"):
# to_add.append(add_origin_equals(o, index))
# code = code.replace(o.get_code(get_OG=True), f"operation_{operation_id}_{index}")
# elif(o.get_type()=="Emitted"):
# code = code.replace(o.get_code(get_OG=True), o.simplify_code())
# index += 1
to_add.reverse()
for c in to_add:
......
......@@ -259,16 +259,17 @@ class Process(Nextflow_Building_Blocks):
for line in code.split("\n"):
#Case there is a single channel as an input -> doesn't use from to import channel -> uses file (see https://github.com/nextflow-io/nextflow/blob/45ceadbdba90b0b7a42a542a9fc241fb04e3719d/docs/process.rst)
pattern = constant.FILE
for match in re.finditer(pattern, line+"\n"):
#In the first case it's "file ch" in the second "file (ch)"
try:
extracted = match.group(1).strip()
except:
extracted = match.group(2).strip()
patterns = [constant.FILE, constant.PATH]
for pattern in patterns:
for match in re.finditer(pattern, line+"\n"):
#In the first case it's "file ch" in the second "file (ch)"
try:
extracted = match.group(1).strip()
except:
extracted = match.group(2).strip()
add_channel(extracted)
self.raw_input_names.append(extracted)
add_channel(extracted)
self.raw_input_names.append(extracted)
#Case there are multiple channels as input (e.g. channel1.mix(channel2))
......
......@@ -528,7 +528,11 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
def rewrite_and_initialise(self, code, processes_2_remove, render_graphs):
temp_process_dependency_graph = self.graph.get_process_dependency_graph()
temp_spec_graph = self.graph.full_dico
temp_spec_graph = self.graph.full_dico
#Remove the "_GG_\d+"
#code = re.sub(r"_GG_\d+", "", code)
#Write new code in temporary file
temp_file = self.get_output_dir()/f"temp_{str(self)[-7:-2]}.nf"
with open(temp_file, "w") as file:
......
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