Skip to content

Commit

Permalink
Merge branch 'gatk3-indelrealigner' into upstream-for-indel
Browse files Browse the repository at this point in the history
  • Loading branch information
jfy133 authored Jun 8, 2022
2 parents f41712d + de88adc commit 1fc0d3d
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 0 deletions.
54 changes: 54 additions & 0 deletions modules/gatk/indelrealigner/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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(input), path(index), path(intervals)
path(fasta)
path(fai)
path(dict)
path(known_vcf)

output:
tuple val(meta), path("*.bam"), path("*.bai"), emit: bam
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
if ("$input" == "${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}" : ""

def avail_mem = 3
if (!task.memory) {
log.info '[GATK IndelRealigner] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.'
} else {
avail_mem = task.memory.giga
}

"""
gatk3 \\
-Xmx${avail_mem}g \\
-T IndelRealigner \\
-R ${fasta} \\
-nt ${task.cpus}
-I ${input} \\
-targetIntervals ${intervals} \\
${known} \\
-o ${prefix}.bam \\
$args
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gatk: \$(echo \$(gatk3 --version))
END_VERSIONS
"""
}
71 changes: 71 additions & 0 deletions modules/gatk/indelrealigner/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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 ]
- input:
type: file
description: Sorted and indexed BAM/CRAM/SAM file
pattern: "*.bam"
- index:
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}"
- fai:
type: file
description: Index of reference file used to generate BAM file
pattern: ".fai"
- dict:
type: file
description: GATK dict file for reference
pattern: ".dict"
- 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"
4 changes: 4 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ gamma/gamma:
- modules/gamma/gamma/**
- tests/modules/gamma/gamma/**

gatk/indelrealigner:
- modules/gatk/indelrealigner/**
- tests/modules/gatk/indelrealigner/**

gatk/realignertargetcreator:
- modules/gatk/realignertargetcreator/**
- tests/modules/gatk/realignertargetcreator/**
Expand Down
22 changes: 22 additions & 0 deletions tests/modules/gatk/indelrealigner/main.nf
Original file line number Diff line number Diff line change
@@ -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, [] )
}
6 changes: 6 additions & 0 deletions tests/modules/gatk/indelrealigner/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
ext.prefix = "${meta.id}.realigned"

}
14 changes: 14 additions & 0 deletions tests/modules/gatk/indelrealigner/test.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1fc0d3d

Please sign in to comment.