Skip to main content

SAXS modelling from protein structures using hydrated form factors

Project description

wiggle-SAXS

SAXS modelling of coarse-grain protein structures using implicitly hydrated form factors.

wiggle-SAXS computes theoretical SAXS curves directly from CA position in PDB files or numpy arrays, using a two body model approximating side chain centre of masses from CAs and pre-fitted implicitly hydrated form factors.


Installation

pip install wiggle-SAXS

Or for development (editable install with dev extras):

git clone https://github.com/mckeownish/wiggle-SAXS.git
cd wiggle-SAXS
pip install -e ".[dev]"

Quick start

From a PDB file

import wiggle

# compute model curve from PDB + experimental SAXS data
result = wiggle.compute_fit("data/lysozyme.pdb", "data/lyso_SAXS.dat")

# fit to data
fit = wiggle.fit_model_to_data(
    result["q_model"], result["I_model"],
    result["q_exp"],   result["I_exp"], result["I_err"],
)
print(f"chi2 = {fit['chi2']:.3f}")

# plot
wiggle.plot_fit(
    result["q_exp"], result["I_exp"], result["I_err"],
    fit["q"], fit["I_scaled"],
    chi2=fit["chi2"],
    title="Lysozyme SAXS Fit",
    save_path="fit.svg",
)

From numpy arrays (e.g. MD trajectories)

import wiggle

proc = wiggle.StructureProcessor()

# sequence accepts one-letter string or list of three-letter codes
structure = proc.process_from_arrays(ca_coords, sequence)

# multi-chain example — pass chain_ids matching length of ca_coords
# chain_ids = np.array(["A"] * 129 + ["B"] * 129)
# structure = proc.process_from_arrays(ca_coords, sequence, chain_ids=chain_ids)

q, I_q = wiggle.calculate_saxs(structure)

fit = wiggle.fit_model_to_data(q, I_q, q_exp, I_exp, I_err)
print(f"chi2 = {fit['chi2']:.3f}")

wiggle.plot_fit(
    q_exp, I_exp, I_err,
    fit["q"], fit["I_scaled"],
    chi2=fit["chi2"],
    title="My protein",
    save_path=None,
)

Command line

wiggle --pdb protein.pdb --saxs data.dat

Output is written to wiggle_fit.dat by default. Use --out to specify a path:

wiggle --pdb protein.pdb --saxs data.dat --out results/wiggle_fit.dat

Custom form factors:

wiggle --pdb protein.pdb --saxs data.dat --ff my_form_factors.pkl --out fit.dat

The output file contains a header with fit metadata followed by four columns:

# wiggle fit
# pdb:   protein.pdb
# saxs:  data.dat
# chi2:  1.2345
# scale: 3.141593e+04
# q_exp  I_exp  I_err  I_model
8.71252000e-02   4.00680000e+00   1.03361000e+01   3.98123000e+00
...

Package layout

wiggle/
├── api.py         # high-level convenience functions (compute_fit)
├── cli.py         # command-line entry point
├── structure.py   # PDB parsing, chain fixing, geometric vector + side-chain placement
├── scattering.py  # Debye SAXS calculation with implicit form factors
├── fitting.py     # chi-squared optimisation and interpolation utilities
├── plotting.py    # matplotlib fit visualisation with residuals panel
└── data/
    └── wiggle_implicit_form_factors.pkl

Package layout

wiggle/
├── structure.py   # PDB parsing, chain fixing, geometric vector + side-chain placement
├── scattering.py  # Debye SAXS calculation with implicit form factors
├── fitting.py     # Chi-squared optimisation and interpolation utilities
└── plotting.py    # Matplotlib fit visualisation with residuals panel

Running tests

pytest

License

MIT

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

wiggle_saxs-0.1.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

wiggle_saxs-0.1.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file wiggle_saxs-0.1.0.tar.gz.

File metadata

  • Download URL: wiggle_saxs-0.1.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for wiggle_saxs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a24aab1531e2b52f1af05e14ce3da8d1748f0ac92f929f18fbcaab5a08df0d7f
MD5 9f1eaa63eeb3b0964db11184db43c0a7
BLAKE2b-256 46503914378b56e30020dd676d01061ec44d939008e431b8e7da96194d9cb7d6

See more details on using hashes here.

File details

Details for the file wiggle_saxs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wiggle_saxs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for wiggle_saxs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a58040f495c9dd4e420aafe661677db265cd006bb7a13f3ab2a3e5293bacdd2f
MD5 353632ff5b25b4ec1b5597d86a6ad0eb
BLAKE2b-256 5153ac1117f1854f810fb577f48e8e7912df389f16634787e32eaca4fd60fe63

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