From 61cdc61982a2159f1ebf0a0a59c97de6b4a7afb5 Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke <101190534+nvnieuwk@users.noreply.github.com> Date: Tue, 28 Feb 2023 13:52:17 +0100 Subject: [PATCH] new module survivor/merge (#2648) * new module survivor/merge * fix versions * review updates * add stubs * fix tests * changed conda according to #2654 * moved the args to input vals * update meta * update to latest decision * fix test * Update modules/nf-core/survivor/merge/main.nf Co-authored-by: Jonathan Manning --------- Co-authored-by: Jonathan Manning --- modules/nf-core/survivor/merge/main.nf | 71 +++++++++++++++++++ modules/nf-core/survivor/merge/meta.yml | 64 +++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/nf-core/survivor/merge/main.nf | 26 +++++++ .../nf-core/survivor/merge/nextflow.config | 5 ++ tests/modules/nf-core/survivor/merge/test.yml | 11 +++ 6 files changed, 181 insertions(+) create mode 100644 modules/nf-core/survivor/merge/main.nf create mode 100644 modules/nf-core/survivor/merge/meta.yml create mode 100644 tests/modules/nf-core/survivor/merge/main.nf create mode 100644 tests/modules/nf-core/survivor/merge/nextflow.config create mode 100644 tests/modules/nf-core/survivor/merge/test.yml diff --git a/modules/nf-core/survivor/merge/main.nf b/modules/nf-core/survivor/merge/main.nf new file mode 100644 index 00000000000..e09854a6c0f --- /dev/null +++ b/modules/nf-core/survivor/merge/main.nf @@ -0,0 +1,71 @@ +process SURVIVOR_MERGE { + tag "$meta.id" + label 'process_low' + + conda "bioconda::survivor=1.0.7" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/survivor:1.0.7--h9a82719_1': + 'quay.io/biocontainers/survivor:1.0.7--h9a82719_1' }" + + input: + tuple val(meta), path(vcfs) + val(max_distance_breakpoints) + val(min_supporting_callers) + val(account_for_type) + val(account_for_sv_strands) + val(estimate_distanced_by_sv_size) + val(min_sv_size) + + output: + tuple val(meta), path("*.vcf") , emit: vcf + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + + vcfs.each{ + if (it.getExtension() == "gz"){ + error "Gzipped files are not supported by Survivor, please gunzip your VCF files first." + // https://github.com/fritzsedlazeck/SURVIVOR/issues/158 + } + } + + """ + SURVIVOR merge \\ + <(ls *.vcf) \\ + ${max_distance_breakpoints} \\ + ${min_supporting_callers} \\ + ${account_for_type} \\ + ${account_for_sv_strands} \\ + ${estimate_distanced_by_sv_size} \\ + ${min_sv_size} \\ + ${prefix}.vcf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + survivor: \$(echo \$(SURVIVOR 2>&1 | grep "Version" | sed 's/^Version: //')) + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + + vcfs.each{ + if (it.getExtension() == "gz"){ + error "Gzipped files are not supported by Survivor, please gunzip your VCF files first." + // https://github.com/fritzsedlazeck/SURVIVOR/issues/158 + } + } + + """ + touch ${prefix}.vcf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + survivor: \$(echo \$(SURVIVOR 2>&1 | grep "Version" | sed 's/^Version: //')) + END_VERSIONS + """ +} diff --git a/modules/nf-core/survivor/merge/meta.yml b/modules/nf-core/survivor/merge/meta.yml new file mode 100644 index 00000000000..5e5310827a1 --- /dev/null +++ b/modules/nf-core/survivor/merge/meta.yml @@ -0,0 +1,64 @@ +name: "survivor_merge" +description: Compare or merge VCF files to generate a consensus or multi sample VCF files. +keywords: + - survivor + - merge + - vcf + - structural variants +tools: + - "survivor": + description: "Toolset for SV simulation, comparison and filtering" + homepage: "https://github.com/fritzsedlazeck/SURVIVOR/wiki" + documentation: "https://github.com/fritzsedlazeck/SURVIVOR/wiki" + tool_dev_url: "https://github.com/fritzsedlazeck/SURVIVOR" + doi: "10.1038/NCOMMS14061" + licence: "['MIT']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - vcfs: + type: files + description: | + The VCF files to be merged + Gzipped VCF files are not supported: https://github.com/fritzsedlazeck/SURVIVOR/issues/158 + pattern: "*.vcf" + - max_distance_breakpoints: + type: integer + description: Max distance between breakpoints (0-1 percent of length, 1- number of bp) + - min_supporting_callers: + type: integer + description: Minimum number of supporting caller + - account_for_type: + type: integer + description: Take the type into account (1==yes, else no) + - account_for_sv_strands: + type: integer + description: Take the strands of SVs into account (1==yes, else no) + - estimate_distanced_by_sv_size: + type: integer + description: Estimate distance based on the size of SV (1==yes, else no) + - min_sv_size: + type: integer + description: Minimum size of SVs to be taken into account + +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" + - vcf: + type: file + description: The merged VCF file + pattern: "*.vcf" + +authors: + - "@nvnieuwk" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 3ea44caaf2a..b0aba07694b 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -3135,6 +3135,10 @@ subworkflows/vcf_gather_bcftools: - subworkflows/nf-core/vcf_gather_bcftools/** - tests/subworkflows/nf-core/vcf_gather_bcftools/** +survivor/merge: + - modules/nf-core/survivor/merge/** + - tests/modules/nf-core/survivor/merge/** + subworkflows/vcf_impute_glimpse: - subworkflows/nf-core/vcf_impute_glimpse/** - tests/subworkflows/nf-core/vcf_impute_glimpse/** diff --git a/tests/modules/nf-core/survivor/merge/main.nf b/tests/modules/nf-core/survivor/merge/main.nf new file mode 100644 index 00000000000..c1e7b7c4353 --- /dev/null +++ b/tests/modules/nf-core/survivor/merge/main.nf @@ -0,0 +1,26 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SURVIVOR_MERGE } from '../../../../../modules/nf-core/survivor/merge/main.nf' + +workflow test_survivor_merge { + + input = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.test_data['homo_sapiens']['illumina']['test2_genome_vcf'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_genome_vcf'], checkIfExists: true) + ] + ] + + SURVIVOR_MERGE ( + input, + 0.2, + 1, + 0, + 0, + 0, + 20 + ) +} diff --git a/tests/modules/nf-core/survivor/merge/nextflow.config b/tests/modules/nf-core/survivor/merge/nextflow.config new file mode 100644 index 00000000000..8730f1c4b93 --- /dev/null +++ b/tests/modules/nf-core/survivor/merge/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/nf-core/survivor/merge/test.yml b/tests/modules/nf-core/survivor/merge/test.yml new file mode 100644 index 00000000000..2ad3170cb07 --- /dev/null +++ b/tests/modules/nf-core/survivor/merge/test.yml @@ -0,0 +1,11 @@ +- name: survivor merge test_survivor_merge + command: nextflow run ./tests/modules/nf-core/survivor/merge -entry test_survivor_merge -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/survivor/merge/nextflow.config + tags: + - survivor + - survivor/merge + files: + - path: output/survivor/test.vcf + contains: + - "##fileformat=VCFv4.1" + - "##source=SURVIVOR" + - path: output/survivor/versions.yml