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

Started implementing external script extraction

parent 28069901
No related branches found
No related tags found
No related merge requests found
Pipeline #13850 passed with stage
in 1 minute and 1 second
...@@ -80,6 +80,11 @@ class Nextflow_Building_Blocks: ...@@ -80,6 +80,11 @@ class Nextflow_Building_Blocks:
def get_rocrate_key(self, dico): def get_rocrate_key(self, dico):
return f"{self.get_file_address()[len(dico['temp_directory'])+1:]}#{self.get_name()}" return f"{self.get_file_address()[len(dico['temp_directory'])+1:]}#{self.get_name()}"
def get_address(self):
return self.origin.get_address()
def get_workflow_address(self):
return self.origin.get_workflow_address()
......
...@@ -115,6 +115,13 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -115,6 +115,13 @@ class Nextflow_File(Nextflow_Building_Blocks):
return self.display_info return self.display_info
else: else:
return self.origin.get_display_info() return self.origin.get_display_info()
def get_workflow_address(self):
if(self.origin==None):
return self.workflow.get_workflow_directory()
else:
return self.origin.get_workflow_address()
...@@ -259,6 +266,7 @@ class Nextflow_File(Nextflow_Building_Blocks): ...@@ -259,6 +266,7 @@ class Nextflow_File(Nextflow_Building_Blocks):
def get_DSL(self): def get_DSL(self):
return self.DSL return self.DSL
#Method which returns the DSL of the workflow -> by default it's DSL2 #Method which returns the DSL of the workflow -> by default it's DSL2
#I use the presence of include, subworkflows and into/from in processes as a proxy #I use the presence of include, subworkflows and into/from in processes as a proxy
def which_DSL(self): def which_DSL(self):
......
import re import re
import glob
from .code_ import Code from .code_ import Code
from .nextflow_building_blocks import Nextflow_Building_Blocks from .nextflow_building_blocks import Nextflow_Building_Blocks
...@@ -53,6 +54,36 @@ class Process(Nextflow_Building_Blocks): ...@@ -53,6 +54,36 @@ class Process(Nextflow_Building_Blocks):
return self.tools return self.tools
def get_external_scripts_call(self):
code = self.get_script_code()
tab = []
for match in re.finditer(r"([^\s\\\*]+\.(sh|py|R|r|pl))[^\w]", code):
tab.append(match.group(1))
return list(set(tab))
def get_external_scripts_code(self):
calls = self.get_external_scripts_call()
#workflow_directory = self.origin.get_address()
#print(workflow_directory)
#import os
#print(os.getcwd(), self.origin.get_address(), self.get_workflow_address())
for call in calls:
#Check first if the file is in the bin
file = glob.glob(f'{self.get_workflow_address()}/bin/**/{call}', recursive=True)
if(len(file)>1):
print(file)
print("More than one file found!")
#If not we search again
if(len(file)==0):
file = glob.glob(f'{self.get_workflow_address()}/**/{call}', recursive=True)
if(len(file)>1):
print(file)
print("More than one file found!")
#def get_source(self): #def get_source(self):
# return [self] # return [self]
......
...@@ -67,6 +67,7 @@ class Workflow: ...@@ -67,6 +67,7 @@ class Workflow:
output_dir=output_dir, output_dir=output_dir,
workflow = self workflow = self
) )
self.workflow_directory = '/'.join(file.split('/')[:-1])
self.output_dir = Path(output_dir) self.output_dir = Path(output_dir)
self.rocrate = None self.rocrate = None
self.name = name self.name = name
...@@ -133,6 +134,15 @@ class Workflow: ...@@ -133,6 +134,15 @@ class Workflow:
""" """
return self.address return self.address
def get_workflow_directory(self):
"""Method that returns the workflow directory
Keyword arguments:
"""
return self.workflow_directory
def set_address(self): def set_address(self):
"""Method that sets the adress of the workflow main """Method that sets the adress of the workflow main
......
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