From 1081e993e59e18829354cba1373696a1635d93e2 Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Fri, 31 May 2024 15:34:06 +0200 Subject: [PATCH] Add more descriptive error message --- src/biotite/structure/info/atoms.py | 7 ++++++- src/biotite/structure/io/pdbx/convert.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/biotite/structure/info/atoms.py b/src/biotite/structure/info/atoms.py index 3a3290334..6ab063a99 100644 --- a/src/biotite/structure/info/atoms.py +++ b/src/biotite/structure/info/atoms.py @@ -72,6 +72,11 @@ def residue(res_name): # Avoid circular import from ..io.pdbx import get_component - component = get_component(get_ccd(), res_name=res_name) + try: + component = get_component(get_ccd(), res_name=res_name) + except KeyError: + raise KeyError( + f"No atom information found for residue '{res_name}' in CCD" + ) component.hetero[:] = res_name not in non_hetero_residues return component diff --git a/src/biotite/structure/io/pdbx/convert.py b/src/biotite/structure/io/pdbx/convert.py index c347e8abe..fdc44ff1a 100644 --- a/src/biotite/structure/io/pdbx/convert.py +++ b/src/biotite/structure/io/pdbx/convert.py @@ -1112,7 +1112,7 @@ def get_component(pdbx_file, data_block=None, use_ideal_coord=True, atom_category = _filter( atom_category, atom_category["comp_id"].as_array() == res_name ) - if len(atom_category) == 0: + if atom_category.row_count == 0: raise KeyError( f"No rows with residue name '{res_name}' found in " f"'chem_comp_atom' category"