From 6e218123f98d1fbc81aaae496b0c4b2401561702 Mon Sep 17 00:00:00 2001 From: Jorisvansteenbrugge <7196110+Jorisvansteenbrugge@users.noreply.github.com> Date: Wed, 8 Apr 2026 17:01:10 +0200 Subject: [PATCH] demo prs modules --- UMCUGenetics/pgscatalog/combine/main.nf | 27 +++++++++ .../pgscatalog/combine/tests/main.nf.test | 27 +++++++++ UMCUGenetics/pgscatalog/match/main.nf | 42 ++++++++++++++ .../pgscatalog/match/tests/main.nf.test | 58 +++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 UMCUGenetics/pgscatalog/combine/main.nf create mode 100644 UMCUGenetics/pgscatalog/combine/tests/main.nf.test create mode 100644 UMCUGenetics/pgscatalog/match/main.nf create mode 100644 UMCUGenetics/pgscatalog/match/tests/main.nf.test diff --git a/UMCUGenetics/pgscatalog/combine/main.nf b/UMCUGenetics/pgscatalog/combine/main.nf new file mode 100644 index 0000000..a651c19 --- /dev/null +++ b/UMCUGenetics/pgscatalog/combine/main.nf @@ -0,0 +1,27 @@ +process PGSCATALOG_COMBINE { + tag "${meta.id}" + + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container + ? 'https://depot.galaxyproject.org/singularity/pgscatalog-utils:1.4.4--pyhdfd78af_0' + : 'biocontainers/pgscatalog-utils:1.4.4--pyhdfd78af_0'}" + + input: + tuple val(meta), path(scoring_file) + val assembly_version + + output: + tuple val(meta), path("*_normalised.txt.gz"), emit: normalised_model + path "versions.yml", emit: versions + + script: + def prefix = task.ext.prefix ?: meta.id + """ + pgscatalog-combine \\ + -s ${scoring_file} \\ + -t ${assembly_version} \\ + -o ${prefix}_normalised.txt.gz + + + echo "pgscatalog-combine: 1.4.4" > versions.yml + """ +} diff --git a/UMCUGenetics/pgscatalog/combine/tests/main.nf.test b/UMCUGenetics/pgscatalog/combine/tests/main.nf.test new file mode 100644 index 0000000..748609f --- /dev/null +++ b/UMCUGenetics/pgscatalog/combine/tests/main.nf.test @@ -0,0 +1,27 @@ +nextflow_process { + name "Test Process PGScatalog-combine" + script "../main.nf" + process "PGSCATALOG_COMBINE" + + tag "modules/local" + + + test("Test Correct model formatting "){ + when{ + process{ + """ + input[0] = [[id: 'model'], + file("${projectDir}/assets/models/BCAC_313_PRS_GRCh38.txt", + checkifExists: true)] + input[1] = channel.value("GRCh38") + """ + } + + then { + assertAll( + {assert process.success}, + ) + } + } + } +} diff --git a/UMCUGenetics/pgscatalog/match/main.nf b/UMCUGenetics/pgscatalog/match/main.nf new file mode 100644 index 0000000..8d2db1b --- /dev/null +++ b/UMCUGenetics/pgscatalog/match/main.nf @@ -0,0 +1,42 @@ +process PGSCATALOG_MATCH { + tag "${meta.id}" + + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container + ? 'https://depot.galaxyproject.org/singularity/pgscatalog-utils:1.4.4--pyhdfd78af_0' + : 'biocontainers/pgscatalog-utils:1.4.4--pyhdfd78af_0'}" + + input: + tuple val(meta), path(pvar) + tuple val(meta2), path(scoring_file) + + + output: + tuple val(meta), path("*_summary.csv"), emit: summary + tuple val(meta), path("*.scorefile.gz"), emit: scorefile + tuple val(meta), path("*_log.csv.gz"), emit: log + path "versions.yml", emit: versions + + script: + def prefix = task.ext.prefix ?: meta.id + def args = task.ext.args ?: "" + """ + pgscatalog-match \\ + ${args} \\ + --dataset ${prefix} \\ + --scorefiles ${scoring_file} \\ + --target ${pvar} \\ + --outdir ./ + + echo "pgscatalog-match: 1.4.4" > versions.yml + """ + + stub: + def prefix = task.ext.prefix ?: "Cohort" + """ + touch ${prefix}_summary.csv + touch ${prefix}.scorefile.gz + touch ${prefix}_log.csv.gz + + echo "pgscatalog-match: 1.4.4" > versions.yml + """ +} diff --git a/UMCUGenetics/pgscatalog/match/tests/main.nf.test b/UMCUGenetics/pgscatalog/match/tests/main.nf.test new file mode 100644 index 0000000..176b6ad --- /dev/null +++ b/UMCUGenetics/pgscatalog/match/tests/main.nf.test @@ -0,0 +1,58 @@ +nextflow_process { + name "Test Process PGScatalog-match" + script "../main.nf" + process "PGSCATALOG_MATCH" + + + + tag "modules/local" + + test("Test SNV ambiguity detection"){ + setup{ + run("PLINK2_VCF") { + script "../../../../nf-core/plink2/vcf/main.nf" + + process{ + """ + input[0] = [[id: "vcf"], file("${projectDir}/assets/test-data/test.vcf",checkIfExists: true)] + """ + } + } + } + + when { + process { + """ + input[0] = [[id: "model"], + file( + "${projectDir}/assets/test-data/norm_test_model_subworkflow.txt.gz", + checkIfExists: true)] + input[1] = PLINK2_VCF.out.pvar_zst + + """ + } + } + then { + // Analysing the csv is necessary as the snapshots do not always match + // (row order differs) + def csv = path(process.out.summary[0][1]).csv().table + def matched = csv.stringColumn("match_status").isEqualTo("matched") + + def n_ambiguous_SNV = csv.where( + csv.booleanColumn("ambiguous").isTrue().and(matched) + ).row(0).getInt("count") + + def n_unambiguous_SNV = csv.where( + csv.booleanColumn("ambiguous").isFalse().and(matched) + ).row(0).getInt("count") + + assertAll ( + {assert process.success}, + {assert n_ambiguous_SNV == 1}, + {assert n_unambiguous_SNV == 3} + ) + } + + + } +}