diff --git a/src/constant.py b/src/constant.py index 9badf13580651123d61360192ce8f05f7b5ec716..f41e6ea0ea54f8618091840202fb7a6ee7a84eeb 100644 --- a/src/constant.py +++ b/src/constant.py @@ -21,6 +21,27 @@ LIST_OPERATORS = ["distinct", "filter", "first", "last", "randomSample", "take", "close","dump","ifEmpty","print","println","set","view", "empty", "of", "fromPath", "fromList", "subscribe", "value", "from"]#This last line is added by me:) +TOOLS = [ + "samtools", + "bcftools", + "fastqc", + "bedtools", + "multiqc", + "gatk", + "bwa", + "minimap2", + "tabix", + "vcf", + "wget", + "bgzip", + "hmmsearch", + "pigz", + "picard", + "star", + "iqtree", + "idxstats", +] + #========================== # PATTERNS @@ -122,3 +143,5 @@ SUBWORKFLOW_HEADER = r'workflow +(\w+|\'[\w ]+\'|\"[\w ]+\") *{' WORKFLOW_HEADER = r"workflow\s*\{" WORKFLOW_HEADER_2 = r'[^\w](workflow\s*{)' + + diff --git a/src/process.py b/src/process.py index 8a94f275e165e62dc46a055742099efb06ec2dc8..7aee198d36a6f849a04145703376c6651429d2a0 100644 --- a/src/process.py +++ b/src/process.py @@ -19,6 +19,7 @@ class Process(Nextflow_Building_Blocks): self.output_code = "" self.when_code = "" self.script_code = "" + self.tools = [] self.initialise() self.initialised = True @@ -71,6 +72,12 @@ class Process(Nextflow_Building_Blocks): def get_nb_outputs(self): return len(self.outputs) + def extract_tools(self): + script = self.script_code.lower() + for tool in constant.TOOLS: + if tool in script: + self.tools.append(tool) + def initialise_parts(self): code = self.get_code() @@ -126,6 +133,7 @@ class Process(Nextflow_Building_Blocks): self.when_code = temp_code elif(variables_index[i]=='script'): self.script_code = temp_code + self.extract_tools() else: raise Exception("This shoudn't happen!") diff --git a/src/ro_crate.py b/src/ro_crate.py new file mode 100644 index 0000000000000000000000000000000000000000..e987fb7242df0bebe73a1d936b6ccdbcbea92cc1 --- /dev/null +++ b/src/ro_crate.py @@ -0,0 +1,14 @@ + + +class RO_Crate: + def __init__(self, workflow): + self.nextflow_file = workflow + self.directroy = '/'.join(workflow.get_file_address().split('/')[:-1]) + self.dico = {} + + def initialise_dico(self): + None + + def initialise(self): + self.initialise_dico() + print("i'm initialised") \ No newline at end of file diff --git a/src/workflow.py b/src/workflow.py new file mode 100644 index 0000000000000000000000000000000000000000..5f700ae746ca54648094fb12d172206d02aa604a --- /dev/null +++ b/src/workflow.py @@ -0,0 +1,25 @@ + +from .nextflow_file import Nextflow_File +from .ro_crate import RO_Crate + + +class Workflow: + def __init__(self, file, duplicate=False, display_info=True): + self.nextflow_file = Nextflow_File(file, duplicate = duplicate, display_info = display_info) + self.rocrate = None + + + def get_file_address(self): + return self.nextflow_file.get_file_address() + + def initialise_rocrate(self): + self.rocrate = RO_Crate(self) + self.rocrate.initialise() + + + def initialise(self): + self.nextflow_file.initialise() + self.initialise_rocrate() + + def generate_all_graphs(self, render_graphs = True): + self.nextflow_file.generate_all_graphs(render_graphs = render_graphs)