Skip to content

Saxs model - #51

Merged
kewh5868 merged 5 commits into
mainfrom
saxs-model
Apr 8, 2026
Merged

kewh5868 merged 5 commits into
mainfrom
saxs-model

Conversation

@kewh5868

@kewh5868 kewh5868 commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds a new Electron Density Mapping supporting application to SAXSShell, wires it into the main SAXS UI Tools menu, includes focused UI stability/layout fixes, and adds a planning note for the upcoming Born-approximation workflow.

Scope of this comment: commits 62d1bba through f18e31b (4 commits, 14 files changed, 8625 insertions, 1 deletion).

What Changed

  • Added new module: src/saxshell/saxs/electron_density_mapping/
  • Implemented full workflow for:
  • Structure input inspection (single-file and folder modes for .xyz / .pdb)
  • Mass-weighted centering and optional center adjustments
  • Spherical mesh construction and radial electron-density profiling
  • Gaussian smearing controls
  • Solvent-contrast subtraction support
  • Fourier transform preview + scattering profile evaluation with windowing/sampling controls
  • CSV/JSON output export
  • Added full dedicated UI:
  • New Electron Density Mapping main window and visualization panel stack
  • Interactive plot/viewer controls and status/progress handling
  • Added CLI entrypoint for standalone launch via module execution
  • Integrated into SAXS main app Tools menu:
  • New action: Open Electron Density Mapping
  • Launcher inherits active project directory and structure-folder context when available
  • Added docs:
  • New user guide page: docs/user-guide/electron-density-mapping.md
  • Added to MkDocs nav (mkdocs.yml)
  • Added targeted non-feature fixes:
  • Stop stale change timers after initialization in ClusterDynamicsML UI
  • Correct Prefit control layout row placement
  • Added roadmap note:
  • docs/planned_updates/bornapprox.txt with Born Approximation implementation plan and UI/data-flow requirements

Tests / Validation

  • Added new test module: tests/test_electron_density_mapping.py covering workflow and UI behavior.
  • Added SAXS UI integration coverage in tests/test_saxs_ui.py for menu action visibility and launch context behavior.
  • Executed targeted tests:
  • PYTHONPATH=src conda run --no-capture-output -n saxshell-py312 pytest tests/test_electron_density_mapping.py tests/test_saxs_ui.py -k "electron_density_mapping_tool_uses_active_structure_folder or menus_expose_project_tools_and_help" (passed)
  • PYTHONPATH=src conda run --no-capture-output -n saxshell-py312 pytest tests/test_electron_density_mapping.py -k "inspect_structure_input_handles_single_files_and_folders or load_electron_density_structure_uses_mass_weighted_center_of_mass" (passed)
  • Pre-commit hooks passed on final commits (format/lint/docs checks).

Reviewer Notes

  • Main UI entrypoint: Tools -> Open Electron Density Mapping
  • Primary integration touchpoint: src/saxshell/saxs/ui/main_window.py
  • New feature is additive and isolated under saxs/electron_density_mapping, with explicit tests and docs included.

Follow-up

  • Born Approximation multi-stoichiometry integration and computed-distribution coupling are documented as planned work in docs/planned_updates/bornapprox.txt and are not fully implemented in this PR.

@kewh5868
kewh5868 merged commit 8dc5bca into main Apr 8, 2026
1 check passed
@kewh5868
kewh5868 deleted the saxs-model branch April 8, 2026 19:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2e1fa1cc0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2228 to +2231
for widget in (
self.load_input_button,
self.run_button,
self.update_mesh_button,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent input reloads while worker thread is active

The busy-state toggle disables load_input_button/input_path_edit but not the file/folder browse actions, so users can still trigger _load_input_from_edit() during an active background run. In that case self._inspection and self._structure can be replaced mid-calculation, and when the old worker finishes its result is applied to a different UI context, which can silently mix outputs and displayed metadata.

Useful? React with 👍 / 👎.

Comment on lines +640 to +643
counts = {
str(element): int(float(amount))
for element, amount in parsed.items()
if float(amount) > 0.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve fractional stoichiometry when parsing solvent formula

This conversion truncates parsed stoichiometric coefficients to integers (int(float(amount))), so valid fractional formulas (which xraydb.chemparse can return) are miscomputed or even zeroed out. That directly biases formula_electrons/formula_mass, producing incorrect solvent electron-density estimates for custom solvents with non-integer composition.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant