diff --git a/lib/WorkflowScrnaseq.groovy b/lib/Utils.groovy similarity index 100% rename from lib/WorkflowScrnaseq.groovy rename to lib/Utils.groovy diff --git a/modules.json b/modules.json index e1234f4c..805606f5 100644 --- a/modules.json +++ b/modules.json @@ -7,7 +7,7 @@ "nf-core": { "cellranger/count": { "branch": "master", - "git_sha": "575e1bc54b083fb15e7dd8b5fcc40bea60e8ce83", + "git_sha": "a2dfd9a0b2e192243695711c723d652959de39fc", "installed_by": ["modules"] }, "cellranger/mkgtf": { @@ -35,11 +35,6 @@ "git_sha": "4196b1b2e7ce265892f3979eabf7a9ddc030702f", "installed_by": ["modules"] }, - "custom/dumpsoftwareversions": { - "branch": "master", - "git_sha": "8ec825f465b9c17f9d83000022995b4f7de6fe93", - "installed_by": ["modules"] - }, "fastqc": { "branch": "master", "git_sha": "f4ae1d942bd50c5c0b9bd2de1393ce38315ba57c", diff --git a/modules/nf-core/cellranger/count/main.nf b/modules/nf-core/cellranger/count/main.nf index d7a191fc..42aa09c9 100644 --- a/modules/nf-core/cellranger/count/main.nf +++ b/modules/nf-core/cellranger/count/main.nf @@ -32,7 +32,7 @@ process CELLRANGER_COUNT { def prefix = task.ext.prefix ?: "${meta.id}" """ mkdir -p "${prefix}/outs/" - touch ${prefix}/outs/fake_file.txt + echo "$prefix" > ${prefix}/outs/fake_file.txt cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/cellranger/count/meta.yml b/modules/nf-core/cellranger/count/meta.yml index c1f4259a..1f1768a8 100644 --- a/modules/nf-core/cellranger/count/meta.yml +++ b/modules/nf-core/cellranger/count/meta.yml @@ -10,7 +10,8 @@ tools: homepage: https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/what-is-cell-ranger documentation: https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/using/tutorial_ov tool_dev_url: https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/using/tutorial_ov - licence: 10x Genomics EULA + licence: + - 10x Genomics EULA input: - meta: type: map diff --git a/modules/nf-core/cellranger/count/templates/cellranger_count.py b/modules/nf-core/cellranger/count/templates/cellranger_count.py index 1527ba76..53360f23 100644 --- a/modules/nf-core/cellranger/count/templates/cellranger_count.py +++ b/modules/nf-core/cellranger/count/templates/cellranger_count.py @@ -36,7 +36,7 @@ def chunk_iter(seq, size): # do not match "SRR12345", "file_INFIXR12", etc filename_pattern = r'([^a-zA-Z0-9])R1([^a-zA-Z0-9])' -for i, (r1, r2) in enumerate(chunk_iter(fastqs, 2)): +for i, (r1, r2) in enumerate(chunk_iter(fastqs, 2), start=1): # double escapes are required because nextflow processes this python 'template' if re.sub(filename_pattern, r'\\1R2\\2', r1.name) != r2.name: raise AssertionError( diff --git a/modules/nf-core/cellranger/count/tests/main.nf.test b/modules/nf-core/cellranger/count/tests/main.nf.test new file mode 100644 index 00000000..c779b89e --- /dev/null +++ b/modules/nf-core/cellranger/count/tests/main.nf.test @@ -0,0 +1,101 @@ +nextflow_process { + + name "Test Process CELLRANGER_COUNT" + script "../main.nf" + process "CELLRANGER_COUNT" + + tag "modules" + tag "modules_nfcore" + tag "cellranger" + tag "cellranger/count" + tag "cellranger/mkref" + tag "cellranger/mkgtf" + + setup { + config "./nextflow.config" + + run("CELLRANGER_MKGTF") { + script "../../mkgtf/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true) + """ + } + } + run("CELLRANGER_MKREF") { + script "../../mkref/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + input[1] = CELLRANGER_MKGTF.out.gtf + input[2] = "homo_sapiens_chr22_reference" + """ + } + } + } + + test("10x example file") { + config "./nextflow.config" + when { + process { + """ + input[0] = [ + [ id:'test_10x', single_end:false, strandedness:'auto' ], // meta map + [ + file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_1_gz'], checkIfExists: true), + file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_2_gz'], checkIfExists: true) + ] + ] + input[1] = CELLRANGER_MKREF.out.reference + """ + } + } + + then { + assertAll( + { assert process.success }, + { + assert snapshot( + process.out.versions, + process.out.outs[0][1].findAll { file(it).name !in [ + 'web_summary.html', // unstable checksum + 'barcodes.tsv.gz' // empty file in test data -> would raise linting error + ]} + ).match() + }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'web_summary.html' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'barcodes.tsv.gz' }).exists() } + ) + } + + } + + test("10x example file - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test_10x', single_end:false, strandedness:'auto' ], // meta map + [ + file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_1_gz'], checkIfExists: true), + file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_2_gz'], checkIfExists: true) + ] + ] + input[1] = CELLRANGER_MKREF.out.reference + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/cellranger/count/tests/main.nf.test.snap b/modules/nf-core/cellranger/count/tests/main.nf.test.snap new file mode 100644 index 00000000..7eafafd0 --- /dev/null +++ b/modules/nf-core/cellranger/count/tests/main.nf.test.snap @@ -0,0 +1,63 @@ +{ + "10x example file": { + "content": [ + [ + "versions.yml:md5,ec6a0c18d2a8332e42956d07215a657c" + ], + [ + "filtered_feature_bc_matrix.h5:md5,cd440a402b661dc307356057d0dd3348", + "features.tsv.gz:md5,9f93621be0bede2b75596ad255607633", + "matrix.mtx.gz:md5,1736b88199c1dd71e907f9b93becc4f8", + "metrics_summary.csv:md5,c295fe3ccbb6ce118482964ca9c748d4", + "molecule_info.h5:md5,6204ac0b164b6e06e65954d072afe599", + "possorted_genome_bam.bam:md5,32fe604968326d98e8c0c36ce3c5ee8d", + "possorted_genome_bam.bam.bai:md5,e37e792ca1b528e64cd57f7d70dae3ed", + "raw_feature_bc_matrix.h5:md5,8521dbdf077e029ae35e682d746eb79d", + "features.tsv.gz:md5,9f93621be0bede2b75596ad255607633", + "matrix.mtx.gz:md5,6294c0359b29a86ba7b06e07d4b8a134" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-06T09:30:22.104987533" + }, + "10x example file - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test_10x", + "single_end": false, + "strandedness": "auto" + }, + "fake_file.txt:md5,0d98223c768861fd6af96f00148dbb8d" + ] + ], + "1": [ + "versions.yml:md5,30cee1a9146b01c48d9b1db6bbe813b6" + ], + "outs": [ + [ + { + "id": "test_10x", + "single_end": false, + "strandedness": "auto" + }, + "fake_file.txt:md5,0d98223c768861fd6af96f00148dbb8d" + ] + ], + "versions": [ + "versions.yml:md5,30cee1a9146b01c48d9b1db6bbe813b6" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-05T17:16:12.322822411" + } +} \ No newline at end of file diff --git a/modules/nf-core/cellranger/count/tests/nextflow.config b/modules/nf-core/cellranger/count/tests/nextflow.config new file mode 100644 index 00000000..2859b34a --- /dev/null +++ b/modules/nf-core/cellranger/count/tests/nextflow.config @@ -0,0 +1,24 @@ +process { + withName: CELLRANGER_MKGTF { + ext.args = '--attribute=gene_biotype:protein_coding \ + --attribute=gene_biotype:lincRNA \ + --attribute=gene_biotype:antisense \ + --attribute=gene_biotype:IG_LV_gene \ + --attribute=gene_biotype:IG_V_gene \ + --attribute=gene_biotype:IG_V_pseudogene \ + --attribute=gene_biotype:IG_D_gene \ + --attribute=gene_biotype:IG_J_gene \ + --attribute=gene_biotype:IG_J_pseudogene \ + --attribute=gene_biotype:IG_C_gene \ + --attribute=gene_biotype:IG_C_pseudogene \ + --attribute=gene_biotype:TR_V_gene \ + --attribute=gene_biotype:TR_V_pseudogene \ + --attribute=gene_biotype:TR_D_gene \ + --attribute=gene_biotype:TR_J_gene \ + --attribute=gene_biotype:TR_J_pseudogene \ + --attribute=gene_biotype:TR_C_gene' + } + withName: CELLRANGER_COUNT { + ext.args = '--chemistry SC3Pv3' + } +} diff --git a/modules/nf-core/cellranger/count/tests/tags.yml b/modules/nf-core/cellranger/count/tests/tags.yml new file mode 100644 index 00000000..a29a7044 --- /dev/null +++ b/modules/nf-core/cellranger/count/tests/tags.yml @@ -0,0 +1,2 @@ +cellranger/count: + - "modules/nf-core/cellranger/count/**" diff --git a/workflows/scrnaseq.nf b/workflows/scrnaseq.nf index 48b205af..e1db493a 100644 --- a/workflows/scrnaseq.nf +++ b/workflows/scrnaseq.nf @@ -22,7 +22,7 @@ workflow SCRNASEQ { main: - protocol_config = WorkflowScrnaseq.getProtocol(workflow, log, params.aligner, params.protocol) + protocol_config = Utils.getProtocol(workflow, log, params.aligner, params.protocol) if (protocol_config['protocol'] == 'auto' && params.aligner != "cellranger") { error "Only cellranger supports `protocol = 'auto'`. Please specify the protocol manually!" }