From d21ecfdcfe0b8c263dd3ffd9f8e90aa5c5a80cca Mon Sep 17 00:00:00 2001 From: alsmith Date: Wed, 17 Apr 2024 16:39:02 +0100 Subject: [PATCH] Refactor get_group_for_sample function in helpers.py to handle missing samples in normalisation groups --- seqnado/helpers.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/seqnado/helpers.py b/seqnado/helpers.py index 16f91e2d..dc656d27 100644 --- a/seqnado/helpers.py +++ b/seqnado/helpers.py @@ -230,9 +230,14 @@ def pepe_silvia(): def get_group_for_sample(wildcards, design: Union[Design, DesignIP]): from seqnado.design import NormGroups - norm_groups = NormGroups.from_design(design) - group = norm_groups.get_sample_group(wildcards.sample) - return group + norm_groups = NormGroups.from_design(design, include_controls=True) + + try: + group = norm_groups.get_sample_group(wildcards.sample) + return group + except KeyError: + logger.error(f"Sample {wildcards.sample} not found in normalisation groups.") + raise KeyError(f"Sample {wildcards.sample} not found in normalisation groups.") def get_scale_method(config: Dict) -> Optional[str]: """