From 6342f5b0996c1debb23037efdd1ad7029e801a7f Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Tue, 17 May 2022 14:24:32 +0200 Subject: [PATCH] added bedtools split --- modules/bedtools/split/main.nf | 38 ++++++++++++++++++ modules/bedtools/split/meta.yml | 41 ++++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/bedtools/split/main.nf | 17 ++++++++ tests/modules/bedtools/split/nextflow.config | 5 +++ tests/modules/bedtools/split/test.yml | 10 +++++ 6 files changed, 115 insertions(+) create mode 100644 modules/bedtools/split/main.nf create mode 100644 modules/bedtools/split/meta.yml create mode 100644 tests/modules/bedtools/split/main.nf create mode 100644 tests/modules/bedtools/split/nextflow.config create mode 100644 tests/modules/bedtools/split/test.yml diff --git a/modules/bedtools/split/main.nf b/modules/bedtools/split/main.nf new file mode 100644 index 00000000..86054292 --- /dev/null +++ b/modules/bedtools/split/main.nf @@ -0,0 +1,38 @@ +process BEDTOOLS_SPLIT { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::bedtools=2.30.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/bedtools:2.30.0--h468198e_3': + 'quay.io/biocontainers/bedtools:2.30.0--h7d7f7ad_2' }" + + input: + tuple val(meta), path(bed) + val(number_of_files) + + output: + tuple val(meta), path("*.bed"), emit: beds + 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}" + + """ + bedtools \\ + split \\ + $args \\ + -i $bed \\ + -p $prefix \\ + -n $number_of_files + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version | sed -e "s/bedtools v//g") + END_VERSIONS + """ +} diff --git a/modules/bedtools/split/meta.yml b/modules/bedtools/split/meta.yml new file mode 100644 index 00000000..1f41cc70 --- /dev/null +++ b/modules/bedtools/split/meta.yml @@ -0,0 +1,41 @@ +name: "bedtools_split" +description: Split BED files into several smaller BED files +keywords: + - sort +tools: + - "bedtools": + description: "A powerful toolset for genome arithmetic" + documentation: "https://bedtools.readthedocs.io/en/latest/content/tools/sort.html" + licence: "['MIT', 'GPL v2']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bed: + type: file + description: BED file + pattern: "*.bed" + - bed: + type: value + description: The number of files to split the BED into + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - beds: + type: file + description: list of split BED files + pattern: "*.bed" + +authors: + - "@nvnieuwk" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 142e9d41..172c3a8b 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -222,6 +222,10 @@ bedtools/sort: - modules/bedtools/sort/** - tests/modules/bedtools/sort/** +bedtools/split: + - modules/bedtools/split/** + - tests/modules/bedtools/split/** + bedtools/subtract: - modules/bedtools/subtract/** - tests/modules/bedtools/subtract/** diff --git a/tests/modules/bedtools/split/main.nf b/tests/modules/bedtools/split/main.nf new file mode 100644 index 00000000..7a1dc685 --- /dev/null +++ b/tests/modules/bedtools/split/main.nf @@ -0,0 +1,17 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BEDTOOLS_SPLIT } from '../../../../modules/bedtools/split/main.nf' + +workflow test_bedtools_split { + + input = [ + [ id:'test' ], // meta map + file(params.test_data['homo_sapiens']['genome']['genome_multi_interval_bed'], checkIfExists: true) + ] + + number_of_files = 2 + + BEDTOOLS_SPLIT ( input, number_of_files ) +} diff --git a/tests/modules/bedtools/split/nextflow.config b/tests/modules/bedtools/split/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/bedtools/split/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/bedtools/split/test.yml b/tests/modules/bedtools/split/test.yml new file mode 100644 index 00000000..92ac17fa --- /dev/null +++ b/tests/modules/bedtools/split/test.yml @@ -0,0 +1,10 @@ +- name: bedtools split test_bedtools_split + command: nextflow run ./tests/modules/bedtools/split -entry test_bedtools_split -c ./tests/config/nextflow.config -c ./tests/modules/bedtools/split/nextflow.config + tags: + - bedtools + - bedtools/split + files: + - path: output/bedtools/test.00001.bed + md5sum: d58e5e46c2fcc3b8be5db0f023e93cb5 + - path: output/bedtools/test.00002.bed + md5sum: 03caf952e9297a54620d2bbba8dc2823