Skip to content

Commit 99cc7f6

Browse files
committed
use unquoted atom ids
1 parent d004acc commit 99cc7f6

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

pdbeccdutils/core/ccd_reader.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,23 +331,29 @@ def _parse_pdb_bonds(mol, cif_block, errors):
331331
)
332332
atom_indices = {
333333
atom_id: atom_index
334-
for atom_index, atom_id in enumerate(
334+
for atom_index, _atom_id in enumerate(
335335
atoms.find_column("_chem_comp_atom.atom_id")
336-
)
336+
) if (atom_id := cif.as_string(_atom_id))
337337
}
338-
for row in bonds:
339-
atom_1 = row["_chem_comp_bond.atom_id_1"]
340-
atom_2 = row["_chem_comp_bond.atom_id_2"]
338+
for index, row in enumerate(bonds):
339+
atom_1 = cif.as_string(row["_chem_comp_bond.atom_id_1"])
340+
atom_2 = cif.as_string(row["_chem_comp_bond.atom_id_2"])
341341

342342
try:
343343
atom_1_id = atom_indices[atom_1]
344344
atom_2_id = atom_indices[atom_2]
345-
bond_order = helper.bond_pdb_order(row["_chem_comp_bond.value_order"])
345+
bond_order = helper.bond_pdb_order(cif.as_string(row["_chem_comp_bond.value_order"]))
346+
if bond_order is None:
347+
errors.append(
348+
f"""Unknown bond order {cif.as_string(row['_chem_comp_bond.value_order'])} in
349+
{index} entry in _chem_comp_bond"""
350+
)
351+
continue
346352

347353
mol.AddBond(atom_1_id, atom_2_id, bond_order)
348-
except (KeyError, ValueError):
354+
except KeyError:
349355
errors.append(
350-
f"Error perceiving {atom_1} - {atom_2} bond in _chem_comp_bond"
356+
f"Missing atom in {index} entry in _chem_comp_bond"
351357
)
352358
except RuntimeError:
353359
errors.append(f"Duplicit bond {atom_1} - {atom_2}")

0 commit comments

Comments
 (0)