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

Fix minor bug

parent 48d0b921
No related branches found
No related tags found
No related merge requests found
...@@ -84,35 +84,42 @@ class Operation(Executor): ...@@ -84,35 +84,42 @@ class Operation(Executor):
#I don't need to define the equivalent gives -> cause it's not possible:) #I don't need to define the equivalent gives -> cause it's not possible:)
def add_origin_emits(self, full_code, name_called, name_emitted): def add_origin_emits(self, full_code, name_called, name_emitted):
from .emitted import Emitted from .emitted import Emitted
#full_code, name_called, name_emitted = match.group(1), match.group(2), match.group(3) #Check that it not already been added
IGNORE_NAMES = ['params'] added = False
#In the cas an operator is extracted at the end of the emit for o in self.origins:
if(full_code.count('.')>=2): if(full_code==o.get_code()):
splited = full_code.split('.') added = True
if( splited[-1] in constant.LIST_OPERATORS):
full_code = '.'.join(splited[:-1]) if(not added):
if(name_called not in IGNORE_NAMES): #full_code, name_called, name_emitted = match.group(1), match.group(2), match.group(3)
process = self.origin.get_process_from_name(name_called) IGNORE_NAMES = ['params']
subworkflow = self.origin.get_subworkflow_from_name(name_called) #In the cas an operator is extracted at the end of the emit
if(full_code.count('.')>=2):
if(process!=None and subworkflow!=None): splited = full_code.split('.')
raise Exception(f"Problem in get_element -> {name_called} exists as process and subworkflow") if( splited[-1] in constant.LIST_OPERATORS):
#Case subworkflow full_code = '.'.join(splited[:-1])
if(process==None and subworkflow!=None): if(name_called not in IGNORE_NAMES):
emitted = Emitted(name=full_code, origin=self.origin, emitted_by=subworkflow) process = self.origin.get_process_from_name(name_called)
emitted.set_emits(name_emitted) subworkflow = self.origin.get_subworkflow_from_name(name_called)
#Case Process
if(process!=None and subworkflow==None): if(process!=None and subworkflow!=None):
emitted = Emitted(name=full_code, origin=self.origin, emitted_by=process) raise Exception(f"Problem in get_element -> {name_called} exists as process and subworkflow")
#TODO -> analyse the outputs of the process #Case subworkflow
if(process==None and subworkflow!=None):
if(process==None and subworkflow==None): emitted = Emitted(name=full_code, origin=self.origin, emitted_by=subworkflow)
if(name_called[:5]=="Call_"): emitted.set_emits(name_emitted)
name_called = self.calls[name_called].get_code() #Case Process
raise BioFlowInsightError(f"The call for '{name_called}' coudn't be found, before its use in the operation '{self.get_code(get_OG=True)}'{self.get_string_line(self.get_code(get_OG=True))}. Either because the call wasn't made before the operation or that the element it is calling doesn't exist.", num =8, origin=self) if(process!=None and subworkflow==None):
emitted = Emitted(name=full_code, origin=self.origin, emitted_by=process)
emitted.add_sink(self) #TODO -> analyse the outputs of the process
self.origins.append(emitted)
if(process==None and subworkflow==None):
if(name_called[:5]=="Call_"):
name_called = self.calls[name_called].get_code()
raise BioFlowInsightError(f"The call for '{name_called}' coudn't be found, before its use in the operation '{self.get_code(get_OG=True)}'{self.get_string_line(self.get_code(get_OG=True))}. Either because the call wasn't made before the operation or that the element it is calling doesn't exist.", num =8, origin=self)
emitted.add_sink(self)
self.origins.append(emitted)
#This methods checks if the input is an emit and adds it if it's the case, it also returns T/F if it's an emit #This methods checks if the input is an emit and adds it if it's the case, it also returns T/F if it's an emit
def check_is_emit(self, name): def check_is_emit(self, name):
...@@ -171,28 +178,35 @@ class Operation(Executor): ...@@ -171,28 +178,35 @@ class Operation(Executor):
channel.add_source(self) channel.add_source(self)
def add_origin(self, name): def add_origin(self, name):
if(self.origin.get_DSL()=="DSL2"): #Check that it's not already been added
#Case it's a call and it's been replaced added = False
if(re.fullmatch(constant.CALL_ID, name)): for o in self.origins:
self.origins.append(self.calls[name]) if(name==o.get_code()):
added = True
if(not added):
if(self.origin.get_DSL()=="DSL2"):
#Case it's a call and it's been replaced
if(re.fullmatch(constant.CALL_ID, name)):
self.origins.append(self.calls[name])
else:
##Case it's a subworkflow
#subworkflow = self.origin.get_subworkflow_from_name(name)
#process = self.origin.get_process_from_name(name)
#if(subworkflow!=None):
# print("George it's a subworkflow")
# #Case suborkflow
# self.origins.append(subworkflow)
##Case process
#elif(process!=None):
# print("George it's a process")
# #Case process
# self.origins.append(process)
##In this case it's a channel
#else:
self.add_origin_channel(name)
else: else:
##Case it's a subworkflow
#subworkflow = self.origin.get_subworkflow_from_name(name)
#process = self.origin.get_process_from_name(name)
#if(subworkflow!=None):
# print("George it's a subworkflow")
# #Case suborkflow
# self.origins.append(subworkflow)
##Case process
#elif(process!=None):
# print("George it's a process")
# #Case process
# self.origins.append(process)
##In this case it's a channel
#else:
self.add_origin_channel(name) self.add_origin_channel(name)
else:
self.add_origin_channel(name)
#Function that from an operation gives the origin ('input') channels #Function that from an operation gives the origin ('input') channels
......
...@@ -75,6 +75,7 @@ class Process(Nextflow_Building_Blocks): ...@@ -75,6 +75,7 @@ class Process(Nextflow_Building_Blocks):
def get_nb_outputs(self): def get_nb_outputs(self):
return len(self.outputs) return len(self.outputs)
#TODO -> Have a much better way of doing this
def extract_tools(self): def extract_tools(self):
script = self.script_code.lower() script = self.script_code.lower()
for tool in constant.TOOLS: for tool in constant.TOOLS:
......
...@@ -105,7 +105,7 @@ class RO_Crate: ...@@ -105,7 +105,7 @@ class RO_Crate:
return f"{year}-{month}-{day}" return f"{year}-{month}-{day}"
return None return None
#TODO -> update this -> it's incomplet
def get_url(self, file): def get_url(self, file):
if(self.workflow.dico!={}): if(self.workflow.dico!={}):
return f"https://github.com/{self.workflow.get_address()}/blob/main/{file}" return f"https://github.com/{self.workflow.get_address()}/blob/main/{file}"
...@@ -114,8 +114,8 @@ class RO_Crate: ...@@ -114,8 +114,8 @@ class RO_Crate:
def get_creators(self, file): def get_creators(self, file):
info = self.fill_log_file(file, reverse = True) info = self.fill_log_file(file, reverse = True)
for match in re.finditer(r"Author: ([ \w-]+) <([^>]+)>", info): for match in re.finditer(r"Author: ([^>]+)<([^>]+)>",info):
return [{"@id": match.group(1)}] return [{"@id": match.group(1).strip()}]
return None return None
......
...@@ -134,8 +134,8 @@ class Workflow: ...@@ -134,8 +134,8 @@ class Workflow:
def get_authors(self): def get_authors(self):
if(self.authors==None): if(self.authors==None):
authors = {} authors = {}
for match in re.finditer(r"Author: ([ \w-]+) <([^>]+)>",self.log): for match in re.finditer(r"Author: ([^>]+)<([^>]+)>",self.log):
authors[match.group(2)] = match.group(1) authors[match.group(2)] = match.group(1).strip()
tab = [] tab = []
for author in authors: for author in authors:
#tab.append({"@id":author, "name":authors[author]}) #tab.append({"@id":author, "name":authors[author]})
......
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