From 83d52d0c39a64261ede7f45ef810d7d69090600d Mon Sep 17 00:00:00 2001 From: jemten Date: Wed, 30 Oct 2024 16:53:33 +0100 Subject: [PATCH 1/3] update createCaseChannel --- lib/CustomFunctions.groovy | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/CustomFunctions.groovy b/lib/CustomFunctions.groovy index 1a8d0227..f7d0434d 100644 --- a/lib/CustomFunctions.groovy +++ b/lib/CustomFunctions.groovy @@ -2,34 +2,39 @@ import nextflow.Nextflow class CustomFunctions { + // Helper function to check if a value is neither 0, "0", nor "" + private static boolean isNonZeroNonEmpty(value) { + return (value instanceof String && value != "" && value != "0") || + (value instanceof Number && value != 0) + } // Function to get a list of metadata (e.g. case id) for the case [ meta ] public static LinkedHashMap createCaseChannel(List rows) { def case_info = [:] - def probands = [] - def upd_children = [] + def probands = [] as Set + def upd_children = [] as Set def father = "" def mother = "" - for (item in rows) { - if (item.phenotype == 2) { - probands.add(item.sample) + rows.each { item -> + if (item?.phenotype == 2) { + probands << item.sample } - if ( (item.paternal!="0") && (item.paternal!="") && (item.maternal!="0") && (item.maternal!="") ) { - upd_children.add(item.sample) + if (isNonZeroNonEmpty(item?.paternal) && isNonZeroNonEmpty(item?.maternal)) { + upd_children << item.sample } - if ( (item.paternal!="0") && (item.paternal!="") ) { + if (isNonZeroNonEmpty(item?.paternal)) { father = item.paternal } - if ( (item.maternal!="0") && (item.maternal!="") ) { + if (isNonZeroNonEmpty(item?.maternal)) { mother = item.maternal } } case_info.father = father case_info.mother = mother - case_info.probands = probands.unique() - case_info.upd_children = upd_children.unique() + case_info.probands = probands.toList() + case_info.upd_children = upd_children.toList() case_info.id = rows[0].case_id return case_info From c76e493655a83a75541dc5394d207fa9f94aec65 Mon Sep 17 00:00:00 2001 From: jemten Date: Wed, 30 Oct 2024 17:01:21 +0100 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f082a8c..9e566e1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - bcftools annotate declaration in annotate CADD subworkflow [#624](https://github.com/nf-core/raredisease/pull/624) - Rhocallviz subworkflow will only be invocated once per sample [#621](https://github.com/nf-core/raredisease/pull/621) - Allow for VEP version 112 to be used and set it to default [#617](https://github.com/nf-core/raredisease/pull/617) +- Updated createCaseChannel function to include a check for maternal and paternal ids being set to a numeric 0 [#643](https://github.com/nf-core/raredisease/pull/643) ### Parameters From 460695711b5cab977a0a3f89d841216efdfa0b66 Mon Sep 17 00:00:00 2001 From: jemten Date: Wed, 30 Oct 2024 17:10:54 +0100 Subject: [PATCH 3/3] linting --- lib/CustomFunctions.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CustomFunctions.groovy b/lib/CustomFunctions.groovy index f7d0434d..00680f09 100644 --- a/lib/CustomFunctions.groovy +++ b/lib/CustomFunctions.groovy @@ -5,7 +5,7 @@ class CustomFunctions { // Helper function to check if a value is neither 0, "0", nor "" private static boolean isNonZeroNonEmpty(value) { return (value instanceof String && value != "" && value != "0") || - (value instanceof Number && value != 0) + (value instanceof Number && value != 0) } // Function to get a list of metadata (e.g. case id) for the case [ meta ]