Skip to content

Load chemical component (ligand) CIF files lacking atom_site records - #1437

Merged
swails merged 2 commits into
ParmEd:masterfrom
barlowa124:cif-chem-comp-1431
Oct 9, 2026
Merged

swails merged 2 commits into
ParmEd:masterfrom
barlowa124:cif-chem-comp-1431

Conversation

@barlowa124

Copy link
Copy Markdown
Contributor

Fixes #1431.

parmed.load_file raised AttributeError: 'NoneType' object has no attribute 'getAttributeIndex' on chemical component CIF files because they have no atom_site category. Their atom records live under _chem_comp_atom and bonds under _chem_comp_bond.

When atom_site is absent, CIFFile.parse now reads _chem_comp_atom into the Structure: atom names, elements, formal charges, one residue per distinct comp_id, and coordinates from model_Cartn_* with pdbx_model_Cartn_*_ideal as a fallback. _chem_comp_bond rows become struct.bonds entries with QualitativeBondType orders, the same mapping _process_struct_conn uses. Structures with bonds from _chem_comp_bond skip assign_bonds, so file-declared connectivity is not re-derived by template or distance heuristics. A CIF with no atom records returns an empty Structure instead of crashing in assign_bonds' voxel partitioning.

A new regression test covers a 4-atom ligand fixture and an atom-less CIF. pytest test/test_parmed_formats.py passes locally on Python 3.9. With this branch, parmed.load_file on the real ATP.cif chemical component file returns a Structure holding all 47 atoms with deposited model coordinates.

parmed.load_file crashed with AttributeError on ligand CIF files, which
carry atom records under _chem_comp_atom and bonds under _chem_comp_bond
instead of _atom_site. Parse those categories into the Structure when
atom_site is absent, and return an empty Structure for CIF files with no
atom records instead of crashing in distance-based bond assignment.

Fixes ParmEd#1431

@swails swails left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@swails
swails merged commit 8bfe9ec into ParmEd:master Oct 9, 2026
3 checks passed
@CatChenal

Copy link
Copy Markdown

That's great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parmed. load_file cannot load a ligand .cif file

3 participants