diff --git a/modules/nf-core/bedtools/shuffle/environment.yml b/modules/nf-core/bedtools/shuffle/environment.yml new file mode 100644 index 000000000000..45c307b0e4fe --- /dev/null +++ b/modules/nf-core/bedtools/shuffle/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::bedtools=2.31.1 diff --git a/modules/nf-core/bedtools/shuffle/main.nf b/modules/nf-core/bedtools/shuffle/main.nf new file mode 100644 index 000000000000..0ab95d5f3b02 --- /dev/null +++ b/modules/nf-core/bedtools/shuffle/main.nf @@ -0,0 +1,56 @@ +process BEDTOOLS_SHUFFLE { + 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/bedtools:2.31.1--h13024bc_3': + 'biocontainers/bedtools:2.31.1--h13024bc_3' }" + + input: + tuple val(meta) , path(intervals) + tuple val(meta2), path(chrom_sizes) + path exclude_file + path include_file + + output: + tuple val(meta), path("*.bed"), emit: bed + 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 exclude_arg = exclude_file ? "-excl $exclude_file" : '' + def include_arg = include_file ? "-incl $include_file" : '' + if ("$intervals" == "${prefix}.bed") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + """ + bedtools \\ + shuffle \\ + $args \\ + -i $intervals \\ + -g $chrom_sizes \\ + $exclude_arg \\ + $include_arg \\ + > ${prefix}.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version |& sed '1!d ; s/bedtools //') + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + if ("$intervals" == "${prefix}.bed") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + """ + touch ${prefix}.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version |& sed '1!d ; s/bedtools //') + END_VERSIONS + """ +} diff --git a/modules/nf-core/bedtools/shuffle/meta.yml b/modules/nf-core/bedtools/shuffle/meta.yml new file mode 100644 index 000000000000..c0b08c02fc16 --- /dev/null +++ b/modules/nf-core/bedtools/shuffle/meta.yml @@ -0,0 +1,80 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "bedtools_shuffle" +description: bedtools shuffle will randomly permute the genomic locations of a feature file among a genome defined in a genome file +keywords: + - bed + - shuffleBed + - region + - fai + - sizes + - genome + - bases +tools: + - bedtools: + description: | + A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types. + documentation: https://bedtools.readthedocs.io/en/latest/content/tools/slop.html + licence: ["MIT"] + identifier: biotools:bedtools + +input: + - - meta: + type: map + description: | + Groovy Map containing interval information + e.g. [ id:'test' ] + - intervals: + type: file + description: Input interval (BED/GFF/VCF) file + pattern: "*.{bed,gff,gff3,vcf}" + ontologies: + - edam: "http://edamontology.org/format_3003" + - edam: "http://edamontology.org/format_2305" + - edam: "http://edamontology.org/format_3016" + - - meta2: + type: map + description: | + Groovy Map containing genome information + e.g. [ id:'test' ] + - chrom_sizes: + type: file + description: Chromosome sizes file + pattern: "*{.genome,.sizes,.txt,.fai}" + - - exclude_file: + type: file + description: BED file containing regions to exclude + pattern: "*.{bed}" + ontologies: + - edam: "http://edamontology.org/format_3003" + - - include_file: + type: file + description: BED file containing regions to include + pattern: "*.{bed}" + ontologies: + - edam: "http://edamontology.org/format_3003" + +output: + - bed: + - meta: + type: map + description: | + Groovy Map containing interval information + e.g. `[ id:'sample1' ]` + - "*.bed": + type: file + description: BED file with shuffled intervals + pattern: "*.{bed}" + ontologies: + - edam: "http://edamontology.org/format_3003" + + - versions: + - "versions.yml": + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@itrujnara" +maintainers: + - "@itrujnara" diff --git a/modules/nf-core/bedtools/shuffle/tests/main.nf.test b/modules/nf-core/bedtools/shuffle/tests/main.nf.test new file mode 100644 index 000000000000..6e34605f48a1 --- /dev/null +++ b/modules/nf-core/bedtools/shuffle/tests/main.nf.test @@ -0,0 +1,309 @@ +// TODO nf-core: Once you have added the required tests, please run the following command to build this file: +// nf-core modules test bedtools/shuffle +nextflow_process { + + name "Test Process BEDTOOLS_SHUFFLE" + script "../main.nf" + process "BEDTOOLS_SHUFFLE" + + tag "modules" + tag "modules_nfcore" + tag "bedtools" + tag "bedtools/shuffle" + + test("test - sarscov - bed - fai") { + + config "./nextflow.config" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - bed - fai - stub") { + + config "./nextflow.config" + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - vcf - fai") { + + config "./nextflow.config" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - vcf - fai - stub") { + + config "./nextflow.config" + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - gff - sizes") { + + config "./nextflow.config" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.sizes', checkIfExists: true) + ] + input[2] = [] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - gff - sizes - stub") { + + config "./nextflow.config" + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.sizes', checkIfExists: true) + ] + input[2] = [] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - exclude") { + + config "./nextflow.config" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.sizes', checkIfExists: true) + ] + input[2] = [file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true)] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - exclude - stub") { + + config "./nextflow.config" + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.sizes', checkIfExists: true) + ] + input[2] = [file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true)] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - include") { + + config "./nextflow.config" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.sizes', checkIfExists: true) + ] + input[2] = [] + input[3] = [file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true)] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test - sarscov - include - stub") { + + config "./nextflow.config" + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true), + ] + input[1] = [ + [ id:'genome' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.sizes', checkIfExists: true) + ] + input[2] = [] + input[3] = [file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true)] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + +} \ No newline at end of file diff --git a/modules/nf-core/bedtools/shuffle/tests/main.nf.test.snap b/modules/nf-core/bedtools/shuffle/tests/main.nf.test.snap new file mode 100644 index 000000000000..6c707cc39cc1 --- /dev/null +++ b/modules/nf-core/bedtools/shuffle/tests/main.nf.test.snap @@ -0,0 +1,332 @@ +{ + "test - sarscov - bed - fai": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,bdcb17eb3c78b52532d7d55393694cda" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,bdcb17eb3c78b52532d7d55393694cda" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:28:35.831870187" + }, + "test - sarscov - include": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,cecdc22ea3518b4df919bcf4827e16b8" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,cecdc22ea3518b4df919bcf4827e16b8" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:50:32.519944639" + }, + "test - sarscov - exclude": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,225734402ffe711fd8f819c63ce5341f" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,225734402ffe711fd8f819c63ce5341f" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-14T17:43:36.931517467" + }, + "test - sarscov - gff - sizes": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,ce190915aabee83c3f1ab57ec3b3a822" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,ce190915aabee83c3f1ab57ec3b3a822" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:41:28.885942789" + }, + "test - sarscov - include - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:50:44.644836082" + }, + "test - sarscov - gff - sizes - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:41:40.893235941" + }, + "test - sarscov - vcf - fai - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:41:16.899354918" + }, + "test - sarscov - vcf - fai": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,0461b8b5a757b3aaa3936872b1cca2e8" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,0461b8b5a757b3aaa3936872b1cca2e8" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:34:03.85730131" + }, + "test - sarscov - bed - fai - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:40:52.91008347" + }, + "test - sarscov - exclude - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ], + "bed": [ + [ + { + "id": "test" + }, + "test_file.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,167f7eeefe27eb3d34d6ef0f8b757ccd" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.10.5" + }, + "timestamp": "2025-03-12T17:50:19.867332058" + } +} \ No newline at end of file diff --git a/modules/nf-core/bedtools/shuffle/tests/nextflow.config b/modules/nf-core/bedtools/shuffle/tests/nextflow.config new file mode 100644 index 000000000000..60bcbe2f7ce6 --- /dev/null +++ b/modules/nf-core/bedtools/shuffle/tests/nextflow.config @@ -0,0 +1,6 @@ +process { + withName: "BEDTOOLS_SHUFFLE" { + ext.args = "-seed 42" + ext.prefix = "test_file" + } +}