diff --git a/modules/nf-core/coptr/index/main.nf b/modules/nf-core/coptr/index/main.nf index 9fce3eb21ab..fa835a68890 100644 --- a/modules/nf-core/coptr/index/main.nf +++ b/modules/nf-core/coptr/index/main.nf @@ -4,8 +4,8 @@ process COPTR_INDEX { conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/coptr:1.1.4--pyhdfd78af_1': - 'biocontainers/coptr:1.1.4--pyhdfd78af_1' }" + 'https://depot.galaxyproject.org/singularity/coptr:1.1.4--pyhdfd78af_3': + 'biocontainers/coptr:1.1.4--pyhdfd78af_3' }" input: tuple val(meta), path(indexfasta, stageAs: "fastafolder/*") @@ -29,6 +29,7 @@ process COPTR_INDEX { --bt2-threads $task.cpus \ fastafolder \ bowtie2/${prefix} + cat <<-END_VERSIONS > versions.yml "${task.process}": coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/') diff --git a/modules/nf-core/coptr/index/tests/main.nf.test b/modules/nf-core/coptr/index/tests/main.nf.test index 8066d370988..80f263e22ea 100644 --- a/modules/nf-core/coptr/index/tests/main.nf.test +++ b/modules/nf-core/coptr/index/tests/main.nf.test @@ -32,29 +32,7 @@ nextflow_process { } - test("coptr index with multiple fastqs") { - - when { - process { - """ - input[0] = [ - [id:'indexNameExample'], - [file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome2.fasta', checkIfExists: true),file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome3.fasta', checkIfExists: true)] - ] - """ - } - } - - then { - assertAll( - { assert process.success }, - { assert snapshot(process.out).match() } - ) - } - - } - - test("coptr index with multiple fastqs - stub") { + test("coptr index with single fastq - stub") { options "-stub" @@ -63,7 +41,7 @@ nextflow_process { """ input[0] = [ [id:'indexNameExample'], - [file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome2.fasta', checkIfExists: true),file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome3.fasta', checkIfExists: true)] + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] """ } @@ -78,5 +56,4 @@ nextflow_process { } - } diff --git a/modules/nf-core/coptr/index/tests/main.nf.test.snap b/modules/nf-core/coptr/index/tests/main.nf.test.snap index fb0aded4c13..153e003fc37 100644 --- a/modules/nf-core/coptr/index/tests/main.nf.test.snap +++ b/modules/nf-core/coptr/index/tests/main.nf.test.snap @@ -43,12 +43,12 @@ } ], "meta": { - "nf-test": "0.9.1", + "nf-test": "0.9.2", "nextflow": "24.10.0" }, - "timestamp": "2024-11-01T15:20:08.028567181" + "timestamp": "2024-11-15T13:37:15.478846" }, - "coptr index with multiple fastqs - stub": { + "coptr index with single fastq - stub": { "content": [ { "0": [ @@ -92,58 +92,9 @@ } ], "meta": { - "nf-test": "0.9.1", + "nf-test": "0.9.2", "nextflow": "24.10.0" }, - "timestamp": "2024-11-01T15:28:00.318435045" - }, - "coptr index with multiple fastqs": { - "content": [ - { - "0": [ - [ - { - "id": "indexNameExample" - }, - [ - "indexNameExample.1.bt2:md5,e88e383183a9dec8dd453b04dc89a903", - "indexNameExample.2.bt2:md5,ae84a18d674ecc823c82188f5ca1ffc9", - "indexNameExample.3.bt2:md5,702fe6c79ef7bc9b54b3661f2f4aaa0b", - "indexNameExample.4.bt2:md5,a2234db869afc50b40f7e7d1289f5f0b", - "indexNameExample.genomes:md5,d4ed161da3cf2ced8e7c66c0c90e8d3e", - "indexNameExample.rev.1.bt2:md5,75d78b73949d636ec9750269a5ea1c8b", - "indexNameExample.rev.2.bt2:md5,39a1186f6aad701a71d773074408b51e" - ] - ] - ], - "1": [ - "versions.yml:md5,6013eeb9d8ac97351260150f44091986" - ], - "index_dir": [ - [ - { - "id": "indexNameExample" - }, - [ - "indexNameExample.1.bt2:md5,e88e383183a9dec8dd453b04dc89a903", - "indexNameExample.2.bt2:md5,ae84a18d674ecc823c82188f5ca1ffc9", - "indexNameExample.3.bt2:md5,702fe6c79ef7bc9b54b3661f2f4aaa0b", - "indexNameExample.4.bt2:md5,a2234db869afc50b40f7e7d1289f5f0b", - "indexNameExample.genomes:md5,d4ed161da3cf2ced8e7c66c0c90e8d3e", - "indexNameExample.rev.1.bt2:md5,75d78b73949d636ec9750269a5ea1c8b", - "indexNameExample.rev.2.bt2:md5,39a1186f6aad701a71d773074408b51e" - ] - ] - ], - "versions": [ - "versions.yml:md5,6013eeb9d8ac97351260150f44091986" - ] - } - ], - "meta": { - "nf-test": "0.9.1", - "nextflow": "24.10.0" - }, - "timestamp": "2024-11-01T15:24:04.847842182" + "timestamp": "2024-11-15T13:37:21.536745" } } \ No newline at end of file diff --git a/modules/nf-core/coptr/map/environment.yml b/modules/nf-core/coptr/map/environment.yml new file mode 100644 index 00000000000..c5a150067f6 --- /dev/null +++ b/modules/nf-core/coptr/map/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/map/main.nf b/modules/nf-core/coptr/map/main.nf new file mode 100644 index 00000000000..9ac0160f69b --- /dev/null +++ b/modules/nf-core/coptr/map/main.nf @@ -0,0 +1,61 @@ +process COPTR_MAP { + 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(fasta, stageAs: "fastafolder/*") + tuple val(meta2), path(index) + + output: + tuple val(meta), path("*.bam"), emit: bam + 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 prefix2 = task.ext.prefix ?: "${meta2.id}" + + def paired_end = "" + if ( ! meta.single_end ) { + paired_end = "--paired" + } + """ + INDEX=`find -L ./ -name "*.rev.1.bt2" | sed "s/\\.rev.1.bt2\$//"` + [ -z "\$INDEX" ] && INDEX=`find -L ./ -name "*.rev.1.bt2l" | sed "s/\\.rev.1.bt2l\$//"` + [ -z "\$INDEX" ] && echo "Bowtie2 index files not found" 1>&2 && exit 1 + + coptr \ + map \ + $args $paired_end \ + --threads $task.cpus \ + \$INDEX \ + fastafolder \ + . + + mv ${prefix}.bam ${prefix}_${prefix2}.bam + cat <<-END_VERSIONS > versions.yml + "${task.process}": + coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/') + END_VERSIONS + """ +} diff --git a/modules/nf-core/coptr/map/meta.yml b/modules/nf-core/coptr/map/meta.yml new file mode 100644 index 00000000000..706fbd661e6 --- /dev/null +++ b/modules/nf-core/coptr/map/meta.yml @@ -0,0 +1,63 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "coptr_map" +description: Maps the reads to the reference database +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 ]` + - fasta: + type: file + description: fastq file with reads + pattern: "*.{.fastq,.fq,.fastq.gz,fq.gz}" + ontologies: + - edam: "http://edamontology.org/format_1929" + - - meta2: + type: map + description: | + Groovy Map containing index genome id and path + e.g. [ id:'test', 'bowtie2' ] + - index: + type: file + description: Directory with Bowtie2 genome index files + pattern: "*.ebwt" + +output: + - bam: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*.bam": + type: file + description: Alignment (BAM) file of reads mapped to the reference database + pattern: "*.{bam}" + ontologies: + - edam: "http://edamontology.org/format_2572" + - versions: + - "versions.yml": + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@ramirobarrantes" +maintainers: + - "@ramirobarrantes" diff --git a/modules/nf-core/coptr/map/tests/main.nf.test b/modules/nf-core/coptr/map/tests/main.nf.test new file mode 100644 index 00000000000..e83705d0296 --- /dev/null +++ b/modules/nf-core/coptr/map/tests/main.nf.test @@ -0,0 +1,106 @@ +nextflow_process { + + name "Test Process COPTR_MAP" + script "../main.nf" + process "COPTR_MAP" + + tag "modules" + tag "modules_nfcore" + tag "coptr" + tag "coptr/index" + tag "coptr/map" + + setup { + run("COPTR_INDEX") { + script "../../index/main.nf" + process { + """ + input[0] = [ + [id:'test_0'], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + ] + """ + } + } + } + + test("sarscov2 - single end test") { + + when { + process { + """ + input[0] = [ + [ id:'test_1', single_end: true ], + file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true) + ] + input[1] = COPTR_INDEX.out.index_dir + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.bam.collect{bam(it[1]).getReads(10)}, + process.out.bam.collect{bam(it[1]).getStatistics(include:["readCount"])}, + process.out.versions + ).match() } + ) + } + } + + test("sarscov2 - paired end") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end: false ], + [ + file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true), + file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_2.fastq.gz", checkIfExists: true) + ] + ] + input[1] = COPTR_INDEX.out.index_dir + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.bam.collect{bam(it[1]).getStatistics(include:["readCount"])}, + process.out.versions + ).match() } + ) + } + } + + + test("sarscov2 - single end - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test', single_end: true ], + file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true) + ] + input[1] = COPTR_INDEX.out.index_dir + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + +} diff --git a/modules/nf-core/coptr/map/tests/main.nf.test.snap b/modules/nf-core/coptr/map/tests/main.nf.test.snap new file mode 100644 index 00000000000..270dd0a2763 --- /dev/null +++ b/modules/nf-core/coptr/map/tests/main.nf.test.snap @@ -0,0 +1,85 @@ +{ + "sarscov2 - paired end": { + "content": [ + [ + { + "readCount": 199 + } + ], + [ + "versions.yml:md5,d7e891e5b88fc649964fb69e018346f7" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.0" + }, + "timestamp": "2024-11-15T12:26:49.184174" + }, + "sarscov2 - single end test": { + "content": [ + [ + [ + "ACGCACATTGCTAACTAAGGGCACACTAGAACCAGAATATTTCAATTCAGTGTGTAGACTTATGAAAACTATAGGTCCAGACATGTTCCTCGGAACTTGTCGGCGTTGTCCTGCTGAAATTGTTGACACTGTGAGTGCTTTGGTTTATGA", + "GCATAGACGGTGCTTTACTTACAAAGTCCTCAGAATACAAAGGTCCTATTACGGATGTTTTCTACAAAGAAAACAGT", + "TAGGTGAGTTAGGTGATGTTAGAGAAACAATGAGTTACTTGTTTCAACATGCCAATTTAGATTCTTGCAAAAGAGTCTTGAACGTGGTGTGTAAAACTTGTGGACAACAGCAGACAACCCTTAAGGGTGTAGAAGCTGTTATGTAC", + "GTCTACAAGCTGGTAATGCAACAGAAGTGCCTGCCAATTCAACTGTATTATCTTTCTGTGCTTTTGCTGTAGATGCTGCTAAAGCTTACAAAGATTATCTAGCTAGTGGGGGACAACCAATCACTAATTGTG", + "AACCAGAATATTTCAATTCAGTGTGTAGACTTATGAAAACTATAGGTCCAGACATGTTCCTCGGAACTTGTCGGCGTTGT", + "ACTTTCCAAAGTGCAGTCAAAAGAACAATCACGGGTACACACCACTGGTTGTTACTCACAATTTTGACTTCACTTTTAG", + "CCTGTTGTCTATGTGATAGACGTGCCACATGCTTTTCCACTGCTTCAGACACTTATGCCTGTTGGCATCATTCTATTGGATTTGATTACGTCTATAATCCGTTTATGATTGATGTTCAACAATGGGGTTTTACAGGTAACCTACAAAGCA", + "GCTCCATATATAGTGGGTGATGTTGTTCAAGAGGGTGTTTTAACTGCTGTGGTTATACCTACTAAAAAGGCTGGTGGCACTACTGAAATGCTAGCGAAAGCTTTGAGAAAAGTGCCAACAGACAATTATATAACCACTTACCCGGGTCAGG", + "CAGTAGTCTTACTCTCAGTTTTGCAACAACTCAGAGTAGAATCATCATCTAAATTGTGGGCTCAATGTGTCCAGTTACACAATGACATTCTCTTAGCTAAAGATACTACTGAATCCTTTGAAAAAAAGGTTTCACTACTTTCGGTTTTG", + "CCTTATGACAGCAAGAACTGTGTATGATGATGGTGCTAGGAGAGTGTGGACACTTATGAATGTCTTGACACTCGTTTATAAAGTTTATTATGGTAATGCTTTAGATCAAGCCATTTCCATGTGGGCTCTTATAATCTCTGTTACTTC" + ] + ], + [ + { + "readCount": 99 + } + ], + [ + "versions.yml:md5,d7e891e5b88fc649964fb69e018346f7" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.0" + }, + "timestamp": "2024-11-15T12:26:38.489728" + }, + "sarscov2 - single end - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": true + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,d7e891e5b88fc649964fb69e018346f7" + ], + "bam": [ + [ + { + "id": "test", + "single_end": true + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,d7e891e5b88fc649964fb69e018346f7" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.0" + }, + "timestamp": "2024-11-15T12:13:16.796608" + } +} \ No newline at end of file diff --git a/nf-test.config b/nf-test.config index e0967518457..d67ea493bab 100644 --- a/nf-test.config +++ b/nf-test.config @@ -13,7 +13,7 @@ config { // load the necessary plugins plugins { - load "nft-bam@0.3.0" + load "nft-bam@0.5.0" load "nft-compress@0.1.0" load "nft-vcf@1.0.7" }