Add residual electron density (Fo−Fc) wireframe map to MoleculeWidget#9
Draft
Add residual electron density (Fo−Fc) wireframe map to MoleculeWidget#9
Conversation
…image Agent-Logs-Url: https://github.com/dkratzert/Fastmolwidget/sessions/dc4caee0-48e0-487e-b2f6-94dd7ce228f6 Co-authored-by: dkratzert <3948149+dkratzert@users.noreply.github.com>
…rtions Agent-Logs-Url: https://github.com/dkratzert/Fastmolwidget/sessions/dc4caee0-48e0-487e-b2f6-94dd7ce228f6 Co-authored-by: dkratzert <3948149+dkratzert@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
dkratzert
April 13, 2026 15:44
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compute and display a difference Fourier map from a CIF + SHELX HKL file, rendered as a green (positive) / red (negative) wireframe overlay in the existing 2D projection widget. Crystal symmetry is fully accounted for via gemmi's
StructureFactorCalculatorX, which applies all space-group operators when computing Fc.New:
diff_map.pycompute_diff_map(cif_path, hkl_path=None)— reads structure + ADPs from CIF, parses and merges SHELX HKL reflections (external file or_shelx_hkl_fileembedded in CIF), computes Fc, estimates scale factor k = √(ΣFo²/ΣFc²), fills aReciprocalComplexGridwith(Fo/k − |Fc|)·exp(iφ_c)coefficients, and inverse-FFTs to a real-space grid.get_mesh_segments(result, level_sigma=3.0)— marching cubes at ±N·σ → unique wireframe edges in Cartesian Å.molecule2D.MoleculeWidgetset_density_mesh(pos_segs, neg_segs)/clear_density_mesh()/show_density(bool)— manage the(N, 2, 3)segment arrays.loader.MoleculeLoaderload_diff_map(hkl_path=None, level_sigma=3.0)— auto-detects<stem>.hkl/<stem>-finalcif.hkl, falls back to embedded CIF data.viewer_widget.MoleculeViewerWidgetUsage
Dependencies
scikit-imageadded as an optional extra (pip install fastmolwidget[diffmap]). RaisesImportErrorwith a clear message if absent.