From 8a17b6dd0e247746cee97e7dc6fa0761534f13ec Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Fri, 13 May 2022 13:46:34 +0200 Subject: [PATCH] added gatk4/splitintervals --- modules/gatk4/splitintervals/main.nf | 47 +++++++++++++++++++ modules/gatk4/splitintervals/meta.yml | 41 ++++++++++++++++ tests/config/pytest_modules.yml | 12 +++-- tests/modules/gatk4/splitintervals/main.nf | 33 +++++++++++++ .../gatk4/splitintervals/nextflow.config | 9 ++++ tests/modules/gatk4/splitintervals/test.yml | 25 ++++++++++ 6 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 modules/gatk4/splitintervals/main.nf create mode 100644 modules/gatk4/splitintervals/meta.yml create mode 100644 tests/modules/gatk4/splitintervals/main.nf create mode 100644 tests/modules/gatk4/splitintervals/nextflow.config create mode 100644 tests/modules/gatk4/splitintervals/test.yml diff --git a/modules/gatk4/splitintervals/main.nf b/modules/gatk4/splitintervals/main.nf new file mode 100644 index 00000000..d9407b95 --- /dev/null +++ b/modules/gatk4/splitintervals/main.nf @@ -0,0 +1,47 @@ +process GATK4_SPLITINTERVALS { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::gatk4=4.2.6.1" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/gatk4:4.2.6.1--hdfd78af_0': + 'quay.io/biocontainers/gatk4:4.2.6.1--hdfd78af_0' }" + + input: + tuple val(meta), path(intervals) + path(fasta) + path(fasta_fai) + path(fasta_dict) + + output: + tuple val(meta), path("**.interval_list"), emit: split_intervals + 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 reference = fasta ? "--reference $fasta" : "" + + def avail_mem = 3 + if (!task.memory) { + log.info '[GATK IntervalListToBed] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' + } else { + avail_mem = task.memory.giga + } + + """ + gatk --java-options "-Xmx${avail_mem}g" SplitIntervals \\ + --output ${prefix} \\ + --intervals $intervals \\ + $reference \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//') + END_VERSIONS + """ +} diff --git a/modules/gatk4/splitintervals/meta.yml b/modules/gatk4/splitintervals/meta.yml new file mode 100644 index 00000000..6cf7cedc --- /dev/null +++ b/modules/gatk4/splitintervals/meta.yml @@ -0,0 +1,41 @@ +name: gatk4_splitintervals +keywords: + - interval + - bed +tools: + - gatk4: + description: Genome Analysis Toolkit (GATK4) + homepage: https://gatk.broadinstitute.org/hc/en-us + documentation: https://gatk.broadinstitute.org/hc/en-us/categories/360002369672s + tool_dev_url: https://github.com/broadinstitute/gatk + doi: "10.1158/1538-7445.AM2017-3590" + licence: ["BSD-3-clause"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - interval: + type: file + description: Interval list or BED + pattern: "*.{interval,interval_list,bed}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - bed: + type: file + description: A list of scattered interval lists + pattern: "*.interval_list" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@nvnieuwk" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 428c3652..bfd8554a 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -819,6 +819,10 @@ gatk4/selectvariants: - modules/gatk4/selectvariants/** - tests/modules/gatk4/selectvariants/** +gatk4/splitintervals: + - modules/gatk4/splitintervals/** + - tests/modules/gatk4/splitintervals/** + gatk4/splitncigarreads: - modules/gatk4/splitncigarreads/** - tests/modules/gatk4/splitncigarreads/** @@ -1647,14 +1651,14 @@ samtools/bam2fq: - modules/samtools/bam2fq/** - tests/modules/samtools/bam2fq/** -samtools/convert: - - modules/samtools/convert/** - - tests/modules/samtools/convert/** - samtools/collatefastq: - modules/samtools/collatefastq/** - tests/modules/samtools/collatefastq/** +samtools/convert: + - modules/samtools/convert/** + - tests/modules/samtools/convert/** + samtools/depth: - modules/samtools/depth/** - tests/modules/samtools/depth/** diff --git a/tests/modules/gatk4/splitintervals/main.nf b/tests/modules/gatk4/splitintervals/main.nf new file mode 100644 index 00000000..f507ece5 --- /dev/null +++ b/tests/modules/gatk4/splitintervals/main.nf @@ -0,0 +1,33 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { GATK4_SPLITINTERVALS } from '../../../../modules/gatk4/splitintervals/main.nf' + +workflow test_gatk4_splitintervals_bed { + + input = [ + [ id:'test' ], // meta map + file(params.test_data['homo_sapiens']['genome']['genome_multi_interval_bed'], checkIfExists: true) + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + fasta_fai = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true) + fasta_dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true) + + GATK4_SPLITINTERVALS ( input, fasta, fasta_fai, fasta_dict) +} + +workflow test_gatk4_splitintervals_intervals { + + input = [ + [ id:'test' ], // meta map + file(params.test_data['homo_sapiens']['genome']['genome_interval_list'], checkIfExists: true) + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + fasta_fai = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true) + fasta_dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true) + + GATK4_SPLITINTERVALS ( input, fasta, fasta_fai, fasta_dict) +} \ No newline at end of file diff --git a/tests/modules/gatk4/splitintervals/nextflow.config b/tests/modules/gatk4/splitintervals/nextflow.config new file mode 100644 index 00000000..10fda96c --- /dev/null +++ b/tests/modules/gatk4/splitintervals/nextflow.config @@ -0,0 +1,9 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + + withName: GATK4_SPLITINTERVALS { + ext.args = "--scatter-count 2" + } +} \ No newline at end of file diff --git a/tests/modules/gatk4/splitintervals/test.yml b/tests/modules/gatk4/splitintervals/test.yml new file mode 100644 index 00000000..dc0ea6ba --- /dev/null +++ b/tests/modules/gatk4/splitintervals/test.yml @@ -0,0 +1,25 @@ +- name: gatk4 splitintervals test_gatk4_splitintervals_bed + command: nextflow run tests/modules/gatk4/splitintervals -entry test_gatk4_splitintervals_bed -c tests/config/nextflow.config + tags: + - gatk4/splitintervals + - gatk4 + files: + - path: output/gatk4/test/0000-scattered.interval_list + md5sum: c8d6b19e7a92535b6ce9608eae558faa + - path: output/gatk4/test/0001-scattered.interval_list + md5sum: b1877ad96aec308906594c50ebbe3ded + - path: output/gatk4/versions.yml + md5sum: c7b9068d84e0e05412f50e86d5b87078 + +- name: gatk4 splitintervals test_gatk4_splitintervals_intervals + command: nextflow run tests/modules/gatk4/splitintervals -entry test_gatk4_splitintervals_intervals -c tests/config/nextflow.config + tags: + - gatk4/splitintervals + - gatk4 + files: + - path: output/gatk4/test/0000-scattered.interval_list + md5sum: ebd6b34a335efc6732ff541936c6d2d5 + - path: output/gatk4/test/0001-scattered.interval_list + md5sum: 9459b0e124fa84ec1e64ac4615bc9af7 + - path: output/gatk4/versions.yml + md5sum: 4eec8245944ad3be4cc22403c6ffb877