project-gemmi / gemmi

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

Gemmi read_ccp4_map fails to correctly set the correct spacing from a .MAP file #312

Closed jrobsontull closed 4 months ago

jrobsontull commented 4 months ago

I have recently found numerous EMDB entries for which gemmi fails to set the correct spacing after read_ccp4_map. If setup=True is passed, then the spacing is set up correctly. We are using the spacing in downstream applications.

Examples:

import gemmi

ccp4 = gemmi.read_cpp4_map('emd-22357.map')
ccp4.grid.spacing # (0, 0, 0)
# expected spacing = (0.532, 0.532, 0.532)

When collecting maps for analysis from the PDB, this occurred in about 5% of maps so it is quite a common issue. So, my questions are, is there anything I should be aware of when doingsetup=True for EM maps, and is this expected behaviour for these map files?

wojdyr commented 4 months ago

Spacing is calculated after setup. Setup extends the map to cover the entire unit cell and reorders the axes to X,Y,Z. However, if the setup step is unnecessary, all works in the same manner as if it was performed: the spacing gets calculated. I suppose it means that for about 95% of EM maps the axes are ordered as X Y Z and "grid sampling" in the map header matches the number of columns, rows and sections. I checked one of the two files (the second one - it's smaller); setup was required here because the order of axes was Z Y X.

Admittedly, that's confusing. Spacing could be calculated without the setup, but then you'd probably come across other problems. Alternatively, setup could be run by default, but it would be backward incompatible. So I don't see a good way to make it less confusing.

jrobsontull commented 4 months ago

Thanks @wojdyr for responding quickly. I see how there's perhaps no good solution for these cases, especially given backwards compatibility. I'll just be sure to perform set up as a default for EM maps.