From 544b62df45d3043ca2c5ca3a131284fe0d74026b Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Thu, 2 Jun 2022 21:11:17 +0200 Subject: [PATCH 1/4] Star work on GATK UG --- modules/gatk/unifiedgenotyper/main.nf | 50 ++++++++++++++++++ modules/gatk/unifiedgenotyper/meta.yml | 51 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/gatk/unifiedgenotyper/main.nf | 15 ++++++ .../gatk/unifiedgenotyper/nextflow.config | 5 ++ tests/modules/gatk/unifiedgenotyper/test.yml | 14 +++++ 6 files changed, 139 insertions(+) create mode 100644 modules/gatk/unifiedgenotyper/main.nf create mode 100644 modules/gatk/unifiedgenotyper/meta.yml create mode 100644 tests/modules/gatk/unifiedgenotyper/main.nf create mode 100644 tests/modules/gatk/unifiedgenotyper/nextflow.config create mode 100644 tests/modules/gatk/unifiedgenotyper/test.yml diff --git a/modules/gatk/unifiedgenotyper/main.nf b/modules/gatk/unifiedgenotyper/main.nf new file mode 100644 index 00000000..4dd6e408 --- /dev/null +++ b/modules/gatk/unifiedgenotyper/main.nf @@ -0,0 +1,50 @@ +process GATK_UNIFIEDGENOTYPER { + tag "$meta.id" + label 'process_medium' + + 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(fasta) + path(fai) + path(dict) + 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: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + def avail_mem = 3 + if (!task.memory) { + log.info '[GATK RealignerTargetCreator] 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 \\ + -nt ${task.cpus} \\ + -T UnifiedGenotyper \\ + -I ${input} \\ + -R ${fasta} \\ + -o ${prefix}.vcf \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + gatk: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + END_VERSIONS + """ +} diff --git a/modules/gatk/unifiedgenotyper/meta.yml b/modules/gatk/unifiedgenotyper/meta.yml new file mode 100644 index 00000000..7a992591 --- /dev/null +++ b/modules/gatk/unifiedgenotyper/meta.yml @@ -0,0 +1,51 @@ +name: "gatk_unifiedgenotyper" +## TODO nf-core: Add a description of the module and list keywords +description: write your description here +keywords: + - sort +tools: + - "gatk": + ## TODO nf-core: Add a description and other details for the software below + description: "The full Genome Analysis Toolkit (GATK) framework, license restricted." + homepage: "None" + documentation: "None" + tool_dev_url: "None" + doi: "" + licence: "['BSD', 'https://www.broadinstitute.org/gatk/about/#licensing', 'https://software.broadinstitute.org/gatk/download/licensing']" + +## TODO nf-core: Add a description of all of the variables used as input +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + # + ## TODO nf-core: Delete / customise this example input + - bam: + type: file + description: BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + +## TODO nf-core: Add a description of all of the variables used as output +output: + #Only when we have meta + - 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" + ## TODO nf-core: Delete / customise this example output + - bam: + type: file + description: Sorted BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index d4bfac5b..0d3a21c2 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/unifiedgenotyper: + - modules/gatk/unifiedgenotyper/** + - tests/modules/gatk/unifiedgenotyper/** + gatk4/applybqsr: - modules/gatk4/applybqsr/** - tests/modules/gatk4/applybqsr/** diff --git a/tests/modules/gatk/unifiedgenotyper/main.nf b/tests/modules/gatk/unifiedgenotyper/main.nf new file mode 100644 index 00000000..86a23790 --- /dev/null +++ b/tests/modules/gatk/unifiedgenotyper/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { GATK_UNIFIEDGENOTYPER } from '../../../../modules/gatk/unifiedgenotyper/main.nf' + +workflow test_gatk_unifiedgenotyper { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + + GATK_UNIFIEDGENOTYPER ( input ) +} diff --git a/tests/modules/gatk/unifiedgenotyper/nextflow.config b/tests/modules/gatk/unifiedgenotyper/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/gatk/unifiedgenotyper/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/gatk/unifiedgenotyper/test.yml b/tests/modules/gatk/unifiedgenotyper/test.yml new file mode 100644 index 00000000..aad9aec9 --- /dev/null +++ b/tests/modules/gatk/unifiedgenotyper/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/unifiedgenotyper +- name: "gatk unifiedgenotyper" + command: nextflow run ./tests/modules/gatk/unifiedgenotyper -entry test_gatk_unifiedgenotyper -c ./tests/config/nextflow.config -c ./tests/modules/gatk/unifiedgenotyper/nextflow.config + tags: + - "gatk" + # + - "gatk/unifiedgenotyper" + # + files: + - path: "output/gatk/test.bam" + md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: output/gatk/versions.yml + md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b From a14855dbe8648ca445759f57a1a2805ec4812615 Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Thu, 2 Jun 2022 21:22:21 +0200 Subject: [PATCH 2/4] Start meta --- modules/gatk/unifiedgenotyper/main.nf | 16 ++++++- modules/gatk/unifiedgenotyper/meta.yml | 59 ++++++++++++++++---------- 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/modules/gatk/unifiedgenotyper/main.nf b/modules/gatk/unifiedgenotyper/main.nf index 4dd6e408..896a347e 100644 --- a/modules/gatk/unifiedgenotyper/main.nf +++ b/modules/gatk/unifiedgenotyper/main.nf @@ -13,9 +13,13 @@ process GATK_UNIFIEDGENOTYPER { path(fai) path(dict) path(known_vcf) + path(intervals) + path(contamination) + path(dbsnps) + path(comp) output: - tuple val(meta), path("*.bam"), emit: bam + tuple val(meta), path("*.vcf.gz"), emit: vcf path "versions.yml" , emit: versions when: @@ -24,6 +28,10 @@ process GATK_UNIFIEDGENOTYPER { script: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" + def contamination_file = contamination ? "-contaminationFile ${contamination}" : "" + def dbsnps_file = dbsnps ? "--dbsnp ${dbsnps}" : "" + def comp_file = comp ? "--comp ${comp}" : "" + def intervals_file = intervals ? "--intervals ${intervals}" : "" def avail_mem = 3 if (!task.memory) { @@ -39,9 +47,15 @@ process GATK_UNIFIEDGENOTYPER { -T UnifiedGenotyper \\ -I ${input} \\ -R ${fasta} \\ + ${contamination_file} \\ + ${dbsnps_file} \\ + ${comp_file} \\ + ${intervals_file} -o ${prefix}.vcf \\ $args + gzip -n *.vcf + cat <<-END_VERSIONS > versions.yml "${task.process}": gatk: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) diff --git a/modules/gatk/unifiedgenotyper/meta.yml b/modules/gatk/unifiedgenotyper/meta.yml index 7a992591..5f85c451 100644 --- a/modules/gatk/unifiedgenotyper/meta.yml +++ b/modules/gatk/unifiedgenotyper/meta.yml @@ -1,51 +1,64 @@ name: "gatk_unifiedgenotyper" -## TODO nf-core: Add a description of the module and list keywords -description: write your description here keywords: - - sort + - bam + - vcf + - variant calling + - indel + - realignment + - targets tools: - "gatk": - ## TODO nf-core: Add a description and other details for the software below description: "The full Genome Analysis Toolkit (GATK) framework, license restricted." - homepage: "None" - documentation: "None" - tool_dev_url: "None" - doi: "" - licence: "['BSD', 'https://www.broadinstitute.org/gatk/about/#licensing', 'https://software.broadinstitute.org/gatk/download/licensing']" + 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']" -## TODO nf-core: Add a description of all of the variables used as input input: - # Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - # - ## TODO nf-core: Delete / customise this example input - - bam: + - input: type: file - description: BAM/CRAM/SAM file - pattern: "*.{bam,cram,sam}" + description: Sorted and indexed BAM/CRAM/SAM file + pattern: "*.bam" + - index: + type: file + description: BAM index file + pattern: "*.bai" + - 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" -## TODO nf-core: Add a description of all of the variables used as output output: - #Only when we have meta - 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" - ## TODO nf-core: Delete / customise this example output - - bam: + - vcf: type: file - description: Sorted BAM/CRAM/SAM file - pattern: "*.{bam,cram,sam}" + description: VCF file containing called variants + pattern: "*.vcf.gz" authors: + - "@ilight1542" - "@jfy133" From a565d9072aba07b369c6e3c43f4168556d32678c Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Thu, 2 Jun 2022 21:39:39 +0200 Subject: [PATCH 3/4] Add GATK UnifiedGenotyper --- modules/gatk/unifiedgenotyper/main.nf | 13 ++++++------ modules/gatk/unifiedgenotyper/meta.yml | 21 ++++++++++++++------ tests/modules/gatk/unifiedgenotyper/main.nf | 15 ++++++++------ tests/modules/gatk/unifiedgenotyper/test.yml | 19 +++++++----------- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/modules/gatk/unifiedgenotyper/main.nf b/modules/gatk/unifiedgenotyper/main.nf index 896a347e..47d83def 100644 --- a/modules/gatk/unifiedgenotyper/main.nf +++ b/modules/gatk/unifiedgenotyper/main.nf @@ -12,15 +12,14 @@ process GATK_UNIFIEDGENOTYPER { path(fasta) path(fai) path(dict) - path(known_vcf) path(intervals) path(contamination) - path(dbsnps) + path(dbsnp) path(comp) output: tuple val(meta), path("*.vcf.gz"), emit: vcf - path "versions.yml" , emit: versions + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -29,7 +28,7 @@ process GATK_UNIFIEDGENOTYPER { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def contamination_file = contamination ? "-contaminationFile ${contamination}" : "" - def dbsnps_file = dbsnps ? "--dbsnp ${dbsnps}" : "" + def dbsnp_file = dbsnp ? "--dbsnp ${dbsnp}" : "" def comp_file = comp ? "--comp ${comp}" : "" def intervals_file = intervals ? "--intervals ${intervals}" : "" @@ -48,9 +47,9 @@ process GATK_UNIFIEDGENOTYPER { -I ${input} \\ -R ${fasta} \\ ${contamination_file} \\ - ${dbsnps_file} \\ + ${dbsnp_file} \\ ${comp_file} \\ - ${intervals_file} + ${intervals_file} \\ -o ${prefix}.vcf \\ $args @@ -58,7 +57,7 @@ process GATK_UNIFIEDGENOTYPER { cat <<-END_VERSIONS > versions.yml "${task.process}": - gatk: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + gatk: \$(echo \$(gatk3 --version)) END_VERSIONS """ } diff --git a/modules/gatk/unifiedgenotyper/meta.yml b/modules/gatk/unifiedgenotyper/meta.yml index 5f85c451..e414d146 100644 --- a/modules/gatk/unifiedgenotyper/meta.yml +++ b/modules/gatk/unifiedgenotyper/meta.yml @@ -3,9 +3,6 @@ keywords: - bam - vcf - variant calling - - indel - - realignment - - targets tools: - "gatk": description: "The full Genome Analysis Toolkit (GATK) framework, license restricted." @@ -39,10 +36,22 @@ input: type: file description: GATK dict file for reference pattern: ".dict" - - known_vcf: + - intervals: type: file - description: Optional input VCF file(s) with known indels - pattern: ".vcf" + description: Bed file with the genomic regions included in the library (optional) + pattern: "*.intervals" + - contamination: + type: file + description: Tab-separated file containing fraction of contamination in sequencing data (per sample) to aggressively remove + pattern: "*" + - dbsnps: + type: file + description: VCF file containing known sites (optional) + pattern: "*" + - comp: + type: file + description: Comparison VCF file (optional) + pattern: "*" output: - meta: diff --git a/tests/modules/gatk/unifiedgenotyper/main.nf b/tests/modules/gatk/unifiedgenotyper/main.nf index 86a23790..6d145e76 100644 --- a/tests/modules/gatk/unifiedgenotyper/main.nf +++ b/tests/modules/gatk/unifiedgenotyper/main.nf @@ -5,11 +5,14 @@ nextflow.enable.dsl = 2 include { GATK_UNIFIEDGENOTYPER } from '../../../../modules/gatk/unifiedgenotyper/main.nf' workflow test_gatk_unifiedgenotyper { - - input = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) - ] - GATK_UNIFIEDGENOTYPER ( input ) + input = [ [ id:'test' ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true), + ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true) + dict = file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true) + + GATK_UNIFIEDGENOTYPER ( input, fasta, fai, dict, [], [], [], []) } diff --git a/tests/modules/gatk/unifiedgenotyper/test.yml b/tests/modules/gatk/unifiedgenotyper/test.yml index aad9aec9..498e7991 100644 --- a/tests/modules/gatk/unifiedgenotyper/test.yml +++ b/tests/modules/gatk/unifiedgenotyper/test.yml @@ -1,14 +1,9 @@ -## TODO nf-core: Please run the following command to build this file: -# nf-core modules create-test-yml gatk/unifiedgenotyper -- name: "gatk unifiedgenotyper" - command: nextflow run ./tests/modules/gatk/unifiedgenotyper -entry test_gatk_unifiedgenotyper -c ./tests/config/nextflow.config -c ./tests/modules/gatk/unifiedgenotyper/nextflow.config +- name: gatk unifiedgenotyper test_gatk_unifiedgenotyper + command: nextflow run ./tests/modules/gatk/unifiedgenotyper -entry test_gatk_unifiedgenotyper -c ./tests/config/nextflow.config -c ./tests/modules/gatk/unifiedgenotyper/nextflow.config tags: - - "gatk" - # - - "gatk/unifiedgenotyper" - # + - gatk + - gatk/unifiedgenotyper files: - - path: "output/gatk/test.bam" - md5sum: e667c7caad0bc4b7ac383fd023c654fc - - path: output/gatk/versions.yml - md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b + - path: output/gatk/test.vcf.gz + contains: + - "#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT test" From e827a042ce1f55a37a8e771944b566faa5108e8e Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Fri, 3 Jun 2022 21:24:03 +0200 Subject: [PATCH 4/4] Update modules/gatk/unifiedgenotyper/main.nf Co-authored-by: Maxime U. Garcia --- modules/gatk/unifiedgenotyper/main.nf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/gatk/unifiedgenotyper/main.nf b/modules/gatk/unifiedgenotyper/main.nf index 47d83def..e88ac7c5 100644 --- a/modules/gatk/unifiedgenotyper/main.nf +++ b/modules/gatk/unifiedgenotyper/main.nf @@ -9,13 +9,13 @@ process GATK_UNIFIEDGENOTYPER { input: tuple val(meta), path(input), path(index) - path(fasta) - path(fai) - path(dict) - path(intervals) - path(contamination) - path(dbsnp) - path(comp) + path fasta + path fai + path dict + path intervals + path contamination + path dbsnp + path comp output: tuple val(meta), path("*.vcf.gz"), emit: vcf