diff --git a/README.md b/README.md index 35968973ec8b36c844373da9218661247dc44ad8..42dbd769b0b90d126e3bb1b16f559785794a6b4c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # BioFlow-Insight -[](https://www.gnu.org/licenses/gpl-3.0) []() [](https://zenodo.org/uploads/10818333) +[](https://www.gnu.org/licenses/gpl-3.0) []() diff --git a/src/call.py b/src/call.py index 826778d29bd0871cef723b7d693e8af25d8afeda..0ae3d38c251f30f93bc20a21440c8b181a7fc7af 100644 --- a/src/call.py +++ b/src/call.py @@ -53,6 +53,9 @@ class Call(Executor): for para in self.parameters: if(para.get_type()=="Call"): tab = para.get_elements_called(tab_input = tab.copy(), first_call = False) + elif(para.get_type()=="Operation"): + tab += para.get_elements_called(tab = tab.copy()) + temp = list(set(tab)) #del tab return temp diff --git a/src/main_DSL2.py b/src/main_DSL2.py index cb82f41bdc0e01bb4392b64e6ffacf530f48391d..e882493600bd17a482570863aa833e4e10fcca79 100644 --- a/src/main_DSL2.py +++ b/src/main_DSL2.py @@ -42,6 +42,17 @@ class Main_DSL2(Nextflow_Building_Blocks): def get_process_from_name(self, name): return self.origin.get_process_from_name(name) + def get_processes_called(self, tab = []): + + for c in self.get_all_called(): + if(c.get_type()=="Process"): + tab.append(c) + elif(c.get_type()=="Subworkflow"): + tab+=c.get_processes_called() + + return list(set(tab)) + + def get_function_from_name(self, name): return self.origin.get_function_from_name(name) diff --git a/src/nextflow_file.py b/src/nextflow_file.py index 740bd4e2545015b627c96c23c9a52db0e3c7ddf2..f23e39a8a9598a589269b1a6d9c2a54ed735b6c6 100644 --- a/src/nextflow_file.py +++ b/src/nextflow_file.py @@ -295,8 +295,23 @@ class Nextflow_File(Nextflow_Building_Blocks): return None raise Exception(f"Process '{name}' couldn't be found in '{self.get_file_address()}'") - def get_number_processes(self): - return len(self.processes) + + def get_processes_defined(self, tab = []): + tab+= super().get_processes() + for include in self.includes: + tab+=include.get_file().get_processes_defined() + return list(set(tab)) + + + def get_processes_called(self, tab = []): + if(self.get_DSL()=="DSL1"): + return self.get_processes() + elif(self.get_DSL()=="DSL2"): + return self.main.get_processes_called() + else: + raise Exception("This shouldn't happen!") + + #---------------------- diff --git a/src/operation.py b/src/operation.py index 8f7b1e5efa81691c2344f0ad96882d3cfbebf3ce..8927f0b8007d4f9b115e9d6fac21c0d4eac9c453 100644 --- a/src/operation.py +++ b/src/operation.py @@ -62,6 +62,11 @@ class Operation(Executor): def add_channel(self, channel): self.origin.add_channel(channel) + def get_elements_called(self, tab = []): + for o in self.origins: + if(o.get_type()=="Call"): + tab+=o.get_elements_called() + return tab def add_origin_channel(self, name): diff --git a/src/workflow.py b/src/workflow.py index db2d7a38877de42b980d4b3a117d802f89b42c52..f458b400e4446f4ddbd59e63a77af514c31fe3eb 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -7,6 +7,10 @@ import os import re import json from pathlib import Path +import glob + +from .bioflowinsighterror import BioFlowInsightError + class Workflow: @@ -15,6 +19,19 @@ class Workflow: license = None, creativeWorkStatus = None, authors = None, version = None, keywords = None, producer = None, publisher = None, processes_2_remove = None): + print("here") + if(not os.path.isfile(file)): + nextflow_files = glob.glob(f'{file}/*.nf') + if(len(nextflow_files)==0): + raise BioFlowInsightError("No Nextflow files ('.nf') are in the directory!", num = -1) + try: + file = '/'.join(nextflow_files[0].split('/')[:-1])+"/main.nf" + with open(file, 'r') as f: + txt= f.read() + except: + file =nextflow_files[0] + + self.nextflow_file = Nextflow_File( file, duplicate=duplicate, @@ -207,6 +224,14 @@ class Workflow: def add_2_rocrate(self, dico): self.nextflow_file.add_2_rocrate(dico) + def get_processes_defined(self): + return self.nextflow_file.get_processes_defined() + + def get_processes_called(self): + return self.nextflow_file.get_processes_called() + + + def initialise_rocrate(self): self.rocrate = RO_Crate(self) self.rocrate.initialise()