From f44e6c74b4c51c5e49bc91e3d9d225544b5c1685 Mon Sep 17 00:00:00 2001 From: Ramprasad Neethiraj <20065894+ramprasadn@users.noreply.github.com> Date: Fri, 4 Feb 2022 15:29:44 +0100 Subject: [PATCH] Add svdb/merge (#1233) * nf-core create * svdb merge module and test * remove to-do from test.yml * version * update meta.yml * add stub * add when --- modules/svdb/merge/main.nf | 52 ++++++++++++++++++++++++ modules/svdb/merge/meta.yml | 39 ++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/svdb/merge/main.nf | 16 ++++++++ tests/modules/svdb/merge/nextflow.config | 5 +++ tests/modules/svdb/merge/test.yml | 7 ++++ 6 files changed, 123 insertions(+) create mode 100644 modules/svdb/merge/main.nf create mode 100644 modules/svdb/merge/meta.yml create mode 100644 tests/modules/svdb/merge/main.nf create mode 100644 tests/modules/svdb/merge/nextflow.config create mode 100644 tests/modules/svdb/merge/test.yml diff --git a/modules/svdb/merge/main.nf b/modules/svdb/merge/main.nf new file mode 100644 index 00000000..1f479ea4 --- /dev/null +++ b/modules/svdb/merge/main.nf @@ -0,0 +1,52 @@ +process SVDB_MERGE { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::svdb=2.5.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/svdb:2.5.0--py39hcbe4a3b_0': + 'quay.io/biocontainers/svdb:2.5.0--py39hcbe4a3b_0' }" + + input: + tuple val(meta), path(vcfs) + val (priority) + + output: + tuple val(meta), path("*_sv_merge.vcf"), emit: vcf + 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 input = "" + for (int index = 0; index < vcfs.size(); index++) { + input += " ${vcfs[index]}:${priority[index]}" + } + """ + svdb \\ + --merge \\ + $args \\ + --priority ${priority.join(',')} \\ + --vcf $input \\ + > ${prefix}_sv_merge.vcf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + svdb: \$( echo \$(svdb) | head -1 | sed 's/usage: SVDB-\\([0-9]\\.[0-9]\\.[0-9]\\).*/\\1/' ) + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}_sv_merge.vcf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + svdb: \$( echo \$(svdb) | head -1 | sed 's/usage: SVDB-\\([0-9]\\.[0-9]\\.[0-9]\\).*/\\1/' ) + END_VERSIONS + """ +} diff --git a/modules/svdb/merge/meta.yml b/modules/svdb/merge/meta.yml new file mode 100644 index 00000000..2092ddd9 --- /dev/null +++ b/modules/svdb/merge/meta.yml @@ -0,0 +1,39 @@ +name: svdb_merge +description: The merge module merges structural variants within one or more vcf files. +keywords: + - structural variants +tools: + - svdb: + description: structural variant database software + homepage: https://github.com/J35P312/SVDB + documentation: https://github.com/J35P312/SVDB/blob/master/README.md + licence: ['MIT'] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - priority: + type: list + description: prioritise the input vcf files according to this list, e.g ['tiddit','cnvnator'] + - vcfs: + type: list + description: Two or more VCF files. Order of files should correspond to the order of tags used for priority. + pattern: "*.{vcf,vcf.gz}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - vcf: + type: file + description: merged VCF file + pattern: "*_sv_merge.vcf" +authors: + - "@ramprasadn" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index b6b906f4..203005da 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1445,6 +1445,10 @@ subread/featurecounts: - modules/subread/featurecounts/** - tests/modules/subread/featurecounts/** +svdb/merge: + - modules/svdb/merge/** + - tests/modules/svdb/merge/** + svdb/query: - modules/svdb/query/** - tests/modules/svdb/query/** diff --git a/tests/modules/svdb/merge/main.nf b/tests/modules/svdb/merge/main.nf new file mode 100644 index 00000000..f417c3f7 --- /dev/null +++ b/tests/modules/svdb/merge/main.nf @@ -0,0 +1,16 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SVDB_MERGE } from '../../../../modules/svdb/merge/main.nf' + +workflow test_svdb_merge { + + input = [ [ id:'test' ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test2_vcf'], checkIfExists: true) ] + ] + priority = [ 'tiddit', 'cnvnator'] + + SVDB_MERGE ( input, priority ) +} diff --git a/tests/modules/svdb/merge/nextflow.config b/tests/modules/svdb/merge/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/svdb/merge/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/svdb/merge/test.yml b/tests/modules/svdb/merge/test.yml new file mode 100644 index 00000000..8d16562f --- /dev/null +++ b/tests/modules/svdb/merge/test.yml @@ -0,0 +1,7 @@ +- name: svdb merge + command: nextflow run ./tests/modules/svdb/merge -entry test_svdb_merge -c ./tests/config/nextflow.config -c ./tests/modules/svdb/merge/nextflow.config + tags: + - svdb + - svdb/merge + files: + - path: output/svdb/test_sv_merge.vcf