diff --git a/modules/gatk/indelrealigner/main.nf b/modules/gatk/indelrealigner/main.nf new file mode 100644 index 00000000..117a298b --- /dev/null +++ b/modules/gatk/indelrealigner/main.nf @@ -0,0 +1,43 @@ +process GATK_INDELREALIGNER { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::gatk=3.5" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/gatk:3.5--hdfd78af_11': + 'quay.io/biocontainers/gatk:3.5--hdfd78af_11' }" + + input: + tuple val(meta), path(bam), path(bai), path(intervals) + tuple val(meta), path(fasta) + tuple val(meta), path(known_vcf) + + output: + tuple val(meta), path("*.bam"), emit: bam + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + if ("$bam" == "${prefix}.bam") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def known = known_vcf ? "-known ${known_vcf}" : "" + """ + gatk3 \\ + -T RealignerTargetCreator \\ + -R ${fasta} \\ + -nt ${task.cpus} + -I ${bam} \\ + -targetIntervals ${intervals} \\ + ${known} \\ + -o ${prefix}.bam \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + gatk: \$(echo \$(gatk3 --version)) + END_VERSIONS + """ +} diff --git a/modules/gatk/indelrealigner/meta.yml b/modules/gatk/indelrealigner/meta.yml new file mode 100644 index 00000000..80abc6aa --- /dev/null +++ b/modules/gatk/indelrealigner/meta.yml @@ -0,0 +1,63 @@ +name: "gatk_indelrealigner" +description: Performs local realignment around indels to correct for mapping errors +keywords: + - bam + - vcf + - variant calling + - indel + - realignment +tools: + - "gatk": + description: "The full Genome Analysis Toolkit (GATK) framework, license restricted." + homepage: "https://gatk.broadinstitute.org/hc/en-us" + documentation: "https://github.com/broadinstitute/gatk-docs" + licence: "['https://software.broadinstitute.org/gatk/download/licensing', 'BSD', 'https://www.broadinstitute.org/gatk/about/#licensing']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: Sorted and indexed BAM/CRAM/SAM file + pattern: "*.bam" + - bai: + type: file + description: BAM index file + pattern: "*.bai" + - intervals: + type: file + description: Intervals file created by gatk3 RealignerTargetCreator + pattern: "*.{intervals,list}" + - fasta: + type: file + description: Reference file used to generate BAM file + pattern: ".{fasta,fa,fna}" + - known_vcf: + type: file + description: Optional input VCF file(s) with known indels + pattern: ".vcf" + +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" + - bam: + type: file + description: Sorted and indexed BAM/CRAM/SAM file with local realignment around variants + pattern: "*.bam" + - bai: + type: file + description: Output BAM Index file + pattern: "*.bai" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 3ff58b5c..8bb9d305 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -715,6 +715,10 @@ gamma/gamma: - modules/gamma/gamma/** - tests/modules/gamma/gamma/** +gatk/indelrealigner: + - modules/gatk/indelrealigner/** + - tests/modules/gatk/indelrealigner/** + gatk4/applybqsr: - modules/gatk4/applybqsr/** - tests/modules/gatk4/applybqsr/** diff --git a/tests/modules/gatk/indelrealigner/main.nf b/tests/modules/gatk/indelrealigner/main.nf new file mode 100644 index 00000000..687e12a9 --- /dev/null +++ b/tests/modules/gatk/indelrealigner/main.nf @@ -0,0 +1,22 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { GATK_INDELREALIGNER } from '../../../../modules/gatk/indelrealigner/main.nf' + +// TODO add REalignerTargetCrator + + +workflow test_gatk_indelrealigner { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_paired_end_bai'], checkIfExists: true), + GATK_REALIGNERTARGETCREATOR.out.intervals + ] + + reference = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + + GATK_INDELREALIGNER ( input, reference, [] ) +} diff --git a/tests/modules/gatk/indelrealigner/nextflow.config b/tests/modules/gatk/indelrealigner/nextflow.config new file mode 100644 index 00000000..2e6ae57f --- /dev/null +++ b/tests/modules/gatk/indelrealigner/nextflow.config @@ -0,0 +1,6 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.prefix = "${meta.id}.realigned" + +} diff --git a/tests/modules/gatk/indelrealigner/test.yml b/tests/modules/gatk/indelrealigner/test.yml new file mode 100644 index 00000000..59fc394f --- /dev/null +++ b/tests/modules/gatk/indelrealigner/test.yml @@ -0,0 +1,14 @@ +## TODO nf-core: Please run the following command to build this file: +# nf-core modules create-test-yml gatk/indelrealigner +- name: "gatk indelrealigner" + command: nextflow run ./tests/modules/gatk/indelrealigner -entry test_gatk_indelrealigner -c ./tests/config/nextflow.config -c ./tests/modules/gatk/indelrealigner/nextflow.config + tags: + - "gatk" + # + - "gatk/indelrealigner" + # + files: + - path: "output/gatk/test.bam" + md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: output/gatk/versions.yml + md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b