From 70deecf2a6dfd6a7cae5d87ac961035ae92ae0fa Mon Sep 17 00:00:00 2001 From: finlayclark Date: Fri, 15 Nov 2024 14:28:32 +0000 Subject: [PATCH] Improve error messages if no lambda windows found during analysis [ci skip] --- python/BioSimSpace/FreeEnergy/_relative.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/python/BioSimSpace/FreeEnergy/_relative.py b/python/BioSimSpace/FreeEnergy/_relative.py index 4e197f1dc..7e9c4027d 100644 --- a/python/BioSimSpace/FreeEnergy/_relative.py +++ b/python/BioSimSpace/FreeEnergy/_relative.py @@ -1435,6 +1435,12 @@ def _analyse_amber(work_dir=None, estimator="MBAR", method="alchemlyb", **kwargs for part in file.parts: if "lambda" in part: lambdas.append(float(part.split("_")[-1])) + if len(lambdas) == 0: + raise ValueError( + "No lambda windows were detected from the output directory names! " + "Ensure that the directory being analysed contains sub-directories" + "name e.g `lambda_0`, `lambda_1` containing the output files." + ) # Find the temperature for each lambda window. temperatures = [] @@ -1516,6 +1522,12 @@ def _analyse_gromacs(work_dir=None, estimator="MBAR", method="alchemlyb", **kwar for part in file.parts: if "lambda" in part: lambdas.append(float(part.split("_")[-1])) + if len(lambdas) == 0: + raise ValueError( + "No lambda windows were detected from the output directory names! " + "Ensure that the directory being analysed contains sub-directories" + "name e.g `lambda_0`, `lambda_1` containing the output files." + ) # Find the temperature at each lambda window temperatures = [] @@ -1685,6 +1697,12 @@ def _analyse_somd(work_dir=None, estimator="MBAR", method="alchemlyb", **kwargs) for part in file.parts: if "lambda" in part: lambdas.append(float(part.split("_")[-1])) + if len(lambdas) == 0: + raise ValueError( + "No lambda windows were detected from the output directory names! " + "Ensure that the directory being analysed contains sub-directories" + "name e.g `lambda_0`, `lambda_1` containing the output files." + ) temperatures = [] for file in files: