From 4cb77a4b441394cba0ed1c22d38125f60ab73e53 Mon Sep 17 00:00:00 2001 From: Luke Zappia Date: Tue, 22 Oct 2024 15:29:48 +0200 Subject: [PATCH] Add arguments for filtering methods in benchmark workflow (#4) * Add arguments to filtering methods in benchmark WF * Apply suggestions from code review Co-authored-by: Robrecht Cannoodt * Tidy method argument definitions * Move checkMethodAllowed Nexflow helper to common * Move checkMethodAllowed Nexflow helper to common --------- Co-authored-by: Robrecht Cannoodt --- common | 2 +- src/workflows/run_benchmark/config.vsh.yaml | 19 ++++++++++++++++--- src/workflows/run_benchmark/main.nf | 11 ++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/common b/common index e64f472b..dabb6cef 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit e64f472b37f1bdbd383640098708ecf5c9f7fd7e +Subproject commit dabb6cef9a735e27cfc859a7afc9f5d6685f8635 diff --git a/src/workflows/run_benchmark/config.vsh.yaml b/src/workflows/run_benchmark/config.vsh.yaml index 3ed43a1e..51e482ab 100644 --- a/src/workflows/run_benchmark/config.vsh.yaml +++ b/src/workflows/run_benchmark/config.vsh.yaml @@ -42,12 +42,24 @@ argument_groups: required: true direction: output default: task_info.yaml - - name: Methods + - name: Method filtering + description: | + Use these arguments to filter methods by name. By default, all methods are + run. If `--methods_include` is defined, only those methods are run. If + `--methods_exclude` is defined, all methods except those specified are run. + These arguments are mutually exclusive, so only `--methods_include` OR + `--methods_exclude` can set but not both. arguments: - - name: "--method_ids" + - name: "--methods_include" type: string multiple: true - description: A list of method ids to run. If not specified, all methods will be run. + description: | + A list of method ids to include. If specified, only these methods will be run. + - name: "--methods_exclude" + type: string + multiple: true + description: | + A list of method ids to exclude. If specified, all methods except the ones listed will be run. resources: - type: nextflow_script @@ -55,6 +67,7 @@ resources: entrypoint: run_wf - type: file path: /_viash.yaml + - path: /common/nextflow_helpers/helper.nf dependencies: - name: h5ad/extract_uns_metadata diff --git a/src/workflows/run_benchmark/main.nf b/src/workflows/run_benchmark/main.nf index 2eff6d8d..69322a1a 100644 --- a/src/workflows/run_benchmark/main.nf +++ b/src/workflows/run_benchmark/main.nf @@ -1,3 +1,5 @@ +include { checkItemAllowed } from "${meta.resources_dir}/helper.nf" + workflow auto { findStates(params, meta.config) | meta.workflow.run( @@ -75,6 +77,7 @@ workflow run_wf { /*************************** * RUN METHODS AND METRICS * ***************************/ + score_ch = dataset_ch // run all methods @@ -88,7 +91,13 @@ workflow run_wf { // if the preferred normalisation is none at all, // we can pass whichever dataset we want def norm_check = (norm == "log_cp10k" && pref == "counts") || norm == pref - def method_check = !state.method_ids || state.method_ids.contains(comp.config.name) + def method_check = checkItemAllowed( + comp.config.name, + state.methods_include, + state.methods_exclude, + "methods_include", + "methods_exclude" + ) method_check && norm_check },