diff --git a/modules/gatk4/splitintervals/main.nf b/modules/gatk4/splitintervals/main.nf new file mode 100644 index 00000000..9df66c21 --- /dev/null +++ b/modules/gatk4/splitintervals/main.nf @@ -0,0 +1,48 @@ +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(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 SplitIntervals] 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 \\ + --tmp-dir . \\ + $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..ba557544 --- /dev/null +++ b/modules/gatk4/splitintervals/meta.yml @@ -0,0 +1,53 @@ +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}" + - fasta: + type: file + description: Reference FASTA + pattern: "*.{fa,fasta}" + - fasta_fai: + type: file + description: Reference FASTA index + pattern: "*.fai" + - dict: + type: file + description: Reference sequence dictionary + pattern: "*.dict" + +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 74cc4e1c..bc0aa79a 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/** 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..741c6bec --- /dev/null +++ b/tests/modules/gatk4/splitintervals/test.yml @@ -0,0 +1,23 @@ +- 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 + +- 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