Skip to main content

Education-focused SAXS profile simulation from protein coordinates

Project description

synth-saxs

codecov PyPI version Python License: MIT Tests Ruff Checked with mypy

synth-saxs is a lightweight Python library for simulating Small-Angle X-ray Scattering (SAXS) profiles from protein coordinates.

Extracted from the synth-pdb ecosystem, it provides a physically grounded, education-focused engine for reciprocal space simulation.


🧪 For Structural Biologists

  • Guinier & Kratky Analysis: Built-in plots to determine Radius of Gyration ($R_g$), forward scattering $I(0)$, and assess protein compactness.
  • Hydration Modeling: Physically accurate solvent displacement model based on Pavlov & Svergun (1997).

🤖 For Machine Learning Researchers

  • Debye Back-Calculation: O(N²) scattering intensity from atomic coordinates, suitable as a differentiable-style loss signal for structure validation.
  • Educational Clarity: Explicit, well-commented implementation of form factors and solvent contrast — easy to audit and extend.

Features

  • Debye Formula: O(N²) calculation of scattering intensity.
  • Solvent Displacement: Physically accurate solvent contrast model based on Pavlov & Svergun (1997).
  • Atomic Form Factors: Standard Waasmaier & Kirfel (1995) coefficients.
  • Visualization: Built-in support for Kratky and Guinier plots.

Installation

# Basic installation
pip install synth-saxs

# Installation with visualization support
pip install "synth-saxs[viz]"

Command-Line Interface (CLI)

synth-saxs provides a CLI for rapid simulation and plotting:

# Basic simulation
synth-saxs protein.pdb --output profile.dat

# Plotting with Kratky analysis
synth-saxs protein.pdb --plot report.png --plot-type kratky

# Advanced modeling (Hydration Shell + P(r) distribution)
synth-saxs protein.pdb --shell-density 0.03 --p-dist pr.png --p-dist-dat pr.dat

CLI Arguments

  • input: Path to PDB/mmCIF file.
  • --output: Save $I(q)$ data to a .dat file.
  • --plot: Path to save a SAXS report image.
  • --shell-density: Excess hydration shell density (default: 0.0).
  • --p-dist: Save a plot of the $P(r)$ distribution.
  • --p-dist-dat: Save raw $P(r)$ data to a .dat file.

Quick Start

1. Single Structure Simulation

import biotite.structure.io.pdb as pdb_io
from synth_saxs import calculate_saxs_profile, add_noise

# Load a structure
struct = pdb_io.PDBFile.read("protein.pdb").get_structure(model=1)

# Calculate I(q) and add realistic noise
q, I = calculate_saxs_profile(struct)
I_noisy = add_noise(I, noise_level=0.02)

2. Ensemble Averaging

The SaxsSimulator can handle both Biotite stacks and standard Python lists of structures.

from synth_saxs import SaxsSimulator

# List of different conformation models
models = [model1, model2, model3]

sim = SaxsSimulator(q_max=0.3)
avg_intensity = sim.simulate(models)

3. Pair Distance Distribution P(r)

from synth_saxs import calculate_p_dist, plot_p_dist

r, pr = calculate_p_dist(struct)
plot_p_dist(r, pr, output_path="p_dist.png")

4. Visualization

from synth_saxs import plot_saxs_results
plot_saxs_results(q, I, plot_type="all", output_path="saxs_report.png")

Scientific Rationale

The engine is designed for numerical stability and educational clarity. It correctly handles the delicate balance between atomic contrast and solvent displacement decay to ensure monotonic scattering curves in the Guinier regime.

References

  • Waasmaier, D. & Kirfel, A. (1995). Acta Cryst. A51, 416-431.
  • Pavlov, M.Y. & Svergun, D.I. (1997). J. Appl. Cryst. 30, 712-717.
  • Svergun, D., et al. (1995). J. Appl. Cryst. 28, 768-773.

Related Projects

This library is part of the synth-pdb ecosystem for synthetic biophysics data generation:

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub. The project uses ruff for linting/formatting and mypy for type checking — run pre-commit run --all-files before submitting.

License

MIT License — see LICENSE for details.

Citation

If you use synth-saxs in your research, please cite:

@software{synth_saxs,
  author  = {Elkins, George},
  title   = {synth-saxs: SAXS profile simulation from protein coordinates},
  year    = {2026},
  url     = {https://github.com/elkins/synth-saxs},
  version = {0.1.0}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synth_saxs-0.1.3.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synth_saxs-0.1.3-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file synth_saxs-0.1.3.tar.gz.

File metadata

  • Download URL: synth_saxs-0.1.3.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for synth_saxs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6efca82ad45143d0afb469a60ce3770c20d73481018e3f7cb830e479f1a8e9f8
MD5 052941309a4a4f888c28d8fe74e1a5f4
BLAKE2b-256 3a3ca04f42d73b26975893a8e48e0d91f2650c302e6978bd29c6fc35b097e0ed

See more details on using hashes here.

File details

Details for the file synth_saxs-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: synth_saxs-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for synth_saxs-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dd7727e95a3aa72ef47d25c2d82f5b6b7863106a6a8cec37839d09877e5537bf
MD5 535b552fc56a36f3c2a76575a336aebd
BLAKE2b-256 2ac74716c65f997c20882e579b3b2827e2445003c62042940029a586a727cd5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page