Access to temporary electron density map created by rs.find_difference_peaks?

The documentation for rs.find_difference_peaks says “Search an electron density map for peaks in the vicinity of a structure.”

Since it takes a reflection file plus the column labels for structure factors and phases as the “map” inputs (as well as the structure used to define peak locations), I extrapolate that this function must actually first calculate a difference map, then search that map to return the eventual list of peaks. Is there a way to save/access that intermediate/temporary difference map?

Hi @mklureza! Sorry for the slow reply. I’m a little unsure how to answer your question. The rs.find_difference_peaks requires that you pass the amplitudes and phases of a difference map. Internally it does a Fourier transform to get the real-space difference density. It uses an algorithm implemented in Gemmi to search for peaks in this density.

Is it the real-space, difference density that you’re hoping to save? Do you need it in some particularl file format?

Yes, it’s the real-space difference density that I’m interested in accessing - the end result of taking the structure factor amplitudes and phases from an mtz file and creating an actual real-space map with it.

In ccp4, I could generate a comparable list of difference density peaks by first running fft, to create a real-space difference density map, and then running peakmax to search that map for peaks. I’d like to compare that route with rs.find_difference_peaks, both to make sure I’ve fully understood what that rs-booster utility is doing, and as a control to make sure I get the same answer both ways. In addition to comparing the final list of peaks, it would be helpful if I could take the map created in rs.find_difference_peaks and feed that into peakmax.

As far as file format goes… peakmax takes a ccp4 .map file as input, but I suspect creating that in rs is nontrivial. To some extent, I’ll take whatever you can give me and then wrangle it in peakmax/coot/whatever else from there, but any thoughts you have about compatibility would be appreciated!

Thanks!

Hi @mklureza, you can use the sf2map program from the gemmi command line app to convert your mtz to a ccp4 map file. This will be equivalent to the map that rs.find_difference_peaks sees. Does this solve your problem?

@kmdalton - do you mean that sf2map is exactly what rs.find_difference_peaks is doing under the hood? Or that it is equivalent to it? I think that rs.find_difference_peaks is actually the ideal tool for one of my current analyses, but before I proceed and rely solely on that, I’m trying to take a look at what it does along the way. (And I’m aware that in theory I could get that understanding from the Python, but my Python isn’t quite up to that yet/I want the direct comparison between rs and ccp4 methods.)

My intention was for the in-memory real space grid computed by rs.find_difference_peaks to be exactly what gemmi would compute in sf2map. Internally it uses only the gemmi tools. I haven’t confirmed the equality with a test, but I can. I can’t guarantee the turnaround, but if you file an issue on the rs-booster github page, I’ll try to have a look soon.

Thank you - will do!