From cc970c416e414bd74c042be95e08d66e346a4791 Mon Sep 17 00:00:00 2001 From: Joon-Klaps Date: Tue, 29 Oct 2024 12:03:56 +0000 Subject: [PATCH 1/8] init --- .../generate_downstream_samplesheets/main.nf | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf new file mode 100644 index 0000000000..1597fb429f --- /dev/null +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf @@ -0,0 +1,54 @@ +// +// Subworkflow with functionality specific to the nf-core/createtaxdb pipeline +// + +workflow SAMPLESHEET_RNASEQ { + take: + ch_reads + + main: + format = 'csv' + + ch_list_for_samplesheet = ch_reads.map { meta, db -> + def tool = meta.tool + def db_name = meta.id + '-' + meta.tool + def db_params = "" + def db_type = "" + def db_path = file(params.outdir).toString() + '/' + meta.tool + '/' + db.getName() + [tool: tool, db_name: db_name, db_params: db_params, db_type: db_type, db_path: db_path] + } + + if (params.build_bracken && params.build_kraken2) { + log.warn("Generated nf-core/taxprofiler samplesheet will only have a row for bracken. If Kraken2 is wished to be executed separately, duplicate row and update tool column to Kraken2!") + } + + channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/databases-taxprofiler", format) +} + +workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { + take: + ch_databases + + main: + def downstreampipeline_names = params.generate_pipeline_samplesheets.split(",") + + if (downstreampipeline_names.contains('taxprofiler')) { + SAMPLESHEET_TAXPROFILER(ch_databases) + } +} + +def channelToSamplesheet(ch_list_for_samplesheet, path, format) { + def format_sep = [csv: ",", tsv: "\t", txt: "\t"][format] + + def ch_header = ch_list_for_samplesheet + + ch_header + .first() + .map { it.keySet().join(format_sep) } + .concat(ch_list_for_samplesheet.map { it.values().join(format_sep) }) + .collectFile( + name: "${path}.${format}", + newLine: true, + sort: false + ) +} From 85add1bdc6ea3cd591b2f7fe6cd09038f1209c5f Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Tue, 29 Oct 2024 13:00:53 +0000 Subject: [PATCH 2/8] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2bf6fcae8..8f3ff37c87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - Update GitHub Actions ([#3237](https://github.com/nf-core/tools/pull/3237)) - add `--dir/-d` option to schema commands ([#3247](https://github.com/nf-core/tools/pull/3247)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.7.1 ([#3250](https://github.com/nf-core/tools/pull/3250)) +- init ([#3261](https://github.com/nf-core/tools/pull/3261)) ## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11] From f2a4f6b6b5873bbd7747d737e60eff636c4d6b7f Mon Sep 17 00:00:00 2001 From: Joon-Klaps Date: Tue, 29 Oct 2024 15:37:37 +0000 Subject: [PATCH 3/8] init for the new subworkflow generate-downstream-samplesheet --- .../generate_downstream_samplesheets/main.nf | 48 ++++++----- .../tests/main.function.nf.test | 79 +++++++++++++++++++ .../tests/main.workflow.nf.test | 43 ++++++++++ .../pipeline-template/workflows/pipeline.nf | 11 +++ .../pipelines/create/template_features.yml | 11 +++ 5 files changed, 173 insertions(+), 19 deletions(-) create mode 100644 nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test create mode 100644 nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf index 1597fb429f..999d9ef911 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf @@ -1,39 +1,49 @@ -// -// Subworkflow with functionality specific to the nf-core/createtaxdb pipeline -// + + + +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + SUBWORKFLOW SPECIFIC FOR RNASEQ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ workflow SAMPLESHEET_RNASEQ { take: ch_reads + format main: - format = 'csv' - - ch_list_for_samplesheet = ch_reads.map { meta, db -> - def tool = meta.tool - def db_name = meta.id + '-' + meta.tool - def db_params = "" - def db_type = "" - def db_path = file(params.outdir).toString() + '/' + meta.tool + '/' + db.getName() - [tool: tool, db_name: db_name, db_params: db_params, db_type: db_type, db_path: db_path] - } - if (params.build_bracken && params.build_kraken2) { - log.warn("Generated nf-core/taxprofiler samplesheet will only have a row for bracken. If Kraken2 is wished to be executed separately, duplicate row and update tool column to Kraken2!") + ch_list_for_samplesheet = ch_reads.map { meta, reads -> + def out_path = file(params.outdir).toString() + '/relative/custom/path/' + def sample = meta.id + def fastq_1 = meta.single_end ? out_path + reads.getName() : out_path + reads[0].getName() + def fastq_2 = !meta.single_end ? out_path + reads[1].getName() : "" + def strandedness = "auto" + [sample: sample, fastq_1: fastq_1, fastq_2: fastq_2, strandedness: strandedness] } - channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/databases-taxprofiler", format) + channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/rnaseq", format) } +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + SUBWORKFLOW CALLING PIPELINE SPECIFIC SAMPLESHEET GENERATION +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { take: - ch_databases + ch_reads main: def downstreampipeline_names = params.generate_pipeline_samplesheets.split(",") - if (downstreampipeline_names.contains('taxprofiler')) { - SAMPLESHEET_TAXPROFILER(ch_databases) + if (downstreampipeline_names.contains('rnaseq')) { + SAMPLESHEET_RNASEQ( + ch_reads, + params.generate_pipeline_samplesheets_format + ) } } diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test new file mode 100644 index 0000000000..6f63e4fa5a --- /dev/null +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test @@ -0,0 +1,79 @@ + +nextflow_function { + + name "Test Functions" + script "../main.nf" + tag 'subworkflows' + tag 'generate_downstream_samplesheets' + tag 'subworkflows/generate_downstream_samplesheets' + + test("Test Function channelToSamplesheet - csv") { + + function "channelToSamplesheet" + + when { + function { + """ + // define inputs of the function here. Example: + input[0] = Channel.of( + [ + [sample: 'test-pe', + fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + fastq_2: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + strandedness: 'auto'] + ], + [ + [sample: 'test-se', + fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + fastq_2: '', + strandedness: 'auto'] + ] + input[1] = "$outputDir/test.csv" + input[2] = "csv" + """ + } + } + + then { + assertAll( + { assert function.success }, + { assert snapshot(function.result).match() } + ) + } + } + + test("Test Function channelToSamplesheet - tsv") { + + function "channelToSamplesheet" + + when { + function { + """ + // define inputs of the function here. Example: + input[0] = Channel.of( + [ + [sample: 'test-pe', + fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + fastq_2: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + strandedness: 'auto'] + ], + [ + [sample: 'test-se', + fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + fastq_2: '', + strandedness: 'auto'] + ] + input[1] = "$outputDir/test.tsv" + input[2] = "tsv" + """ + } + } + + then { + assertAll( + { assert function.success }, + { assert snapshot(function.result).match() } + ) + } + } +} diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test new file mode 100644 index 0000000000..b3a80587b3 --- /dev/null +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test @@ -0,0 +1,43 @@ +nextflow_workflow { + + name "Test Workflow GENERATE_DOWNSTREAM_SAMPLESHEETS" + script "../main.nf" + workflow "GENERATE_DOWNSTREAM_SAMPLESHEETS" + tag 'subworkflows' + tag 'generate_downstream_samplesheets' + tag 'subworkflows/generated_downstream_samplesheets' + + test("Test worfklow rnaseq") { + when { + params { + outdir = "." + generate_pipeline_samplesheets = 'rnaseq' + generate_pipeline_samplesheets_format = 'csv' + } + workflow { + """ + input[0] = Channel.of( + [ + [id: 'test-pe', single_end: false, reads: ['test_1.fastq.gz', 'test_2.fastq.gz']] + ], + [ + [id: 'test-se', single_end: true, reads: ['test_1.fastq.gz']] + ] + ) + """ + } + } + + then { + assertAll( + { assert workflow.success }, + { assert snapshot( + [ + "${params.outdir}/downstream_samplesheets/rnaseq.csv" + ]).match() + } + ) + } + } + +} diff --git a/nf_core/pipeline-template/workflows/pipeline.nf b/nf_core/pipeline-template/workflows/pipeline.nf index 4dd8674c1b..c268f6e5ba 100644 --- a/nf_core/pipeline-template/workflows/pipeline.nf +++ b/nf_core/pipeline-template/workflows/pipeline.nf @@ -11,6 +11,7 @@ {% if multiqc %}include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline'{% endif %} include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline' {% if citations or multiqc %}include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_{{ short_name }}_pipeline'{% endif %} +{% if downstream_samplesheet %}include { GENERATE_DOWNSTREAM_SAMPLESHEETS } from '../subworkflows/local/generate_downstream_samplesheets'{% endif %} {%- endif %} /* @@ -41,6 +42,16 @@ workflow {{ short_name|upper }} { ch_versions = ch_versions.mix(FASTQC.out.versions.first()) {%- endif %} + + {% if downstream_samplesheet %} + // + // SUBWORKFLOW: Generate downstream samplesheets + // + GENERATE_DOWNSTREAM_SAMPLESHEETS( + ch_samplesheet + ) + {% endif %} + // // Collate and save software versions // diff --git a/nf_core/pipelines/create/template_features.yml b/nf_core/pipelines/create/template_features.yml index 0a3180286f..635c8105eb 100644 --- a/nf_core/pipelines/create/template_features.yml +++ b/nf_core/pipelines/create/template_features.yml @@ -279,6 +279,17 @@ modules: - "modules.json" nfcore_pipelines: False custom_pipelines: True +downstream_samplesheet: + skippable_paths: + - "subworkflows/local/generate_downstream_samplesheets/" + short_description: "Include a subworkflow to generate downstream samplesheets" + description: "The pipeline will include the generate_downstream_samplesheets subworkflow for the generation of a samplesheet for other downstream pipelines." + help_text: | + The pipeline will include the generate_downstream_samplesheets subworkflow. + generate_downstream_samplesheets is a subworkflow which provides a base template for generating samplesheets. + The subworklow takes an input channel, converts it into the correct format and writes it to a samplesheet that can be used as an input for another pipeline. + nfcore_pipelines: True + custom_pipelines: True changelog: skippable_paths: - "CHANGELOG.md" From 318ac2fe516bfd8fbfbaeeb7267b7d9a1787a41d Mon Sep 17 00:00:00 2001 From: Joon-Klaps Date: Tue, 29 Oct 2024 16:17:34 +0000 Subject: [PATCH 4/8] tests not yet working --- .../tests/main.function.nf.test | 4 ++-- nf_core/pipelines/create/template_features.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test index 6f63e4fa5a..1d469d3857 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test @@ -27,7 +27,7 @@ nextflow_function { fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', fastq_2: '', strandedness: 'auto'] - ] + ]) input[1] = "$outputDir/test.csv" input[2] = "csv" """ @@ -62,7 +62,7 @@ nextflow_function { fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', fastq_2: '', strandedness: 'auto'] - ] + ]) input[1] = "$outputDir/test.tsv" input[2] = "tsv" """ diff --git a/nf_core/pipelines/create/template_features.yml b/nf_core/pipelines/create/template_features.yml index 635c8105eb..3d592d5408 100644 --- a/nf_core/pipelines/create/template_features.yml +++ b/nf_core/pipelines/create/template_features.yml @@ -281,7 +281,7 @@ modules: custom_pipelines: True downstream_samplesheet: skippable_paths: - - "subworkflows/local/generate_downstream_samplesheets/" + - "subworkflows/local/generate_downstream_samplesheets" short_description: "Include a subworkflow to generate downstream samplesheets" description: "The pipeline will include the generate_downstream_samplesheets subworkflow for the generation of a samplesheet for other downstream pipelines." help_text: | From db702003f08271a4f5f335300672a92eec6acb64 Mon Sep 17 00:00:00 2001 From: Joon-Klaps Date: Wed, 30 Oct 2024 10:37:03 +0000 Subject: [PATCH 5/8] Refactor generate_downstream_samplesheets subworkflow This commit refactors the generate_downstream_samplesheets subworkflow in the pipeline-template. It updates the workflow to a specific pipeline and adds support for more pipelines in the future. The changes include modifying the input parameters and updating the channelToSamplesheet function. This refactoring improves the flexibility and extensibility of the subworkflow. --- .../generate_downstream_samplesheets/main.nf | 7 +++-- .../tests/main.function.nf.test | 16 ++++++------ .../tests/main.function.nf.test.snap | 26 +++++++++++++++++++ .../tests/main.workflow.nf.test | 6 +++-- .../tests/main.workflow.nf.test.snap | 14 ++++++++++ .../pipelines/create/template_features.yml | 6 ++--- 6 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test.snap create mode 100644 nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf index 999d9ef911..b51cbb1063 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf @@ -7,6 +7,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +// TODO: Update the following workflow to a specific pipeline workflow SAMPLESHEET_RNASEQ { take: ch_reads @@ -34,19 +35,21 @@ workflow SAMPLESHEET_RNASEQ { workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { take: - ch_reads + input main: def downstreampipeline_names = params.generate_pipeline_samplesheets.split(",") + // TODO: Add more pipelines here if (downstreampipeline_names.contains('rnaseq')) { SAMPLESHEET_RNASEQ( - ch_reads, + input, params.generate_pipeline_samplesheets_format ) } } +// Input can be any channel with a dictionary def channelToSamplesheet(ch_list_for_samplesheet, path, format) { def format_sep = [csv: ",", tsv: "\t", txt: "\t"][format] diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test index 1d469d3857..8c79968af8 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test @@ -17,16 +17,16 @@ nextflow_function { // define inputs of the function here. Example: input[0] = Channel.of( [ - [sample: 'test-pe', + sample: 'test-pe', fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', fastq_2: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', - strandedness: 'auto'] + strandedness: 'auto' ], [ - [sample: 'test-se', + sample: 'test-se', fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', fastq_2: '', - strandedness: 'auto'] + strandedness: 'auto' ]) input[1] = "$outputDir/test.csv" input[2] = "csv" @@ -52,16 +52,16 @@ nextflow_function { // define inputs of the function here. Example: input[0] = Channel.of( [ - [sample: 'test-pe', + sample: 'test-pe', fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', fastq_2: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', - strandedness: 'auto'] + strandedness: 'auto' ], [ - [sample: 'test-se', + sample: 'test-se', fastq_1: 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', fastq_2: '', - strandedness: 'auto'] + strandedness: 'auto' ]) input[1] = "$outputDir/test.tsv" input[2] = "tsv" diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test.snap b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test.snap new file mode 100644 index 0000000000..7256fc36f9 --- /dev/null +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.function.nf.test.snap @@ -0,0 +1,26 @@ +{ + "Test Function channelToSamplesheet - tsv": { + "content": [ + { + + } + ], + "meta": { + "nf-test": "0.9.1", + "nextflow": "24.10.0" + }, + "timestamp": "2024-10-30T10:06:13.403158303" + }, + "Test Function channelToSamplesheet - csv": { + "content": [ + { + + } + ], + "meta": { + "nf-test": "0.9.1", + "nextflow": "24.10.0" + }, + "timestamp": "2024-10-30T10:06:02.487840724" + } +} \ No newline at end of file diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test index b3a80587b3..4535e8072e 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test @@ -18,10 +18,12 @@ nextflow_workflow { """ input[0] = Channel.of( [ - [id: 'test-pe', single_end: false, reads: ['test_1.fastq.gz', 'test_2.fastq.gz']] + [ id:'test', single_end:false ], + [file('test_1.fastq.gz', checkIfExists: false), file('test_2.fastq.gz', checkIfExists: false)] ], [ - [id: 'test-se', single_end: true, reads: ['test_1.fastq.gz']] + [id: 'test-se', single_end: true], + file('test_1.fastq.gz', checkIfExists: false) ] ) """ diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap new file mode 100644 index 0000000000..b81e6155b8 --- /dev/null +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap @@ -0,0 +1,14 @@ +{ + "Test worfklow rnaseq": { + "content": [ + [ + "./downstream_samplesheets/rnaseq.csv" + ] + ], + "meta": { + "nf-test": "0.9.1", + "nextflow": "24.10.0" + }, + "timestamp": "2024-10-30T09:34:46.912767154" + } +} \ No newline at end of file diff --git a/nf_core/pipelines/create/template_features.yml b/nf_core/pipelines/create/template_features.yml index 3d592d5408..b43bfba6ca 100644 --- a/nf_core/pipelines/create/template_features.yml +++ b/nf_core/pipelines/create/template_features.yml @@ -282,12 +282,12 @@ modules: downstream_samplesheet: skippable_paths: - "subworkflows/local/generate_downstream_samplesheets" - short_description: "Include a subworkflow to generate downstream samplesheets" + short_description: "Generate downstream samplesheets" description: "The pipeline will include the generate_downstream_samplesheets subworkflow for the generation of a samplesheet for other downstream pipelines." help_text: | The pipeline will include the generate_downstream_samplesheets subworkflow. - generate_downstream_samplesheets is a subworkflow which provides a base template for generating samplesheets. - The subworklow takes an input channel, converts it into the correct format and writes it to a samplesheet that can be used as an input for another pipeline. + + The subworkflow generate_downstream_samplesheets provides a base template for generating samplesheets by taking a specified input channel of i.e. reads or fasta extracts its metadata for generating samplesheets. nfcore_pipelines: True custom_pipelines: True changelog: From 34dc6e5a8125edb00f5bcf16ebe434aee8bfc3af Mon Sep 17 00:00:00 2001 From: Joon-Klaps Date: Wed, 30 Oct 2024 11:17:32 +0000 Subject: [PATCH 6/8] adding params in config --- nf_core/pipeline-template/conf/test.config | 6 ++++++ nf_core/pipeline-template/conf/test_full.config | 6 ++++++ nf_core/pipeline-template/nextflow.config | 7 +++++++ nf_core/pipeline-template/workflows/pipeline.nf | 8 +++++--- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/nf_core/pipeline-template/conf/test.config b/nf_core/pipeline-template/conf/test.config index bea6f670d0..0c2f9392fc 100644 --- a/nf_core/pipeline-template/conf/test.config +++ b/nf_core/pipeline-template/conf/test.config @@ -31,4 +31,10 @@ params { // Genome references genome = 'R64-1-1' {%- endif %} + + {% if downstream_samplesheets -%} + // Downstream samplesheets + generate_downstream_samplesheets = true + generate_pipeline_samplesheets = 'rnaseq' + {%- endif %} } diff --git a/nf_core/pipeline-template/conf/test_full.config b/nf_core/pipeline-template/conf/test_full.config index aa3b70c1e5..e01c4a8bc6 100644 --- a/nf_core/pipeline-template/conf/test_full.config +++ b/nf_core/pipeline-template/conf/test_full.config @@ -26,4 +26,10 @@ params { // Fasta references fasta = params.pipelines_testdata_base_path + 'viralrecon/genome/NC_045512.2/GCF_009858895.2_ASM985889v3_genomic.200409.fna.gz' {%- endif %} + + {% if downstream_samplesheets -%} + // Downstream samplesheets + generate_downstream_samplesheets = true + generate_pipeline_samplesheets = 'rnaseq' + {%- endif %} } diff --git a/nf_core/pipeline-template/nextflow.config b/nf_core/pipeline-template/nextflow.config index 0afaaa6785..05e82de55c 100644 --- a/nf_core/pipeline-template/nextflow.config +++ b/nf_core/pipeline-template/nextflow.config @@ -29,6 +29,13 @@ params { {% if citations %}multiqc_methods_description = null{% endif %} {%- endif %} + {% if downstream_samplesheet -%} + // Downstream samplesheet generation + generate_downstream_samplesheets = false + generate_pipeline_samplesheets = null + generate_pipeline_samplesheets_format = 'csv' + {%- endif %} + // Boilerplate options outdir = null {% if modules %}publish_dir_mode = 'copy'{% endif %} diff --git a/nf_core/pipeline-template/workflows/pipeline.nf b/nf_core/pipeline-template/workflows/pipeline.nf index c268f6e5ba..fd7a29b904 100644 --- a/nf_core/pipeline-template/workflows/pipeline.nf +++ b/nf_core/pipeline-template/workflows/pipeline.nf @@ -47,9 +47,11 @@ workflow {{ short_name|upper }} { // // SUBWORKFLOW: Generate downstream samplesheets // - GENERATE_DOWNSTREAM_SAMPLESHEETS( - ch_samplesheet - ) + if (params.generate_downstream_samplesheets) { + GENERATE_DOWNSTREAM_SAMPLESHEETS( + ch_samplesheet + ) + } {% endif %} // From 82d97d29b485f6bf1b79c8796a09262bf3c93cfb Mon Sep 17 00:00:00 2001 From: Joon-Klaps Date: Thu, 31 Oct 2024 11:01:26 +0000 Subject: [PATCH 7/8] implement suggested changes & add params to schema --- CHANGELOG.md | 2 +- nf_core/pipeline-template/conf/test.config | 4 +- .../pipeline-template/conf/test_full.config | 4 +- .../pipeline-template/nextflow_schema.json | 24 +++++++++++ .../generate_downstream_samplesheets/main.nf | 42 ++++++++++++++++++- .../pipelines/create/template_features.yml | 4 +- 6 files changed, 71 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f3ff37c87..ba21bb55f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ - Update GitHub Actions ([#3237](https://github.com/nf-core/tools/pull/3237)) - add `--dir/-d` option to schema commands ([#3247](https://github.com/nf-core/tools/pull/3247)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.7.1 ([#3250](https://github.com/nf-core/tools/pull/3250)) -- init ([#3261](https://github.com/nf-core/tools/pull/3261)) +- Add `downstream_samplesheets` to skip_features and GENERATE_DOWNSTREAM_SAMPLESHEETS to template ([#3261](https://github.com/nf-core/tools/pull/3261)) ## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11] diff --git a/nf_core/pipeline-template/conf/test.config b/nf_core/pipeline-template/conf/test.config index 0c2f9392fc..016d5639cd 100644 --- a/nf_core/pipeline-template/conf/test.config +++ b/nf_core/pipeline-template/conf/test.config @@ -32,9 +32,9 @@ params { genome = 'R64-1-1' {%- endif %} - {% if downstream_samplesheets -%} + {% if downstream_samplesheet -%} // Downstream samplesheets generate_downstream_samplesheets = true - generate_pipeline_samplesheets = 'rnaseq' + generate_pipeline_samplesheets = 'rnaseq,sarek' {%- endif %} } diff --git a/nf_core/pipeline-template/conf/test_full.config b/nf_core/pipeline-template/conf/test_full.config index e01c4a8bc6..f525e636a9 100644 --- a/nf_core/pipeline-template/conf/test_full.config +++ b/nf_core/pipeline-template/conf/test_full.config @@ -27,9 +27,9 @@ params { fasta = params.pipelines_testdata_base_path + 'viralrecon/genome/NC_045512.2/GCF_009858895.2_ASM985889v3_genomic.200409.fna.gz' {%- endif %} - {% if downstream_samplesheets -%} + {% if downstream_samplesheet -%} // Downstream samplesheets generate_downstream_samplesheets = true - generate_pipeline_samplesheets = 'rnaseq' + generate_pipeline_samplesheets = 'sarek,rnaseq' {%- endif %} } diff --git a/nf_core/pipeline-template/nextflow_schema.json b/nf_core/pipeline-template/nextflow_schema.json index 4136a0b490..47a6624e6c 100644 --- a/nf_core/pipeline-template/nextflow_schema.json +++ b/nf_core/pipeline-template/nextflow_schema.json @@ -86,6 +86,30 @@ } }, {%- endif %} + {% if downstream_samplesheet %} + "generate_samplesheet_options": { + "title": "Downstream pipeline samplesheet generation options", + "type": "object", + "fa_icon": "fas fa-university", + "description": "Options for generating input samplesheets for complementary downstream pipelines.", + "properties": { + "generate_downstream_samplesheets": { + "type": "boolean", + "description": "Turn on generation of samplesheets for downstream pipelines." + }, + "generate_pipeline_samplesheets": { + "type": "string", + "description": "Specify a comma separated string in quotes to specify which pipeline to generate a samplesheet for.", + "pattern": "^(rnaseq|sarek)(?:,(sarek|rnaseq)){0,1}" + }, + "generate_pipeline_samplesheets_format": { + "type": "string", + "description": "Specify the output format of the samplesheet.", + "enum": ["txt", "tsv", "csv"], + } + } + }, + {%- endif %} {%- if nf_core_configs %} "institutional_config_options": { "title": "Institutional config options", diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf index b51cbb1063..7b796bd381 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf @@ -7,7 +7,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -// TODO: Update the following workflow to a specific pipeline +// TODO nf-core: Update the following workflow to a specific pipeline workflow SAMPLESHEET_RNASEQ { take: ch_reads @@ -15,7 +15,9 @@ workflow SAMPLESHEET_RNASEQ { main: + //TODO nf-core: customise to your needs ch_list_for_samplesheet = ch_reads.map { meta, reads -> + //TODO nf-core: Update the path to the published output directory of the reads def out_path = file(params.outdir).toString() + '/relative/custom/path/' def sample = meta.id def fastq_1 = meta.single_end ? out_path + reads.getName() : out_path + reads[0].getName() @@ -27,6 +29,35 @@ workflow SAMPLESHEET_RNASEQ { channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/rnaseq", format) } +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + SUBWORKFLOW SPECIFIC FOR SAREK +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +// TODO nf-core: Update the following workflow to a specific pipeline +workflow SAMPLESHEET_SAREK { + take: + ch_reads + format + + main: + + //TODO nf-core: customise to your needs + ch_list_for_samplesheet = ch_reads.map { meta, reads -> + //TODO nf-core: Update the path to the published output directory of the reads + def out_path = file(params.outdir).toString() + '/relative/custom/path/' + def patient = meta.id + def sample = meta.id + def lane = "" + def fastq_1 = meta.single_end ? out_path + reads.getName() : out_path + reads[0].getName() + def fastq_2 = !meta.single_end ? out_path + reads[1].getName() : "" + [ patient: patient, sample: sample, lane: lane, fastq_1: fastq_1, fastq_2: fastq_2 ] + } + + channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/rnaseq", format) +} + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUBWORKFLOW CALLING PIPELINE SPECIFIC SAMPLESHEET GENERATION @@ -40,13 +71,20 @@ workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { main: def downstreampipeline_names = params.generate_pipeline_samplesheets.split(",") - // TODO: Add more pipelines here + // TODO nf-coee: Add more pipelines here if (downstreampipeline_names.contains('rnaseq')) { SAMPLESHEET_RNASEQ( input, params.generate_pipeline_samplesheets_format ) } + + if (downstreampipeline_names.contains('rnaseq')) { + SAMPLESHEET_SAREK( + input, + params.generate_pipeline_samplesheets_format + ) + } } // Input can be any channel with a dictionary diff --git a/nf_core/pipelines/create/template_features.yml b/nf_core/pipelines/create/template_features.yml index b43bfba6ca..edff8a19ac 100644 --- a/nf_core/pipelines/create/template_features.yml +++ b/nf_core/pipelines/create/template_features.yml @@ -285,9 +285,9 @@ downstream_samplesheet: short_description: "Generate downstream samplesheets" description: "The pipeline will include the generate_downstream_samplesheets subworkflow for the generation of a samplesheet for other downstream pipelines." help_text: | - The pipeline will include the generate_downstream_samplesheets subworkflow. + The pipeline will include the `GENERATE_DOWNSTREAM_SAMPLESHEETS` subworkflow. - The subworkflow generate_downstream_samplesheets provides a base template for generating samplesheets by taking a specified input channel of i.e. reads or fasta extracts its metadata for generating samplesheets. + The subworkflow `GENERATE_DOWNSTREAM_SAMPLESHEETS` provides a base template for generating samplesheets by taking a specified input channel of reads or fasta and extracts its metadata for generating samplesheets. nfcore_pipelines: True custom_pipelines: True changelog: From ec27111122dfc6ab00f7d7409a0004b5e88bf48b Mon Sep 17 00:00:00 2001 From: Joon-Klaps Date: Thu, 31 Oct 2024 15:51:54 +0000 Subject: [PATCH 8/8] update to include sarek as example --- .../local/generate_downstream_samplesheets/main.nf | 2 +- .../tests/main.workflow.nf.test | 7 ++++--- .../tests/main.workflow.nf.test.snap | 9 +++++---- nf_core/pipelines/create/template_features.yml | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf index 7b796bd381..ddcd1309c7 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/main.nf @@ -55,7 +55,7 @@ workflow SAMPLESHEET_SAREK { [ patient: patient, sample: sample, lane: lane, fastq_1: fastq_1, fastq_2: fastq_2 ] } - channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/rnaseq", format) + channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/sarek", format) } /* diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test index 4535e8072e..f258ffeb43 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test @@ -7,11 +7,11 @@ nextflow_workflow { tag 'generate_downstream_samplesheets' tag 'subworkflows/generated_downstream_samplesheets' - test("Test worfklow rnaseq") { + test("Test worfklow rnaseq,sarek") { when { params { outdir = "." - generate_pipeline_samplesheets = 'rnaseq' + generate_pipeline_samplesheets = 'rnaseq,sarek' generate_pipeline_samplesheets_format = 'csv' } workflow { @@ -35,7 +35,8 @@ nextflow_workflow { { assert workflow.success }, { assert snapshot( [ - "${params.outdir}/downstream_samplesheets/rnaseq.csv" + "${params.outdir}/downstream_samplesheets/rnaseq.csv", + "${params.outdir}/downstream_samplesheets/sarek.csv" ]).match() } ) diff --git a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap index b81e6155b8..8caf3bc950 100644 --- a/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap +++ b/nf_core/pipeline-template/subworkflows/local/generate_downstream_samplesheets/tests/main.workflow.nf.test.snap @@ -1,14 +1,15 @@ { - "Test worfklow rnaseq": { + "Test worfklow rnaseq,sarek": { "content": [ [ - "./downstream_samplesheets/rnaseq.csv" + "./downstream_samplesheets/rnaseq.csv", + "./downstream_samplesheets/sarek.csv" ] ], "meta": { "nf-test": "0.9.1", "nextflow": "24.10.0" }, - "timestamp": "2024-10-30T09:34:46.912767154" + "timestamp": "2024-10-31T15:44:42.743679838" } -} \ No newline at end of file +} diff --git a/nf_core/pipelines/create/template_features.yml b/nf_core/pipelines/create/template_features.yml index edff8a19ac..f3be4b688c 100644 --- a/nf_core/pipelines/create/template_features.yml +++ b/nf_core/pipelines/create/template_features.yml @@ -287,7 +287,7 @@ downstream_samplesheet: help_text: | The pipeline will include the `GENERATE_DOWNSTREAM_SAMPLESHEETS` subworkflow. - The subworkflow `GENERATE_DOWNSTREAM_SAMPLESHEETS` provides a base template for generating samplesheets by taking a specified input channel of reads or fasta and extracts its metadata for generating samplesheets. + The subworkflow `GENERATE_DOWNSTREAM_SAMPLESHEETS` provides a base template for generating samplesheets by taking a specified input channel, *eg:* reads or fasta, and extracts its metadata for generating samplesheets. nfcore_pipelines: True custom_pipelines: True changelog: