-
Notifications
You must be signed in to change notification settings - Fork 221
create template GENERATE_DOWNSTREAM_SAMPLESHEETS for tools #3261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 6 commits
cc970c4
85add1b
f2a4f6b
318ac2f
db70200
34dc6e5
82d97d2
ec27111
f294a45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 %} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
|
|
||
|
|
||
|
|
||
| /* | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| SUBWORKFLOW SPECIFIC FOR RNASEQ | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| */ | ||
|
|
||
| // TODO: Update the following workflow to a specific pipeline | ||
Joon-Klaps marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| workflow SAMPLESHEET_RNASEQ { | ||
| take: | ||
| ch_reads | ||
| format | ||
|
|
||
| main: | ||
|
|
||
| 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] | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we sure we want it to make so genomics specific?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See reply above about pros/cons of example code (maybe with more TODOs. |
||
|
|
||
| channelToSamplesheet(ch_list_for_samplesheet, "${params.outdir}/downstream_samplesheets/rnaseq", format) | ||
| } | ||
|
|
||
| /* | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| SUBWORKFLOW CALLING PIPELINE SPECIFIC SAMPLESHEET GENERATION | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| */ | ||
|
|
||
| workflow GENERATE_DOWNSTREAM_SAMPLESHEETS { | ||
| take: | ||
| input | ||
|
|
||
| main: | ||
| def downstreampipeline_names = params.generate_pipeline_samplesheets.split(",") | ||
|
|
||
| // TODO: Add more pipelines here | ||
| if (downstreampipeline_names.contains('rnaseq')) { | ||
| SAMPLESHEET_RNASEQ( | ||
| 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] | ||
|
|
||
| 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 | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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() } | ||
| ) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| 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', single_end:false ], | ||
| [file('test_1.fastq.gz', checkIfExists: false), file('test_2.fastq.gz', checkIfExists: false)] | ||
| ], | ||
| [ | ||
| [id: 'test-se', single_end: true], | ||
| file('test_1.fastq.gz', checkIfExists: false) | ||
| ] | ||
| ) | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert workflow.success }, | ||
| { assert snapshot( | ||
| [ | ||
| "${params.outdir}/downstream_samplesheets/rnaseq.csv" | ||
| ]).match() | ||
| } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.