From f25bd4b911254bbbd4b5a1d434bed2a90a056927 Mon Sep 17 00:00:00 2001 From: Ramiro Date: Tue, 3 Dec 2024 01:52:43 -0500 Subject: [PATCH] New module: COPTR/EXTRACT (#7089) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial addition * Updated snapshot, removed obsolete snapshots * Update modules/nf-core/coptr/extract/tests/main.nf.test Added stub Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> * Update modules/nf-core/coptr/extract/main.nf Added stub Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> * Update modules/nf-core/coptr/extract/main.nf Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> * Updated stub * Updated snapshot * Update modules/nf-core/coptr/extract/main.nf Added .pkl extension Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Updated snapshot --------- Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> --- modules/nf-core/coptr/extract/environment.yml | 7 ++ modules/nf-core/coptr/extract/main.nf | 48 ++++++++ modules/nf-core/coptr/extract/meta.yml | 56 +++++++++ .../nf-core/coptr/extract/tests/main.nf.test | 86 ++++++++++++++ .../coptr/extract/tests/main.nf.test.snap | 107 ++++++++++++++++++ 5 files changed, 304 insertions(+) create mode 100644 modules/nf-core/coptr/extract/environment.yml create mode 100644 modules/nf-core/coptr/extract/main.nf create mode 100644 modules/nf-core/coptr/extract/meta.yml create mode 100644 modules/nf-core/coptr/extract/tests/main.nf.test create mode 100644 modules/nf-core/coptr/extract/tests/main.nf.test.snap diff --git a/modules/nf-core/coptr/extract/environment.yml b/modules/nf-core/coptr/extract/environment.yml new file mode 100644 index 00000000000..c5a150067f6 --- /dev/null +++ b/modules/nf-core/coptr/extract/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::coptr=1.1.4" diff --git a/modules/nf-core/coptr/extract/main.nf b/modules/nf-core/coptr/extract/main.nf new file mode 100644 index 00000000000..2633c3907e2 --- /dev/null +++ b/modules/nf-core/coptr/extract/main.nf @@ -0,0 +1,48 @@ +process COPTR_EXTRACT { + 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/coptr:1.1.4--pyhdfd78af_3': + 'biocontainers/coptr:1.1.4--pyhdfd78af_3' }" + + input: + tuple val(meta), path(bam, stageAs: "bamfolder/*") + + output: + tuple val(meta), path("*.pkl"), emit: coverage + 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}" + + """ + coptr \\ + extract \\ + $args \\ + bamfolder/ \\ + . + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/') + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.pkl + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + "${task.process}": + coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/') + END_VERSIONS + """ +} diff --git a/modules/nf-core/coptr/extract/meta.yml b/modules/nf-core/coptr/extract/meta.yml new file mode 100644 index 00000000000..753bc041f1b --- /dev/null +++ b/modules/nf-core/coptr/extract/meta.yml @@ -0,0 +1,56 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "coptr_extract" +description: Computes the coverage map along the reference genome +keywords: + - coptr + - mapping + - ptr +tools: + - "coptr": + description: "Accurate and robust inference of microbial growth dynamics from + metagenomic sequencing reads." + homepage: "https://github.com/tyjo/coptr" + documentation: "https://coptr.readthedocs.io/" + tool_dev_url: "https://github.com/tyjo/coptr" + doi: "10.1101/gr.275533.121" + licence: ["GPL v3"] + identifier: biotools:coptr + +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - bam: + type: file + description: bam file with the mapping of the reads on the reference genome + pattern: "*.{.bam}" + ontologies: + - edam: "http://edamontology.org/format_2572" + +output: + - coverage: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*.pkl": + type: file + description: Python pickle (pkl) file containing coverage along the reference genome + pattern: "*.{pkl}" + ontologies: + - edam: "http://edamontology.org/format_4002" + + - versions: + - "versions.yml": + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@ramirobarrantes" +maintainers: + - "@ramirobarrantes" diff --git a/modules/nf-core/coptr/extract/tests/main.nf.test b/modules/nf-core/coptr/extract/tests/main.nf.test new file mode 100644 index 00000000000..d2934218a83 --- /dev/null +++ b/modules/nf-core/coptr/extract/tests/main.nf.test @@ -0,0 +1,86 @@ +nextflow_process { + + name "Test Process COPTR_EXTRACT" + script "../main.nf" + process "COPTR_EXTRACT" + + tag "modules" + tag "modules_nfcore" + tag "coptr" + tag "coptr/extract" + + + test("coptr extract single bam file") { + + when { + process { + """ + input[0] = [ + [id:'indexNameExample'], + [ file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() + } + ) + } + + } + + test("coptr extract two bam files") { + + when { + process { + """ + input[0] = [ + [id:'indexNameExample'], + [ file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.single_end.bam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() + } + ) + } + } + + test("coptr extract single bam file - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [id:'indexNameExample'], + [ file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() + } + ) + } + + } +} diff --git a/modules/nf-core/coptr/extract/tests/main.nf.test.snap b/modules/nf-core/coptr/extract/tests/main.nf.test.snap new file mode 100644 index 00000000000..1fb2eeb35ad --- /dev/null +++ b/modules/nf-core/coptr/extract/tests/main.nf.test.snap @@ -0,0 +1,107 @@ +{ + "coptr extract two bam files": { + "content": [ + { + "0": [ + [ + { + "id": "indexNameExample" + }, + [ + "test.paired_end.sorted.cm.pkl:md5,c60bb7cb7cba50898c95b2406516ec5f", + "test.single_end.cm.pkl:md5,128ae12d6548a0640ddace5fc7a7eea8" + ] + ] + ], + "1": [ + "versions.yml:md5,c6fcaf8fb6aa9c10a3192d81f9623d4f" + ], + "coverage": [ + [ + { + "id": "indexNameExample" + }, + [ + "test.paired_end.sorted.cm.pkl:md5,c60bb7cb7cba50898c95b2406516ec5f", + "test.single_end.cm.pkl:md5,128ae12d6548a0640ddace5fc7a7eea8" + ] + ] + ], + "versions": [ + "versions.yml:md5,c6fcaf8fb6aa9c10a3192d81f9623d4f" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.1" + }, + "timestamp": "2024-11-25T16:06:26.239512" + }, + "coptr extract single bam file": { + "content": [ + { + "0": [ + [ + { + "id": "indexNameExample" + }, + "test.paired_end.sorted.cm.pkl:md5,c60bb7cb7cba50898c95b2406516ec5f" + ] + ], + "1": [ + "versions.yml:md5,c6fcaf8fb6aa9c10a3192d81f9623d4f" + ], + "coverage": [ + [ + { + "id": "indexNameExample" + }, + "test.paired_end.sorted.cm.pkl:md5,c60bb7cb7cba50898c95b2406516ec5f" + ] + ], + "versions": [ + "versions.yml:md5,c6fcaf8fb6aa9c10a3192d81f9623d4f" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.1" + }, + "timestamp": "2024-11-25T16:04:59.852647" + }, + "coptr extract single bam file - stub": { + "content": [ + { + "0": [ + [ + { + "id": "indexNameExample" + }, + "indexNameExample.pkl:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,578f185b99f7f5ba27eb2a9f44c1d6a9" + ], + "coverage": [ + [ + { + "id": "indexNameExample" + }, + "indexNameExample.pkl:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,578f185b99f7f5ba27eb2a9f44c1d6a9" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-02T19:26:21.856688" + } +} \ No newline at end of file