From 14360292311aef207764456091073fc10a780fc0 Mon Sep 17 00:00:00 2001 From: Chris Wyatt <9978862+chriswyatt1@users.noreply.github.com> Date: Thu, 6 Feb 2025 14:49:52 +0000 Subject: [PATCH] WIP: New Module: Pychopper (#7438) * WIP- add pychopper * meta yml complete * Test and snap * Add stub gzipped format, working version * try remove all blank entries in meta yml * linted * Update main.nf add version as def var --- modules/nf-core/pychopper/environment.yml | 7 ++ modules/nf-core/pychopper/main.nf | 52 ++++++++++++++ modules/nf-core/pychopper/meta.yml | 54 +++++++++++++++ modules/nf-core/pychopper/tests/main.nf.test | 69 +++++++++++++++++++ .../nf-core/pychopper/tests/main.nf.test.snap | 42 +++++++++++ 5 files changed, 224 insertions(+) create mode 100644 modules/nf-core/pychopper/environment.yml create mode 100644 modules/nf-core/pychopper/main.nf create mode 100644 modules/nf-core/pychopper/meta.yml create mode 100644 modules/nf-core/pychopper/tests/main.nf.test create mode 100644 modules/nf-core/pychopper/tests/main.nf.test.snap diff --git a/modules/nf-core/pychopper/environment.yml b/modules/nf-core/pychopper/environment.yml new file mode 100644 index 00000000000..6b530615c1b --- /dev/null +++ b/modules/nf-core/pychopper/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::pychopper=2.7.10" diff --git a/modules/nf-core/pychopper/main.nf b/modules/nf-core/pychopper/main.nf new file mode 100644 index 00000000000..dea2d0f0d6e --- /dev/null +++ b/modules/nf-core/pychopper/main.nf @@ -0,0 +1,52 @@ +process PYCHOPPER { + 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/pychopper:2.7.10--pyhdfd78af_0': + 'biocontainers/pychopper:2.7.10--pyhdfd78af_0' }" + + input: + tuple val(meta), path(fastq) + + output: + tuple val(meta), path("*.out.fastq.gz"), emit: fastq + 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}" + def PYCHOPPER_VERSION = '2.7.10' + + """ + pychopper \\ + $args \\ + -t $task.cpus \\ + $fastq \\ + ${prefix}.out.fastq + + gzip -f ${prefix}.out.fastq > ${prefix}.out.fastq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pychopper: $PYCHOPPER_VERSION (hard coded- check container used for this module) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.out.fastq + gzip ${prefix}.out.fastq + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pychopper: 2.7.10 (hard coded- check container used for this module) + END_VERSIONS + """ +} diff --git a/modules/nf-core/pychopper/meta.yml b/modules/nf-core/pychopper/meta.yml new file mode 100644 index 00000000000..e405e893897 --- /dev/null +++ b/modules/nf-core/pychopper/meta.yml @@ -0,0 +1,54 @@ +name: "pychopper" +description: Identify, orient and trim nanopore cDNA reads +keywords: + - sort + - trimming + - nanopore +tools: + - "pychopper": + description: "A tool to identify, orient and rescue full length cDNA reads from + nanopore data." + homepage: "https://github.com/epi2me-labs/pychopper" + documentation: "https://github.com/epi2me-labs/pychopper" + tool_dev_url: "https://github.com/epi2me-labs/pychopper" + licence: ["Oxford Nanopore Technologies PLC. Public License Version 1.0"] + identifier: "" + - "gzip": + description: "Gzip reduces the size of the named files using Lempel-Ziv coding + (LZ77)." + documentation: "https://linux.die.net/man/1/gzip" + args_id: "$args3" + identifier: "" +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - fastq: + type: file + description: FastQ with reads from long read sequencing e.g. nanopore + pattern: "*.{fastq.gz}" +output: + - fastq: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + pattern: "*.{fastq.gz}" + - "*.out.fastq.gz": + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + pattern: "*.{fastq.gz}" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@chriswyatt1" +maintainers: + - "@chriswyatt1" diff --git a/modules/nf-core/pychopper/tests/main.nf.test b/modules/nf-core/pychopper/tests/main.nf.test new file mode 100644 index 00000000000..c86ec7e942b --- /dev/null +++ b/modules/nf-core/pychopper/tests/main.nf.test @@ -0,0 +1,69 @@ +nextflow_process { + + name "Test Process PYCHOPPER" + script "../main.nf" + process "PYCHOPPER" + tag "pychopper" + tag "modules" + tag "modules_nfcore" + + test("pychopper-test") { + + when { + params { + outdir = "$outputDir" + } + process { + """ + input[0] = [ + [id:'test_out' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/nanopore/fastq/test_2.fastq.gz', checkIfExists: true) + ] + """ + } + } + + then { + + def fastq_content = path(process.out.fastq.get(0).get(1)).linesGzip + + assertAll( + { assert process.success }, + // original pytest checks + { assert process.out.fastq.get(0).get(1) ==~ ".*/test_out.out.fastq.gz" }, + // additional nf-test checks + // Order of reads is not deterministic, so only assess whether the number of reads is correct + { assert snapshot( + process.out.fastq, + process.out.versions + ).match() } + ) + } + } + + test("test-pychopper-stub") { + options '-stub' + + when { + process { + """ + input[0] = [ + [id:'test_out' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/nanopore/fastq/test.fastq.gz', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.fastq, + process.out.versions + ).match() } + ) + } + } + +} diff --git a/modules/nf-core/pychopper/tests/main.nf.test.snap b/modules/nf-core/pychopper/tests/main.nf.test.snap new file mode 100644 index 00000000000..c94ecdba34e --- /dev/null +++ b/modules/nf-core/pychopper/tests/main.nf.test.snap @@ -0,0 +1,42 @@ +{ + "pychopper-test": { + "content": [ + [ + [ + { + "id": "test_out" + }, + "test_out.out.fastq.gz:md5,04f3003f5cb5a78d90cae351beacb094" + ] + ], + [ + "versions.yml:md5,1431ed95e3c77f8742c7b014b26e50f5" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-02-05T13:57:08.581810556" + }, + "test-pychopper-stub": { + "content": [ + [ + [ + { + "id": "test_out" + }, + "test_out.out.fastq.gz:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + [ + "versions.yml:md5,1431ed95e3c77f8742c7b014b26e50f5" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-02-05T15:09:38.47491875" + } +} \ No newline at end of file