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

update

parent 2a05d205
No related branches found
No related tags found
1 merge request!12Test
Pipeline #13305 passed with stage
in 59 seconds
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
# BioFlow-Insight # BioFlow-Insight
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-green.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Version 1.0](https://img.shields.io/badge/version-v1.0-yellow)]() [![Zenodo doi badge](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.10818333-blue.svg)](https://zenodo.org/uploads/10818333) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-green.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Version 1.0](https://img.shields.io/badge/version-v1.0-yellow)]()
......
...@@ -53,6 +53,9 @@ class Call(Executor): ...@@ -53,6 +53,9 @@ class Call(Executor):
for para in self.parameters: for para in self.parameters:
if(para.get_type()=="Call"): if(para.get_type()=="Call"):
tab = para.get_elements_called(tab_input = tab.copy(), first_call = False) 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)) temp = list(set(tab))
#del tab #del tab
return temp return temp
......
...@@ -42,6 +42,17 @@ class Main_DSL2(Nextflow_Building_Blocks): ...@@ -42,6 +42,17 @@ class Main_DSL2(Nextflow_Building_Blocks):
def get_process_from_name(self, name): def get_process_from_name(self, name):
return self.origin.get_process_from_name(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): def get_function_from_name(self, name):
return self.origin.get_function_from_name(name) return self.origin.get_function_from_name(name)
......
...@@ -295,8 +295,23 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -295,8 +295,23 @@ class Nextflow_File(Nextflow_Building_Blocks):
return None return None
raise Exception(f"Process '{name}' couldn't be found in '{self.get_file_address()}'") 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!")
#---------------------- #----------------------
......
...@@ -62,6 +62,11 @@ class Operation(Executor): ...@@ -62,6 +62,11 @@ class Operation(Executor):
def add_channel(self, channel): def add_channel(self, channel):
self.origin.add_channel(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): def add_origin_channel(self, name):
......
...@@ -7,6 +7,10 @@ import os ...@@ -7,6 +7,10 @@ import os
import re import re
import json import json
from pathlib import Path from pathlib import Path
import glob
from .bioflowinsighterror import BioFlowInsightError
class Workflow: class Workflow:
...@@ -15,6 +19,19 @@ class Workflow: ...@@ -15,6 +19,19 @@ class Workflow:
license = None, creativeWorkStatus = None, authors = None, license = None, creativeWorkStatus = None, authors = None,
version = None, keywords = None, producer = None, version = None, keywords = None, producer = None,
publisher = None, processes_2_remove = 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( self.nextflow_file = Nextflow_File(
file, file,
duplicate=duplicate, duplicate=duplicate,
...@@ -207,6 +224,14 @@ class Workflow: ...@@ -207,6 +224,14 @@ class Workflow:
def add_2_rocrate(self, dico): def add_2_rocrate(self, dico):
self.nextflow_file.add_2_rocrate(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): def initialise_rocrate(self):
self.rocrate = RO_Crate(self) self.rocrate = RO_Crate(self)
self.rocrate.initialise() self.rocrate.initialise()
......
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