diff --git a/modules/nf-core/pbcpgtools/alignedbamtocpgscores/environment.yml b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/environment.yml new file mode 100644 index 00000000000..21ff53b2f00 --- /dev/null +++ b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/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::pb-cpg-tools=3.0.0" diff --git a/modules/nf-core/pbcpgtools/alignedbamtocpgscores/main.nf b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/main.nf new file mode 100644 index 00000000000..bba19efad97 --- /dev/null +++ b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/main.nf @@ -0,0 +1,61 @@ +process PBCPGTOOLS_ALIGNEDBAMTOCPGSCORES { + tag "$meta.id" + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/pb-cpg-tools:3.0.0--h9ee0642_0': + 'biocontainers/pb-cpg-tools:3.0.0--h9ee0642_0' }" + + input: + tuple val(meta), path(bam), path(bai) + + output: + tuple val(meta), path("*.bed.gz"), emit: bed + tuple val(meta), path("*.bed.gz.tbi"), emit: bed_index + tuple val(meta), path("*.bw"), emit: bigwig + 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}" + + """ + aligned_bam_to_cpg_scores \\ + --bam ${bam} \\ + --output-prefix ${prefix} \\ + --threads ${task.cpus} \\ + ${args} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pbcpgtools: \$(aligned_bam_to_cpg_scores --version | sed 's/aligned_bam_to_cpg_scores //') + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + + echo "" | gzip > ${prefix}.combined.bed.gz + touch ${prefix}.combined.bed.gz.tbi + touch ${prefix}.combined.bw + + echo "" | gzip > ${prefix}.hap1.bed.gz + touch ${prefix}.hap1.bed.gz.tbi + touch ${prefix}.hap1.bw + + echo "" | gzip > ${prefix}.hap2.bed.gz + touch ${prefix}.hap2.bed.gz.tbi + touch ${prefix}.hap2.bw + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pbcpgtools: \$(aligned_bam_to_cpg_scores --version | sed 's/aligned_bam_to_cpg_scores //') + END_VERSIONS + """ +} diff --git a/modules/nf-core/pbcpgtools/alignedbamtocpgscores/meta.yml b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/meta.yml new file mode 100644 index 00000000000..38a67841742 --- /dev/null +++ b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/meta.yml @@ -0,0 +1,77 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "pbcpgtools_alignedbamtocpgscores" +description: Converts aligned BAM files into CpG methylation scores using pb-cpg-tools. +keywords: + - methylation + - cpg + - pacbio +tools: + - "pbcpgtools": + description: "Collection of tools for the analysis of CpG data" + homepage: "https://github.com/PacificBiosciences/pb-CpG-tools" + documentation: "https://github.com/PacificBiosciences/pb-CpG-tools#readme" + tool_dev_url: "https://github.com/PacificBiosciences/pb-CpG-tools" + licence: ["Pacific Biosciences Software License Agreement"] + +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - bam: + type: file + description: BAM/CRAM file + pattern: "*.{bam,cram}" + ontologies: [] + - bai: + type: file + description: Index of BAM/CRAM file + pattern: "*.{bai,crai,csi}" + ontologies: [] + +output: + bed: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - "*.bed.gz": + type: file + description: Zipped BED file with CpG methylation scores + pattern: "*.{bed.gz}" + ontologies: [] + bed_index: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - "*.bed.gz.tbi": + type: file + description: Index of zipped BED file + pattern: "*.{.bed.gz.tbi}" + ontologies: [] + bigwig: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - "*.bw": + type: file + description: Bigwig file for visualization in IGV + pattern: "*.{bw}" + ontologies: [] + versions: + - "versions.yml": + type: file + description: File containing software versions + pattern: "versions.yml" + ontologies: [] + +authors: + - "@inemesb" +maintainers: + - "@inemesb" diff --git a/modules/nf-core/pbcpgtools/alignedbamtocpgscores/tests/main.nf.test b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/tests/main.nf.test new file mode 100644 index 00000000000..48a17fdcfd2 --- /dev/null +++ b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/tests/main.nf.test @@ -0,0 +1,88 @@ +nextflow_process { + + name "Test Process PBCPGTOOLS_ALIGNEDBAMTOCPGSCORES" + script "../main.nf" + process "PBCPGTOOLS_ALIGNEDBAMTOCPGSCORES" + + tag "modules" + tag "modules_nfcore" + tag "pbcpgtools" + tag "pbcpgtools/alignedbamtocpgscores" + + test("pacbio - bam - notphased") { + + when { + process { + """ + + input[0] = [ + [ id:'test'], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/NA037562_downsampled.pbmm2.repeats.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/NA037562_downsampled.pbmm2.repeats.bam.bai', checkIfExists: true) + + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("pacbio - bam - phased") { + + when { + process { + """ + + input[0] = [ + [ id:'test'], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/NA037562_downsampled.pbmm2.repeats.phased.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/NA037562_downsampled.pbmm2.repeats.phased.bam.bai', checkIfExists: true) + + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("pacbio - bam - phased - stub") { + + options "-stub" + + when { + process { + """ + + input[0] = [ + [ id:'test'], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/NA037562_downsampled.pbmm2.repeats.phased.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/NA037562_downsampled.pbmm2.repeats.phased.bam.bai', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/pbcpgtools/alignedbamtocpgscores/tests/main.nf.test.snap b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/tests/main.nf.test.snap new file mode 100644 index 00000000000..70fd97e5a76 --- /dev/null +++ b/modules/nf-core/pbcpgtools/alignedbamtocpgscores/tests/main.nf.test.snap @@ -0,0 +1,245 @@ +{ + "pacbio - bam - notphased": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.combined.bed.gz:md5,bacdb71f8eec683930c6103f020277cd" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.combined.bed.gz.tbi:md5,9ca5efde7981fec4e6a79b0b08999186" + ] + ], + "2": [ + [ + { + "id": "test" + }, + "test.combined.bw:md5,77a572a00645df6743459805bd397cb9" + ] + ], + "3": [ + "versions.yml:md5,e77c5038eded0c8fe9de5af6f9de783b" + ], + "bed": [ + [ + { + "id": "test" + }, + "test.combined.bed.gz:md5,bacdb71f8eec683930c6103f020277cd" + ] + ], + "bed_index": [ + [ + { + "id": "test" + }, + "test.combined.bed.gz.tbi:md5,9ca5efde7981fec4e6a79b0b08999186" + ] + ], + "bigwig": [ + [ + { + "id": "test" + }, + "test.combined.bw:md5,77a572a00645df6743459805bd397cb9" + ] + ], + "versions": [ + "versions.yml:md5,e77c5038eded0c8fe9de5af6f9de783b" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.7" + }, + "timestamp": "2025-10-31T10:15:31.999302716" + }, + "pacbio - bam - phased": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz:md5,861084b58d048a2a957a86068ec39bcf", + "test.hap1.bed.gz:md5,db37b440b02203f38c0d7c20b3dd62f3", + "test.hap2.bed.gz:md5,b5b7a4539d3906bd938010644b779196" + ] + ] + ], + "1": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz.tbi:md5,4325f78aeb593d00de8b56cffbc77712", + "test.hap1.bed.gz.tbi:md5,b9813e40b7d3365fb312ad35ac117bab", + "test.hap2.bed.gz.tbi:md5,0213f587a323929cd2180862b01e8044" + ] + ] + ], + "2": [ + [ + { + "id": "test" + }, + [ + "test.combined.bw:md5,77a572a00645df6743459805bd397cb9", + "test.hap1.bw:md5,df389b5415312c1da05a762177f7b50e", + "test.hap2.bw:md5,b87e364ef8cf80790ddef4963fa5e55c" + ] + ] + ], + "3": [ + "versions.yml:md5,e77c5038eded0c8fe9de5af6f9de783b" + ], + "bed": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz:md5,861084b58d048a2a957a86068ec39bcf", + "test.hap1.bed.gz:md5,db37b440b02203f38c0d7c20b3dd62f3", + "test.hap2.bed.gz:md5,b5b7a4539d3906bd938010644b779196" + ] + ] + ], + "bed_index": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz.tbi:md5,4325f78aeb593d00de8b56cffbc77712", + "test.hap1.bed.gz.tbi:md5,b9813e40b7d3365fb312ad35ac117bab", + "test.hap2.bed.gz.tbi:md5,0213f587a323929cd2180862b01e8044" + ] + ] + ], + "bigwig": [ + [ + { + "id": "test" + }, + [ + "test.combined.bw:md5,77a572a00645df6743459805bd397cb9", + "test.hap1.bw:md5,df389b5415312c1da05a762177f7b50e", + "test.hap2.bw:md5,b87e364ef8cf80790ddef4963fa5e55c" + ] + ] + ], + "versions": [ + "versions.yml:md5,e77c5038eded0c8fe9de5af6f9de783b" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.7" + }, + "timestamp": "2025-10-31T10:15:35.516831346" + }, + "pacbio - bam - phased - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test.hap1.bed.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test.hap2.bed.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ] + ], + "1": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap1.bed.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap2.bed.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "2": [ + [ + { + "id": "test" + }, + [ + "test.combined.bw:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap1.bw:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap2.bw:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "3": [ + "versions.yml:md5,e77c5038eded0c8fe9de5af6f9de783b" + ], + "bed": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test.hap1.bed.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test.hap2.bed.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ] + ], + "bed_index": [ + [ + { + "id": "test" + }, + [ + "test.combined.bed.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap1.bed.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap2.bed.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "bigwig": [ + [ + { + "id": "test" + }, + [ + "test.combined.bw:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap1.bw:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.hap2.bw:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions": [ + "versions.yml:md5,e77c5038eded0c8fe9de5af6f9de783b" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.7" + }, + "timestamp": "2025-10-31T10:15:38.750126786" + } +} \ No newline at end of file