From 80c3624865578552fb8e42ccff151ca9857ee44a Mon Sep 17 00:00:00 2001 From: hemmerj3 Date: Thu, 16 May 2024 09:54:09 +0200 Subject: [PATCH] except error --- molpipeline/mol2any/mol2rdkit_phys_chem.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/molpipeline/mol2any/mol2rdkit_phys_chem.py b/molpipeline/mol2any/mol2rdkit_phys_chem.py index 9b9d7255..60dd8f93 100644 --- a/molpipeline/mol2any/mol2rdkit_phys_chem.py +++ b/molpipeline/mol2any/mol2rdkit_phys_chem.py @@ -108,9 +108,13 @@ def pretransform_single( Optional[npt.NDArray[np.float_]] Descriptor vector for given molecule. None if calculation failed. """ - vec = np.array( - [RDKIT_DESCRIPTOR_DICT[name](value) for name in self._descriptor_list] - ) + try: + vec = np.array( + [RDKIT_DESCRIPTOR_DICT[name](value) for name in self._descriptor_list] + ) + except ZeroDivisionError as e: + return InvalidInstance(self.uuid, f"Descriptor calculation failed, {e}", self.name) + if np.any(np.isnan(vec)): return InvalidInstance(self.uuid, "NaN in descriptor vector", self.name) return vec