diff --git a/main.nf b/main.nf index e7e9c5f..fef5585 100644 --- a/main.nf +++ b/main.nf @@ -96,7 +96,7 @@ workflow { NFCORE_TBANALYZER.out.multiqc_report ) } - +// Everything seemed okay /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ THE END diff --git a/modules/tbpore/modules/local/tbpore_cluster/main.nf b/modules/tbpore/modules/local/tbpore_cluster/main.nf new file mode 100644 index 0000000..6046889 --- /dev/null +++ b/modules/tbpore/modules/local/tbpore_cluster/main.nf @@ -0,0 +1,47 @@ +process TBPORE_CLUSTER { + tag "$meta.id" + label 'process_low' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/tbpore:0.7.1--pyhdfd78af_0': + 'biocontainers/tbpore:0.7.1--pyhdfd78af_0' }" + + input: + tuple val(meta), path(consensus_fa) + + output: + + tuple val(meta), path("*.txt"), emit: txt + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + + """ + tbpore cluster $args \\ + --threads $task.cpus \\ + $consensus_fa + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + tbpore: \$(tbpore --version |& sed s/tbpore, version //') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + touch ${prefix}.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + tbpore: \$(tbpore --version |& sed s/tbpore, version //') + END_VERSIONS + """ +} diff --git a/modules/tbpore/modules/local/tbpore_cluster/tests/main.nf.test b/modules/tbpore/modules/local/tbpore_cluster/tests/main.nf.test new file mode 100644 index 0000000..0e591dc --- /dev/null +++ b/modules/tbpore/modules/local/tbpore_cluster/tests/main.nf.test @@ -0,0 +1,55 @@ +nextflow_process { + + name "Test Process TBPORE_CLUSTER" + script "../main.nf" + process "TBPORE_CLUSTER" + + setup { + run("TBPORE_PROCESS") { + script "../../tbpore_process/main.nf" + + params { + modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/' + } + + process { + """ + + input[0] = Channel.of([ + [ id:'test', single_end:true ], + file( + params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + checkIfExists: true + ) + ]) + + input[1] = Channel.of( + file("/.tbpore/decontamination_db/remove_contam.map-ont.mmi") + ) + """ + } + } + } + + test("sarscov2 single end [fastq]") { + + when { + params { + // define parameters here. Example: + outdir = "tests/results" + } + process { + """ + // input[0] = TBPORE_PROCESS.out.fa | collect + """ + } + } + + then { + assert process.success + assert snapshot(process.out).match() + } + + } + +} diff --git a/modules/tbpore/modules/local/tbpore_process/main.nf b/modules/tbpore/modules/local/tbpore_process/main.nf new file mode 100644 index 0000000..f6a4d66 --- /dev/null +++ b/modules/tbpore/modules/local/tbpore_process/main.nf @@ -0,0 +1,61 @@ + +process TBPORE_PROCESS { + tag "$meta.id" + label 'process_low' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/tbpore:0.7.1--pyhdfd78af_0': + 'biocontainers/tbpore:0.7.1--pyhdfd78af_0' }" + + input: + tuple val(meta), path(fastq) + path db + + output: + tuple val(meta), path("*.json"), emit: json + tuple val(meta), path("*.fa") , emit: fa + tuple val(meta), path("*.bcf") , emit: bcf + tuple val(meta), path("*.txt") , emit: txt + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + tbpore process $args \\ + --threads $task.cpus \\ + --name $prefix \\ + --db $db \\ + $fastq + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + tbpore: \$(tbpore --version |& sed s/tbpore, version //') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + // TODO nf-core: A stub section should mimic the execution of the original module as best as possible + // Have a look at the following examples: + // Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63 + // Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54 + """ + touch ${prefix}.json + touch ${prefix}.fa + touch ${prefix}.bcf + touch ${prefix}.txt + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + tbpore: \$(tbpore --version |& sed s/tbpore, version //') + END_VERSIONS + """ +} diff --git a/modules/tbpore/modules/local/tbpore_process/tests/main.nf.test b/modules/tbpore/modules/local/tbpore_process/tests/main.nf.test new file mode 100644 index 0000000..25eb488 --- /dev/null +++ b/modules/tbpore/modules/local/tbpore_process/tests/main.nf.test @@ -0,0 +1,43 @@ +nextflow_process { + + name "Test Process TBPORE_PROCESS" + script "../main.nf" + process "TBPORE_PROCESS" + + tag TBPORE_PROCESS + + test("sarscov2 single end fastq") { + + when { + params { + //define parameters here. Example: + modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/' + outdir = "tests/results" + } + process { + """ + input[0] = Channel.of([ + [ id:'test', single_end:true ], + file( + params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', + checkIfExists: true + ) + ]) + input[1] = Channel.fromPath( + file("/.tbpore/decontamination_db/remove_contam.map-ont.mmi") + ) + """ + } + } + + then { + assertAll( + + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/tbpore/modules/local/tbpore_process/tests/main.nf.test.snap b/modules/tbpore/modules/local/tbpore_process/tests/main.nf.test.snap new file mode 100644 index 0000000..ca2413c --- /dev/null +++ b/modules/tbpore/modules/local/tbpore_process/tests/main.nf.test.snap @@ -0,0 +1,43 @@ +{ + "real data fastq": { + "content": [ + { + "0": [ + + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "bcf": [ + + ], + "fa": [ + + ], + "json": [ + + ], + "txt": [ + + ], + "versions": [ + + ] + } + ], + "meta": { + "nf-test": "0.9.1", + "nextflow": "24.04.4" + }, + "timestamp": "2024-11-03T12:51:08.385030023" + } +} \ No newline at end of file diff --git a/nf-test.config b/nf-test.config new file mode 100644 index 0000000..870799d --- /dev/null +++ b/nf-test.config @@ -0,0 +1,8 @@ +config { + + testsDir "tests" + workDir ".nf-test" + configFile "tests/nextflow.config" + profile "" + +} diff --git a/tests/nextflow.config b/tests/nextflow.config new file mode 100644 index 0000000..c19b1ad --- /dev/null +++ b/tests/nextflow.config @@ -0,0 +1,5 @@ +/* +======================================================================================== + Nextflow config file for running tests +======================================================================================== +*/