From 3a16480f0a93c7297099998ab862fc816ad9fea6 Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Wed, 7 Feb 2024 15:14:34 +0100 Subject: [PATCH] add cli and test data --- bioflow_insight_cli/__init__.py | 0 bioflow_insight_cli/main.py | 45 +++++++++++++++++++++++++++++++++ wf_test/main.nf | 37 +++++++++++++++++++++++++++ wf_test/modules/p1.nf | 13 ++++++++++ wf_test/subworkflows/wf1.nf | 13 ++++++++++ 5 files changed, 108 insertions(+) create mode 100644 bioflow_insight_cli/__init__.py create mode 100644 bioflow_insight_cli/main.py create mode 100644 wf_test/main.nf create mode 100644 wf_test/modules/p1.nf create mode 100644 wf_test/subworkflows/wf1.nf diff --git a/bioflow_insight_cli/__init__.py b/bioflow_insight_cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bioflow_insight_cli/main.py b/bioflow_insight_cli/main.py new file mode 100644 index 0000000..be9fdb4 --- /dev/null +++ b/bioflow_insight_cli/main.py @@ -0,0 +1,45 @@ +import click + +from src.nextflow_file import Nextflow_File + + +@click.command() +@click.argument('main_workflow_path') +@click.option('--author', 'author', required=False, help='Author name, extracted otherwise') +@click.option('--name', 'name', required=False, help='Workflow name, extracted otherwise') +@click.option('--output-dir', default='./results', help='Where the results will be written') +@click.option( + '--no-duplicate', + 'duplicate', + required=False, + default=True, + is_flag=True, + help='' + 'When processes and subworkflows are duplicated in the workflows by the \'include as\' option, ' + 'this option will duplicate the procedures in the graph output.', +) +@click.option( + '--graph-in-dot-only', + 'render_graphs', + required=False, + default=True, + is_flag=True, + help='Generate the graph output only in dot format, not png (faster).', +) +def cli_command(main_workflow_path, **kwargs): + return cli(main_workflow_path, **kwargs) + + +def cli(main_workflow_path, render_graphs: bool, **kwargs): + """ + The path to main file, subworkflows and modules must be in direct subdir of this file, + in folders with eponymous names. + """ + + w = Nextflow_File(address=main_workflow_path, **kwargs) + w.initialise() + w.generate_all_graphs(render_graphs=render_graphs) + + +if __name__ == '__main__': + cli_command() diff --git a/wf_test/main.nf b/wf_test/main.nf new file mode 100644 index 0000000..babcaa5 --- /dev/null +++ b/wf_test/main.nf @@ -0,0 +1,37 @@ +//include { p1 as p1_1; p1 as p1_2} from './modules/p1' + + +//include { wf1 as wf1_1; wf1 as wf1_2 } from './subworkflows/wf1' +include { wf1 as wf1_1 } from './subworkflows/wf1' +//include { wf1 as wf1_2 } from './subworkflows/wf1' + + + + + + + +workflow { + + a = channel.empty() + + //c = wf1_1(a) + //c = wf1_2(b) + + b = wf1_1(a) + + + + //c = p1_1(p1_2(wf1_2(wf1_1(a)))) + //wf1_1(a) + // | wf1_2 + // | p1_2 + // | p1_1 + + //(a, b) = p1_1(a) + //(ch1, ch2) = (params.ped ? [a, Channel.empty()]: [Channel.empty(), b]) + //(ch1, ch2) = a.into(2) + + + +} \ No newline at end of file diff --git a/wf_test/modules/p1.nf b/wf_test/modules/p1.nf new file mode 100644 index 0000000..6737856 --- /dev/null +++ b/wf_test/modules/p1.nf @@ -0,0 +1,13 @@ + +process p1 { + input: + file(input) + output: + file(output_1) + file(output_2) + + """ + something + """ +} + diff --git a/wf_test/subworkflows/wf1.nf b/wf_test/subworkflows/wf1.nf new file mode 100644 index 0000000..9730430 --- /dev/null +++ b/wf_test/subworkflows/wf1.nf @@ -0,0 +1,13 @@ +include { p1 } from '../modules/p1' + +workflow wf1 { + take: + input_wf1 + + main: + output_wf1 = p1(input_wf1) + + emit: + //val = output_wf1 + output_wf1 +} \ No newline at end of file -- GitLab