project-gemmi / gemmi

macromolecular crystallography library and utilities
https://project-gemmi.github.io/
Mozilla Public License 2.0
205 stars 42 forks source link

Adding additional properties to the Structure object present in the cif atom_site table #304

Closed danny305 closed 2 months ago

danny305 commented 3 months ago

We often append additional columns (RSA/SASA values, charge calculations, atomic radii, and additional atom features) to the atom_site table in a cif file.

However, whenever we read the cif file (struct = gemmi.read_structure(str(cif))) as a Structure object we lose all this additional data for each atom. Currently, we have to read in both the cif file as a gemmi.cif.Document and as a gemmi.Structure in order to get access to these additional atom_site columns and do our structure processing, respectively, and have to do some form of atom matching.

Could it be possible to add an additional property to the Structure object? This property can be a dictionary of all these additional atom_site columns.If anyone can point me to how we would implement this in the most reasonable way in Gemmi I would greatly appreciate it!

wojdyr commented 3 months ago

You can read it once, as cif.Document. Then you can obtain Structure from:

struct = gemmi.make_structure_from_block(doc[0])

If you want to have both Structure and your RSA/SASA data in one Python object, you could make such an object – a class that is derived from or contains gemmi.Structure.