diff --git a/modules/nf-core/pypgx/preparedepthofcoverage/environment.yml b/modules/nf-core/pypgx/preparedepthofcoverage/environment.yml new file mode 100644 index 00000000000..d18360bed97 --- /dev/null +++ b/modules/nf-core/pypgx/preparedepthofcoverage/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::pypgx=0.25.0" diff --git a/modules/nf-core/pypgx/preparedepthofcoverage/main.nf b/modules/nf-core/pypgx/preparedepthofcoverage/main.nf new file mode 100644 index 00000000000..1682eae234b --- /dev/null +++ b/modules/nf-core/pypgx/preparedepthofcoverage/main.nf @@ -0,0 +1,53 @@ +process PYPGX_PREPAREDEPTHOFCOVERAGE { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/pypgx:0.25.0--pyh7e72e81_0': + 'biocontainers/pypgx:0.25.0--pyh7e72e81_0' }" + + input: + tuple val(meta), path(bam), path(bai) + val(pgx_genes) + val(assembly_version) + + output: + tuple val(meta), path('*.zip'), 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}" + def genes = "--genes ${pgx_genes.join(' ')}" ?: '' + def assembly = assembly_version ?: "GRCh38" + + """ + pypgx prepare-depth-of-coverage \\ + ${args} \\ + ${genes} \\ + --assembly ${assembly} \\ + ${prefix}.zip \\ + $bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pypgx: \$(echo \$(pypgx -v 2>&1) | sed 's/.* //') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + python -c 'import zipfile; zipfile.ZipFile("${prefix}.zip", "w").close()' + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pypgx: \$(echo \$(pypgx -v 2>&1) | sed 's/.* //') + END_VERSIONS + """ +} diff --git a/modules/nf-core/pypgx/preparedepthofcoverage/meta.yml b/modules/nf-core/pypgx/preparedepthofcoverage/meta.yml new file mode 100644 index 00000000000..71fe4de093b --- /dev/null +++ b/modules/nf-core/pypgx/preparedepthofcoverage/meta.yml @@ -0,0 +1,61 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "pypgx_preparedepthofcoverage" +description: Prepare a depth of coverage file for all target genes with SV from BAM + files. +keywords: + - Pharmacogenetics + - pypgx + - SV +tools: + - "pypgx": + description: "A Python package for pharmacogenomics research" + homepage: "https://pypgx.readthedocs.io/en/latest/" + documentation: "https://pypgx.readthedocs.io/en/latest/" + tool_dev_url: "https://github.com/sbslee/pypgx" + doi: "10.1371/journal.pone.0272129" + licence: ["MIT"] + identifier: "" +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - bam: + type: file + description: Input BAM file + pattern: "*.{bam}" + - bai: + type: file + description: Input BAM index file + pattern: "*.{bam.bai}" + - - pgx_genes: + type: list + description: List of PGx genes supported by PyPGx to include in variant calling. + - - assembly_version: + type: string + description: Genome assembly version to use. + pattern: "{GRCh37,GRCh38}" +output: + - coverage: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + pattern: "*.{zip}" + - "*.zip": + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + pattern: "*.{zip}" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@jorivansteenbrugge" +maintainers: + - "@jorivansteenbrugge" diff --git a/modules/nf-core/pypgx/preparedepthofcoverage/tests/main.nf.test b/modules/nf-core/pypgx/preparedepthofcoverage/tests/main.nf.test new file mode 100644 index 00000000000..43d768d31ed --- /dev/null +++ b/modules/nf-core/pypgx/preparedepthofcoverage/tests/main.nf.test @@ -0,0 +1,65 @@ +// nf-core modules test pypgx/preparedepthofcoverage +nextflow_process { + + name "Test Process PYPGX_PREPAREDEPTHOFCOVERAGE" + script "../main.nf" + process "PYPGX_PREPAREDEPTHOFCOVERAGE" + + tag "modules" + tag "modules_nfcore" + tag "pypgx" + tag "pypgx/preparedepthofcoverage" + + test("human paired end bam CYP2D6 locus - GRCh37") { + when { + process { + """ + input[0] = [ + [id: 'test'], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam.bai', checkIfExists: true) + ] + input[1] = ["CYP2D6"] + input[2] = "GRCh37" + """ + } + } + then { + def zipFile = path(process.out.coverage[0][1]).zip + def paths = zipFile.extractAll() + def metaFile = paths.find { it.getFileName().toString() == 'metadata.txt' } + def dataFile = paths.find { it.getFileName().toString() == 'data.tsv' } + + assertAll( + {assert process.success}, + {assert zipFile.isValid()}, + {assert snapshot( + metaFile, + dataFile).match()} + ) + } + } + + test("stub") { + options "-stub" + when { + process { + """ + input[0] = [ + [ id:'test' ], + [], + [] + ] + input[1] = [] + input[2] = "" + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/pypgx/preparedepthofcoverage/tests/main.nf.test.snap b/modules/nf-core/pypgx/preparedepthofcoverage/tests/main.nf.test.snap new file mode 100644 index 00000000000..ab6ae57d57b --- /dev/null +++ b/modules/nf-core/pypgx/preparedepthofcoverage/tests/main.nf.test.snap @@ -0,0 +1,46 @@ +{ + "human paired end bam CYP2D6 locus - GRCh37": { + "content": [ + "metadata.txt:md5,36e844724abd194e915ca0a9793cddc8", + "data.tsv:md5,4291d10aa774208ba97a9b753face059" + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-10-04T08:27:28.096562" + }, + "stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.zip:md5,76cdb2bad9582d23c1f6f4d868218d6c" + ] + ], + "1": [ + "versions.yml:md5,245a2588c91875e1fe561955c4a0ad27" + ], + "coverage": [ + [ + { + "id": "test" + }, + "test.zip:md5,76cdb2bad9582d23c1f6f4d868218d6c" + ] + ], + "versions": [ + "versions.yml:md5,245a2588c91875e1fe561955c4a0ad27" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-10-04T08:27:34.813018" + } +} \ No newline at end of file diff --git a/modules/nf-core/pypgx/preparedepthofcoverage/tests/tags.yml b/modules/nf-core/pypgx/preparedepthofcoverage/tests/tags.yml new file mode 100644 index 00000000000..68e953151b6 --- /dev/null +++ b/modules/nf-core/pypgx/preparedepthofcoverage/tests/tags.yml @@ -0,0 +1,2 @@ +pypgx/preparedepthofcoverage: + - "modules/nf-core/pypgx/preparedepthofcoverage/**"