Skip to content

Commit

Permalink
Add more descriptive error message
Browse files Browse the repository at this point in the history
  • Loading branch information
padix-key committed May 31, 2024
1 parent d1606a4 commit 1081e99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/biotite/structure/info/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/biotite/structure/io/pdbx/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1081e99

Please sign in to comment.