From 09acfad211be75e964bc268ad7c45713733210c7 Mon Sep 17 00:00:00 2001 From: nvnieuwk <101190534+nvnieuwk@users.noreply.github.com> Date: Mon, 5 Sep 2022 10:49:13 +0200 Subject: [PATCH] new module gatk4/collectreadcounts (#1998) * added the module * updated test.yml * Update modules/gatk4/collectreadcounts/main.nf Co-authored-by: FriederikeHanssen * small fix * tests update * linting * tests update (again) Co-authored-by: FriederikeHanssen --- modules/gatk4/collectreadcounts/main.nf | 53 ++++++++++++++ modules/gatk4/collectreadcounts/meta.yml | 72 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/gatk4/collectreadcounts/main.nf | 54 ++++++++++++++ .../gatk4/collectreadcounts/nextflow.config | 17 +++++ .../modules/gatk4/collectreadcounts/test.yml | 25 +++++++ 6 files changed, 225 insertions(+) create mode 100644 modules/gatk4/collectreadcounts/main.nf create mode 100644 modules/gatk4/collectreadcounts/meta.yml create mode 100644 tests/modules/gatk4/collectreadcounts/main.nf create mode 100644 tests/modules/gatk4/collectreadcounts/nextflow.config create mode 100644 tests/modules/gatk4/collectreadcounts/test.yml diff --git a/modules/gatk4/collectreadcounts/main.nf b/modules/gatk4/collectreadcounts/main.nf new file mode 100644 index 00000000..ed64d931 --- /dev/null +++ b/modules/gatk4/collectreadcounts/main.nf @@ -0,0 +1,53 @@ +process GATK4_COLLECTREADCOUNTS { + tag "$meta.id" + label 'process_medium' + + 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(input), path(input_index), path(intervals) + path(fasta) + path(fai) + path(dict) + + output: + tuple val(meta), path("*.hdf5"), optional: true, emit: hdf5 + tuple val(meta), path("*.tsv") , optional: true, emit: tsv + 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 extension = args.contains("--format HDF5") ? "hdf5" : + args.contains("--format TSV") ? "tsv" : + "hdf5" + + def avail_mem = 3 + if (!task.memory) { + log.info '[GATK COLLECTREADCOUNTS] 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" CollectReadCounts \\ + --input $input \\ + --intervals $intervals \\ + --output ${prefix}.$extension \\ + $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/collectreadcounts/meta.yml b/modules/gatk4/collectreadcounts/meta.yml new file mode 100644 index 00000000..1dbddc59 --- /dev/null +++ b/modules/gatk4/collectreadcounts/meta.yml @@ -0,0 +1,72 @@ +name: "gatk4_collectreadcounts" +description: Collects read counts at specified intervals. The count for each interval is calculated by counting the number of read starts that lie in the interval. +keywords: + - bam + - cram + - CollectReadCounts + - gatk + - gatk4 +tools: + - gatk4: + description: + Genome Analysis Toolkit (GATK4). Developed in the Data Sciences Platform at the Broad Institute, the toolkit offers a wide variety of tools + with a primary focus on variant discovery and genotyping. Its powerful processing engine + and high-performance computing features make it capable of taking on projects of any size. + homepage: https://gatk.broadinstitute.org/hc/en-us + documentation: https://gatk.broadinstitute.org/hc/en-us/articles/360037593911-CombineGVCFs + tool_dev_url: https://github.com/broadinstitute/gatk + doi: 10.1158/1538-7445.AM2017-3590 + licence: ["Apache-2.0"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + - bai: + type: file + description: BAM/CRAM/SAM index file + pattern: "*.{bai,crai,sai}" + - intervals: + type: file + description: A file containing the specified intervals + pattern: "*.{bed,intervals}" + - fasta: + type: file + description: Optional - Reference FASTA + pattern: "*.{fasta,fa}" + - fai: + type: file + description: Optional - Index of the reference FASTA file + pattern: "*.fai" + - dict: + type: file + description: Optional - Sequence dictionary of the reference FASTA file + pattern: "*.dict" + +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" + - hdf5: + type: file + description: The read counts in hdf5 format + pattern: "*.hdf5" + - tsv: + type: file + description: The read counts in TSV format + pattern: "*.tsv" + +authors: + - "@nvnieuwk" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 50e8274f..fda99231 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -843,6 +843,10 @@ gatk4/cnnscorevariants: - modules/gatk4/cnnscorevariants/** - tests/modules/gatk4/cnnscorevariants/** +gatk4/collectreadcounts: + - modules/gatk4/collectreadcounts/** + - tests/modules/gatk4/collectreadcounts/** + gatk4/combinegvcfs: - modules/gatk4/combinegvcfs/** - tests/modules/gatk4/combinegvcfs/** diff --git a/tests/modules/gatk4/collectreadcounts/main.nf b/tests/modules/gatk4/collectreadcounts/main.nf new file mode 100644 index 00000000..9e69c018 --- /dev/null +++ b/tests/modules/gatk4/collectreadcounts/main.nf @@ -0,0 +1,54 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { GATK4_COLLECTREADCOUNTS } from '../../../../modules/gatk4/collectreadcounts/main.nf' + +workflow test_gatk4_collectreadcounts_hdf5 { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true), + ] + + fasta = [] + fai = [] + dict = [] + + GATK4_COLLECTREADCOUNTS ( input, fasta, fai, dict ) +} + +workflow test_gatk4_collectreadcounts_tsv { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true), + ] + + fasta = [] + fai = [] + dict = [] + + GATK4_COLLECTREADCOUNTS ( input, fasta, fai, dict ) +} + +workflow test_gatk4_collectreadcounts_cram { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true), + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + fai = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true) + dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true) + + GATK4_COLLECTREADCOUNTS ( input, fasta, fai, dict ) +} + diff --git a/tests/modules/gatk4/collectreadcounts/nextflow.config b/tests/modules/gatk4/collectreadcounts/nextflow.config new file mode 100644 index 00000000..3863bf92 --- /dev/null +++ b/tests/modules/gatk4/collectreadcounts/nextflow.config @@ -0,0 +1,17 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: 'test_gatk4_collectreadcounts_hdf5:GATK4_COLLECTREADCOUNTS'{ + ext.args = "--interval-merging-rule OVERLAPPING_ONLY" + } + + withName: 'test_gatk4_collectreadcounts_tsv:GATK4_COLLECTREADCOUNTS' { + ext.args = "--format TSV --interval-merging-rule OVERLAPPING_ONLY" + } + + withName: 'test_gatk4_collectreadcounts_cram:GATK4_COLLECTREADCOUNTS' { + ext.args = "--format TSV --interval-merging-rule OVERLAPPING_ONLY" + } + +} \ No newline at end of file diff --git a/tests/modules/gatk4/collectreadcounts/test.yml b/tests/modules/gatk4/collectreadcounts/test.yml new file mode 100644 index 00000000..1652f021 --- /dev/null +++ b/tests/modules/gatk4/collectreadcounts/test.yml @@ -0,0 +1,25 @@ +- name: gatk4 collectreadcounts test_gatk4_collectreadcounts_hdf5 + command: nextflow run ./tests/modules/gatk4/collectreadcounts -entry test_gatk4_collectreadcounts_hdf5 -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/collectreadcounts/nextflow.config + tags: + - gatk4/collectreadcounts + - gatk4 + files: + - path: output/gatk4/test.hdf5 + +- name: gatk4 collectreadcounts test_gatk4_collectreadcounts_tsv + command: nextflow run ./tests/modules/gatk4/collectreadcounts -entry test_gatk4_collectreadcounts_tsv -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/collectreadcounts/nextflow.config + tags: + - gatk4/collectreadcounts + - gatk4 + files: + - path: output/gatk4/test.tsv + md5sum: 8e45a6164916c303387f39f02ce45841 + +- name: gatk4 collectreadcounts test_gatk4_collectreadcounts_cram + command: nextflow run ./tests/modules/gatk4/collectreadcounts -entry test_gatk4_collectreadcounts_cram -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/collectreadcounts/nextflow.config + tags: + - gatk4/collectreadcounts + - gatk4 + files: + - path: output/gatk4/test.tsv + md5sum: d9a32039b7a84f5bb74e8382e5427670