ihmwg / python-ihm

Python package for handling IHM mmCIF and BinaryCIF files
MIT License
14 stars 7 forks source link

Missing elements in `ihm.ChemComp._element_mass` #99

Closed bienchen closed 1 year ago

bienchen commented 1 year ago

ihm.ChemComp._element_mass only contains atoms known to the peptide/ nucleic acid ChemComp classes. So _entity.formula_weight can not be calculated properly for a lot of non-poly entities. I can add elements to ihm.ChemComp._element_mass myself, but then Pylint (rightfully) complains about accessing a protected member of a class. While there are hacky workarounds for the message, it would be nice to have a proper way to handle elements.

A simple solution would be to add the whole periodic table to ihm.ChemComp. Otherwise it would be good to have a function to check if an element is known to ihm.ChemComp and a function to add new elements to prevent accessing _element_mass directly.

benmwebb commented 1 year ago

I've just added elements to the ihm.ChemComp._element_mass dictionary when I've needed them (e.g. it contains Fe which isn't in any peptide or nucleic acid). If you need others, just open a PR to add the masses you need (or the whole table if you like). I don't think a function to add new elements at runtime is necessary though - new elements (particularly those found in biological ligands) aren't discovered all that often!

benmwebb commented 1 year ago

Resolved by #100.