diff --git a/src/bioflowinsighterror.py b/src/bioflowinsighterror.py index dd222bb911354243c204a4ce080bf325f04eb2ee..0dfc769c67d643823b55529a1319d935dde46a3e 100644 --- a/src/bioflowinsighterror.py +++ b/src/bioflowinsighterror.py @@ -43,6 +43,8 @@ class BioFlowInsightError(Exception): #* [5] -> A ternary conditional operator was used with an tuple #* [7] -> Tuple with emit (ch1, ch2) = emit.out #* [9] -> Tuple with call (ch1, ch2) = wf() +#* [11] -> Failed to extract the operation or call at the line x. Try rewriting it in a simplified version. + diff --git a/src/nextflow_building_blocks.py b/src/nextflow_building_blocks.py index c436bf2b7d6b83b904e0c8869064b6fd8ede4e2b..ce5144c9088f598a39dc7741fa98dd50de672357 100644 --- a/src/nextflow_building_blocks.py +++ b/src/nextflow_building_blocks.py @@ -318,16 +318,24 @@ class Nextflow_Building_Blocks: if(match.group(1) in constant.LIST_OPERATORS): #TODO -> the function below might not work perfectly but i don't have any other ideas - #TODO -> IMPORTANT find another way of doing this -> for example if there isn't the same number of curlies/parentheses + #Use if there is an operator called right before opening the curlies/parenthse - curly_left, curly_right = get_curly_count(text[:start]), get_curly_count(text[end:]) + #curly_left, curly_right = get_curly_count(text[:start]), get_curly_count(text[end:]) parenthese_left, parenthese_right = get_parenthese_count(text[:start]), get_parenthese_count(text[end:]) #if(curly_left==0 and curly_right==0 and parenthese_left==0 and parenthese_right==0 and (start, end) not in searched): if(parenthese_left==0 and parenthese_right==0 and (start, end) not in searched): searched.append((start, end)) - pot = extract_executor_from_middle(text, start, end) + try: + pot = extract_executor_from_middle(text, start, end) + except: + try: + temp = text[start-10:end+10] + except: + temp = text[start:end] + raise BioFlowInsightError(f"Failed to extract the operation or call{self.get_string_line(temp)}. Try rewriting it in a simplified version.", num = 11, origin=self) + pot = expand_to_pipe_operators(text, pot) #If the thing which is extracted is not in the conditon of an if @@ -360,6 +368,7 @@ class Nextflow_Building_Blocks: self.executors.append(ope) searching = True break + #--------------------------------------------------------------- #STEP4 - Extract the Executors which only use the pipe operators (which start with a channel)