diff --git a/modules/nf-core/octopusv/merge/environment.yml b/modules/nf-core/octopusv/merge/environment.yml new file mode 100644 index 00000000000..583655a9621 --- /dev/null +++ b/modules/nf-core/octopusv/merge/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::octopusv=0.3.2" diff --git a/modules/nf-core/octopusv/merge/main.nf b/modules/nf-core/octopusv/merge/main.nf new file mode 100644 index 00000000000..8874a653e31 --- /dev/null +++ b/modules/nf-core/octopusv/merge/main.nf @@ -0,0 +1,50 @@ +process OCTOPUSV_MERGE { + tag "${meta.id}" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container + ? 'https://depot.galaxyproject.org/singularity/octopusv:0.3.2--pyhdfd78af_0' + : 'quay.io/biocontainers/octopusv:0.3.2--pyhdfd78af_0'}" + + input: + tuple val(meta), path(svcfs) + + output: + tuple val(meta), path("*.svcf"), emit: svcf + tuple val("${task.process}"), val('octopusv'), eval("python -c \"import importlib.metadata as m; print(m.version('octopusv'))\""), emit: versions_octopusv, topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = (task.ext.args ?: '').trim() + def prefix = task.ext.prefix ?: "${meta.id}" + + def strategy_flags = ['--union', '--intersect', '--specific', '--min-support', '--exact-support', '--max-support', '--expression'] + + def explicit_flags = strategy_flags.findAll { flag -> args.tokenize().contains(flag) } + if (explicit_flags.size() > 1) { + error("OCTOPUSV_MERGE: multiple merge strategies specified: ${explicit_flags.join(', ')}") + } + + if (explicit_flags.isEmpty()) { + args = "--union ${args}".trim() + } + + """ + octopusv merge -i ${svcfs.join(' ')} \\ + -o ${prefix}.svcf \\ + ${args} + """ + + stub: + def args = (task.ext.args ?: '').trim() + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + echo ${args} + + touch ${prefix}.svcf + """ +} diff --git a/modules/nf-core/octopusv/merge/meta.yml b/modules/nf-core/octopusv/merge/meta.yml new file mode 100644 index 00000000000..1721b8136b8 --- /dev/null +++ b/modules/nf-core/octopusv/merge/meta.yml @@ -0,0 +1,69 @@ +name: "octopusv_merge" +description: "Merge and harmonize structural variant calls from multiple samples." +keywords: + - structural variants + - merge + - genomics + - svcf +tools: + - "octopusv": + description: "End-to-end structural variant post-processing: standardize, merge, + compare, and export SVs." + homepage: "https://github.com/ylab-hi/OctopuSV" + documentation: "https://github.com/ylab-hi/OctopuSV" + tool_dev_url: "https://github.com/ylab-hi/octopusV" + doi: "10.1093/bioinformatics/btaf599" + licence: + - "MIT" + identifier: "" +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - svcfs: + type: file + description: List of SVCF files to merge + pattern: "*.svcf" + ontologies: + - edam: "http://edamontology.org/format_3016" + - edam: "http://edamontology.org/format_3615" +output: + svcf: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - "*.svcf": + type: file + description: Sorted VCF file + pattern: "*.svcf" + ontologies: + - edam: "http://edamontology.org/format_3016" + versions_octopusv: + - - ${task.process}: + type: string + description: The name of the process + - octopusv: + type: string + description: The name of the tool + - python -c "import importlib.metadata as m; print(m.version('octopusv'))": + type: eval + description: The expression to obtain the version of the tool +topics: + versions: + - - ${task.process}: + type: string + description: The name of the process + - octopusv: + type: string + description: The name of the tool + - python -c "import importlib.metadata as m; print(m.version('octopusv'))": + type: eval + description: The expression to obtain the version of the tool +authors: + - "@manascripts" +maintainers: + - "@manascripts" diff --git a/modules/nf-core/octopusv/merge/tests/main.nf.test b/modules/nf-core/octopusv/merge/tests/main.nf.test new file mode 100644 index 00000000000..6a49498ea8f --- /dev/null +++ b/modules/nf-core/octopusv/merge/tests/main.nf.test @@ -0,0 +1,68 @@ +nextflow_process { + + name "Test Process OCTOPUSV_MERGE" + script "../main.nf" + process "OCTOPUSV_MERGE" + + tag "modules" + tag "modules_nfcore" + tag "octopusv" + tag "octopusv/merge" + + test("homo_sapiens - svcf list") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/octopusv/sk-n-as-sniffles-ont.svcf', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/octopusv/sk-n-as-severus-ont.svcf', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + path(process.out.svcf.get(0).get(1)).vcf.summary, + path(process.out.svcf.get(0).get(1)).vcf.variantsMD5, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() } + ) + } + + } + + test("homo_sapiens - svcf list - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/octopusv/sk-n-as-sniffles-ont.svcf', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/octopusv/sk-n-as-severus-ont.svcf', checkIfExists: true) + ] + ] + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot(sanitizeOutput(process.out)).match() } + ) + } + + } + +} diff --git a/modules/nf-core/octopusv/merge/tests/main.nf.test.snap b/modules/nf-core/octopusv/merge/tests/main.nf.test.snap new file mode 100644 index 00000000000..737dd6ec002 --- /dev/null +++ b/modules/nf-core/octopusv/merge/tests/main.nf.test.snap @@ -0,0 +1,48 @@ +{ + "homo_sapiens - svcf list - stub": { + "content": [ + { + "svcf": [ + [ + { + "id": "test" + }, + "test.svcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions_octopusv": [ + [ + "OCTOPUSV_MERGE", + "octopusv", + "0.3.2" + ] + ] + } + ], + "timestamp": "2026-05-13T14:02:15.365401997", + "meta": { + "nf-test": "0.9.5", + "nextflow": "25.10.4" + } + }, + "homo_sapiens - svcf list": { + "content": [ + "VcfFile [chromosomes=[chr9, chr16_KI270728v1_random, chr7, chr8, chr8_KI270816v1_alt, chrUn_KI270757v1, chr5, chr17_KI270907v1_alt, chr6, chr3, chr21, chr11, chr22, chr4, chr2_KI270772v1_alt, chr1, chr12, chr15_ML143371v1_fix, chr14, chr8_KI270901v1_alt, chr16, chr17, chr7_KI270805v1_alt], sampleCount=1, variantCount=62, phased=false, phasedAutodetect=false]", + "df8a9f0a3e5b517ec23ffd6ee75fd4a0", + { + "versions_octopusv": [ + [ + "OCTOPUSV_MERGE", + "octopusv", + "0.3.2" + ] + ] + } + ], + "timestamp": "2026-05-13T14:04:02.989592821", + "meta": { + "nf-test": "0.9.5", + "nextflow": "25.10.4" + } + } +} \ No newline at end of file