From bad2110a3f1ef3fbe2232517fb908a371d445909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theresa=20St=C3=B6riko?= <73145457+tstoeriko@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:49:19 +0100 Subject: [PATCH] New module svtypersso (#5311) * Add module svtypersso * Adjust formatting - align equal signs --- .../svtyper/svtypersso/environment.yml | 7 + modules/nf-core/svtyper/svtypersso/main.nf | 57 +++++++ modules/nf-core/svtyper/svtypersso/meta.yml | 68 +++++++++ .../svtyper/svtypersso/tests/main.nf.test | 129 ++++++++++++++++ .../svtypersso/tests/main.nf.test.snap | 140 ++++++++++++++++++ .../nf-core/svtyper/svtypersso/tests/tags.yml | 2 + 6 files changed, 403 insertions(+) create mode 100644 modules/nf-core/svtyper/svtypersso/environment.yml create mode 100644 modules/nf-core/svtyper/svtypersso/main.nf create mode 100644 modules/nf-core/svtyper/svtypersso/meta.yml create mode 100644 modules/nf-core/svtyper/svtypersso/tests/main.nf.test create mode 100644 modules/nf-core/svtyper/svtypersso/tests/main.nf.test.snap create mode 100644 modules/nf-core/svtyper/svtypersso/tests/tags.yml diff --git a/modules/nf-core/svtyper/svtypersso/environment.yml b/modules/nf-core/svtyper/svtypersso/environment.yml new file mode 100644 index 00000000000..b00cc4338ba --- /dev/null +++ b/modules/nf-core/svtyper/svtypersso/environment.yml @@ -0,0 +1,7 @@ +name: "svtyper_svtypersso" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::svtyper=0.7.1" diff --git a/modules/nf-core/svtyper/svtypersso/main.nf b/modules/nf-core/svtyper/svtypersso/main.nf new file mode 100644 index 00000000000..123a12495b9 --- /dev/null +++ b/modules/nf-core/svtyper/svtypersso/main.nf @@ -0,0 +1,57 @@ +process SVTYPER_SVTYPERSSO { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/svtyper:0.7.1--py_0': + 'biocontainers/svtyper:0.7.1--py_0' }" + + input: + tuple val(meta), path(bam), path(bam_index), path(vcf) + tuple val(meta2), path(fasta) + + output: + tuple val(meta), path("*.vcf") , emit: gt_vcf + tuple val(meta), path("*.json"), emit: json + 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 vcf = vcf ? "--input_vcf ${vcf}" : "" + def fasta = fasta ? "--ref_fasta ${fasta}" : "" + if ("$vcf" == "${prefix}.vcf") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + if ("$bam" == "${prefix}.bam") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + """ + svtyper-sso \\ + --bam $bam \\ + $vcf \\ + $fasta \\ + --output_vcf ${prefix}.vcf \\ + --lib_info ${prefix}.json \\ + --cores $task.cpus \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + svtyper: \$(echo \$(svtyper-sso -h 2>&1 | grep "version:" | sed 's/^version: v//')) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.json + touch ${prefix}.vcf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + svtyper: \$(echo \$(svtyper-sso -h 2>&1 | grep "version:" | sed 's/^version: v//')) + END_VERSIONS + """ +} diff --git a/modules/nf-core/svtyper/svtypersso/meta.yml b/modules/nf-core/svtyper/svtypersso/meta.yml new file mode 100644 index 00000000000..edbf8e3ce5c --- /dev/null +++ b/modules/nf-core/svtyper/svtypersso/meta.yml @@ -0,0 +1,68 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "svtyper_svtypersso" +description: SVTyper-sso computes structural variant (SV) genotypes based on breakpoint depth on a SINGLE sample +keywords: + - sv + - structural variants + - genotyping + - Bayesian +tools: + - "svtyper": + description: "Bayesian genotyper for structural variants" + homepage: "https://github.com/hall-lab/svtyper" + documentation: "https://github.com/hall-lab/svtyper" + tool_dev_url: "https://github.com/hall-lab/svtyper" + doi: "10.1038/nmeth.3505" + licence: ["MIT"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test'] + - meta2: + type: map + description: | + Groovy Map containing sample information for reference FASTA file + e.g. [ id:'fasta'] + - bam: + type: file + description: BAM or CRAM file with alignments + pattern: "*.{bam,cram}" + - bam_index: + type: file + description: BAI file matching the BAM file + pattern: "*.{bai}" + - vcf: + type: file + description: Matching VCF of alignments + pattern: "*.vcf" + - fasta: + type: file + description: indexed reference FASTA file (recommended for reading CRAM files) + pattern: "*.{fa,fasta}" + +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" + - json: + type: file + description: JSON file including library information + pattern: "*.json" + - gt_vcf: + type: file + description: Genotyped SVs + pattern: "*.vcf" +authors: + - "@tstoeriko" +maintainers: + - "@tstoeriko" diff --git a/modules/nf-core/svtyper/svtypersso/tests/main.nf.test b/modules/nf-core/svtyper/svtypersso/tests/main.nf.test new file mode 100644 index 00000000000..b263f3be7f0 --- /dev/null +++ b/modules/nf-core/svtyper/svtypersso/tests/main.nf.test @@ -0,0 +1,129 @@ +nextflow_process { + + name "Test Process SVTYPER_SVTYPERSSO" + script "../main.nf" + process "SVTYPER_SVTYPERSSO" + + tag "modules" + tag "modules_nfcore" + tag "svtyper" + tag "svtyper/svtypersso" + + test("homo_sapiens - bam - vcf - fasta") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf', checkIfExists: true) + ] + input[1] = [ + [ id:'reference' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.gt_vcf, + process.out.versions).match("bam_vcf_fasta") }, + { assert file(process.out.json.get(0).get(1)).exists() } + ) + } + } + + test("homo_sapiens - bam - vcf - fasta - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf', checkIfExists: true) + ] + input[1] = [ + [ id:'reference' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match("bam_vcf_fasta_stub") } + ) + } + } + + test("homo_sapiens - bam") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true), + [] + ] + input[1] = [ + [ id:'reference' ], // meta map + [] + ] + """ + } + } + + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.gt_vcf, + process.out.versions).match("bam") }, + { assert file(process.out.json.get(0).get(1)).exists() } + ) + } + } + + test("homo_sapiens - bam - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true), + [] + ] + input[1] = [ + [ id:'reference' ], // meta map + [] + ] + """ + } + } + + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match("bam_stub") } + ) + } + } +} diff --git a/modules/nf-core/svtyper/svtypersso/tests/main.nf.test.snap b/modules/nf-core/svtyper/svtypersso/tests/main.nf.test.snap new file mode 100644 index 00000000000..e83a9345e89 --- /dev/null +++ b/modules/nf-core/svtyper/svtypersso/tests/main.nf.test.snap @@ -0,0 +1,140 @@ +{ + "bam_vcf_fasta_stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.json:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + "versions.yml:md5,5fae80f0d38e21c8f42733cf3ef61665" + ], + "gt_vcf": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "json": [ + [ + { + "id": "test" + }, + "test.json:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,5fae80f0d38e21c8f42733cf3ef61665" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-20T08:49:25.044877605" + }, + "bam_vcf_fasta": { + "content": [ + [ + [ + { + "id": "test" + }, + "test.vcf:md5,aee556ba714a2a3d64fb4fc9f2753cea" + ] + ], + [ + "versions.yml:md5,5fae80f0d38e21c8f42733cf3ef61665" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-20T08:30:52.404061568" + }, + "bam": { + "content": [ + [ + [ + { + "id": "test" + }, + "test.vcf:md5,b4a4e316e8524535ca1d3f26ad39ac78" + ] + ], + [ + "versions.yml:md5,5fae80f0d38e21c8f42733cf3ef61665" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-20T08:31:15.057840812" + }, + "bam_stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.json:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + "versions.yml:md5,5fae80f0d38e21c8f42733cf3ef61665" + ], + "gt_vcf": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "json": [ + [ + { + "id": "test" + }, + "test.json:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,5fae80f0d38e21c8f42733cf3ef61665" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-20T08:49:53.327743119" + } +} \ No newline at end of file diff --git a/modules/nf-core/svtyper/svtypersso/tests/tags.yml b/modules/nf-core/svtyper/svtypersso/tests/tags.yml new file mode 100644 index 00000000000..da061baf163 --- /dev/null +++ b/modules/nf-core/svtyper/svtypersso/tests/tags.yml @@ -0,0 +1,2 @@ +svtyper/svtypersso: + - "modules/nf-core/svtyper/svtypersso/**"