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

Fixed some bugs

parent 6211cd77
No related branches found
No related tags found
No related merge requests found
Pipeline #14312 failed with stage
in 2 minutes and 27 seconds
......@@ -123,7 +123,7 @@ END_PIPE_OPERATOR = r"\s*(\s*\|\s*\w+)+"
# PROCESS
#--------------------------
FILE = r'file +(\w+) *\n'
FILE = r'file +(\w+) *\n|file +\( *(\w+) *\) *\n'
FROM = r' from ([^\n]+)\n'
INPUT = r"\n\s*input *:"
INTO = r'into +([\w, ]+)'
......
......@@ -354,7 +354,12 @@ class Process(Nextflow_Building_Blocks):
#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"):
extracted = match.group(1).strip()
#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)
......@@ -581,6 +586,8 @@ class Process(Nextflow_Building_Blocks):
for line in code.split("\n"):
line = line.replace(" into ", ", emit: ")
line = line.replace(" mode flatten", "")
#Remove optionnal true #TODO check if this breaks soemthing
line = line.replace("optional true", "")
line = process_2_DSL2(line)
lines.append(line)
code = "\n".join(lines)
......@@ -590,8 +597,7 @@ class Process(Nextflow_Building_Blocks):
def replacer(match):
return match.group(1)
for o in line[1:]:
code = re.sub(fr"\,\s*{re.escape(o.get_code())}(\s|\,|\))", replacer, code)
code = re.sub(fr"\,\s*{re.escape(o.get_code())}(\s|\,|\))", replacer, code+"\n")
return code
#This method is to detect which are the channels which need to be flattened
......@@ -609,13 +615,16 @@ class Process(Nextflow_Building_Blocks):
if(bool(re.fullmatch(r"\w+\.val", raw_input_names[i]))):
raw_input_names[i] = raw_input_names[i].split('.')[0]
return raw_input_names
def get_parameters_call(self):
return ', '.join(self.clean_raw_input_names(self.raw_input_names))
def convert_to_DSL2(self):
if(self.get_DSL()=="DSL2"):
print("Workflow is already written in DSL2")
else:
code = self.get_code()
call = [f"{self.get_name()}({', '.join(self.clean_raw_input_names(self.raw_input_names))})"]
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())
channels_to_flatten = self.get_channels_to_flatten()
......
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