Skip to main content

synth-xtal

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

synth-xtal is a lightweight Python library for simulating X-ray Crystallography diffraction data (structure factors and MTZ files) from input atomic models (PDB/mmCIF files).

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


🧪 For Structural Biologists

  • Virtual Crystallography: Generate ideal $F_{calc}$ and $\phi_{calc}$ structure factors from structural models.
  • Automated Cell Generation: Transparently computes optimal bounding unit cells in $P 1$ for standalone peptides/proteins lacking periodic symmetry constraints.

🤖 For Machine Learning Researchers

  • Standard Integrations: Built directly on top of gemmi and reciprocalspaceship for native FFT acceleration and robust MTZ writing.
  • Multi-Model Support: Seamlessly handles NMR ensembles or MD trajectories by accurately averaging grid densities to simulate alternative conformations.
  • Educational Clarity: Simple, well-commented implementation of crystallographic density mapping — easy to audit and extend.

Features

  • Diffraction Simulation: Direct generation of complex structure factors from atomic coordinates using gemmi.DensityCalculatorX.
  • Ensemble Averaging: Calculates coherent scattering intensities over an ensemble of structural models.
  • Pythonic Data Structures: Outputs are formatted to reciprocalspaceship.DataSet objects for seamless downstream integration with standard ML/data-science tools (Pandas).

Installation

# Basic installation
pip install synth-xtal

# Installation for contributors/developers
pip install "synth-xtal[dev,test,docs]"

Command-Line Interface (CLI)

synth-xtal provides a simple CLI for rapid simulation:

# Basic simulation (outputs to MTZ format)
synth-xtal input.pdb -o simulated.mtz

# Simulation at a specific high-resolution limit (e.g., 1.5 Å)
synth-xtal input.pdb -o simulated.mtz --resolution 1.5

# Simulation with a custom padding margin for automatically generated unit cells
synth-xtal input.pdb -o simulated.mtz --margin 15.0

CLI Arguments

  • input: Path to PDB or mmCIF file.
  • -o, --output: Save structure factor data to an .mtz file (Required).
  • -d, --resolution: High resolution limit in Ångströms (default: 2.0).
  • --margin: Margin in Ångströms for the unit cell bounding box if the input lacks a defined unit cell (default: 10.0).

Quick Start

Python API

from synth_xtal.simulator import simulate_diffraction

# Calculate MTZ from a PDB or mmCIF file
simulate_diffraction(
    input_pdb="protein.cif",
    output_mtz="simulated_data.mtz",
    d_min=2.0
)

Tutorials

Try out synth-xtal interactively in Google Colab:

  • 01. Crystallography Basics: Open In Colab
  • 02. Experimental Validation (4LZT): Open In Colab
  • 03. Virtual Crystallography Lab: Open In Colab

Acknowledgements

synth-xtal was heavily inspired by the educational goals of the larger synth-pdb ecosystem and relies critically on:

  • gemmi - for core density calculations and FFT operations.
  • reciprocalspaceship - for MTZ manipulation and Pandas integration.

Download files

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

Source Distribution

synth_xtal-0.2.1.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

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

synth_xtal-0.2.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file synth_xtal-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for synth_xtal-0.2.1.tar.gz
Algorithm Hash digest
SHA256 892068caed2cd617fd1228356606f344a63e8b2069e0f5e3ec2f14b3aa5ff40d
MD5 dfd481781e6abd91e0d168ced938a060
BLAKE2b-256 21561cac0e0989451c3e254a9a0bde874fc00830eff07d7d0ffdbe82f77b4632

See more details on using hashes here.

File details

Details for the file synth_xtal-0.2.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for synth_xtal-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8e06486b28081dc0a2f5db1ecefdd22db4618417647a503d7f01f9617ecdd4d
MD5 de2a20c56ef3b3f57bb296c0f628c98b
BLAKE2b-256 03e22df386af7c81798b1fe2eb65418c876c5b1d1cf73235bfda23775a63891f

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