quality โ Publication Visualization & Structure Quality
The synth_pdb.quality sub-package provides two complementary capabilities:
- Publication-ready plots โ journal-standard figures for chemical shift correlations, Ramachandran analysis, and SAXS profiles.
- Structure quality classification โ GNN-based and feature-based classifiers for scoring structural plausibility.
Optional Dependencies
The plotting functions require matplotlib. The correlation plot additionally requires scipy. If either is absent the functions return None and log an error โ they do not raise, so scripts can run in headless environments.
Plotting Functions
Import directly from the sub-package:
from synth_pdb.quality import (
apply_publication_style,
save_publication_figure,
plot_chemical_shift_correlation,
plot_ramachandran_publication,
plot_saxs_publication,
)
Or from the full module path:
apply_publication_style()
Sets journal-standard matplotlib rcParams globally: sans-serif fonts (Arial/Helvetica), 300 DPI save default, cleaned tick sizes.
Side-effect scope
This modifies global rcParams. It intentionally does not set savefig.format โ the format is always passed explicitly via save_publication_figure to avoid silently changing the output format of other figures in the same process.
save_publication_figure(fig, path, transparent=False)
Saves a figure at 300 DPI with bbox_inches="tight". The format is derived from the file extension (defaults to PDF when no extension is given).
save_publication_figure(fig, "output/ca_correlation.pdf")
save_publication_figure(fig, "output/figure1") # โ saves as .pdf
save_publication_figure(fig, "output/thumbnail.png") # โ saves as .png
plot_chemical_shift_correlation
fig = plot_chemical_shift_correlation(
exp_data, # dict[int, dict[str, float]] residue โ {atom: ppm}
syn_data, # dict[int, dict[str, float]] (same structure)
atom_type="CA", # which nucleus to plot
title=None, # optional override; auto-generates R value in title
output_path=None, # if set, saves the figure
)
Generates a scatter plot of experimental vs synthetic shifts with a diagonal reference line. Annotates Pearson R and RMSD automatically.
plot_ramachandran_publication
fig = plot_ramachandran_publication(
phi, # np.ndarray of ฯ angles in degrees
psi, # np.ndarray of ฯ angles in degrees
title="Ramachandran Plot",
output_path=None,
)
Approximate region shading
The ฮฑ-helical (blue) and ฮฒ-strand (red) shaded regions are simplified rectangular approximations. They are not the probability-density contours from MolProbity or the Richardson Top8000 dataset. Use them for quick visual reference only โ do not cite them as quantitative Ramachandran statistics.
plot_saxs_publication
fig = plot_saxs_publication(
q, # np.ndarray โ scattering vector (ร
โปยน)
intensity, # np.ndarray โ I(q)
rg=None, # float | None โ annotates Rg on the plot when provided
output_path=None,
)
Plots I(q) on a log-linear scale (standard for SAXS publications).
Full API Reference
plots
Publication-Quality Visualization Module for synth-pdb.
This module provides standardized plotting functions designed for academic journals (e.g., Nature, Journal of Molecular Biology, JACS). It focuses on high-DPI export, consistent typography, and scientifically accurate scales.
Functions
apply_publication_style()
Apply global matplotlib settings for publication-ready figures.
Source code in synth_pdb/quality/plots.py
save_publication_figure(fig, path, transparent=False)
Save a figure with journal-standard defaults.
The output format is derived from the file extension (defaults to PDF
when the path has no extension). The format is passed explicitly to
fig.savefig so that this function never relies on - or mutates -
the global savefig.format rcParam.
Source code in synth_pdb/quality/plots.py
plot_chemical_shift_correlation(exp_data, syn_data, atom_type='CA', title=None, output_path=None)
Generate a high-fidelity correlation plot for chemical shifts.
Source code in synth_pdb/quality/plots.py
plot_ramachandran_publication(phi, psi, title='Ramachandran Plot', output_path=None)
Generate a publication-quality Ramachandran plot with favored regions.
Source code in synth_pdb/quality/plots.py
plot_saxs_publication(q, intensity, rg=None, output_path=None)
Standardized SAXS I(q) vs q plot for papers.
Source code in synth_pdb/quality/plots.py
Complete Workflow Example
import numpy as np
import biotite.structure.io.pdb as pdb_io
from synth_pdb.bmrb_api import BMRBAPI
from synth_pdb.chemical_shifts import predict_chemical_shifts
from synth_pdb.saxs import calculate_saxs_profile, calculate_radius_of_gyration
from synth_pdb.quality import (
plot_chemical_shift_correlation,
plot_ramachandran_publication,
plot_saxs_publication,
)
import biotite.structure as struc
# Load structure
structure = pdb_io.PDBFile.read("examples/1D3Z.pdb").get_structure(model=1)
# Chemical shift correlation
exp_shifts = BMRBAPI.fetch_chemical_shifts("6457")
syn_shifts_full = predict_chemical_shifts(structure)
syn_shifts = list(syn_shifts_full.values())[0] # first chain
fig = plot_chemical_shift_correlation(
exp_shifts, syn_shifts, atom_type="CA",
output_path="figures/ca_correlation.pdf",
)
# Ramachandran plot
phi, psi, _ = struc.dihedral_backbone(structure)
mask = ~np.isnan(phi) & ~np.isnan(psi)
plot_ramachandran_publication(
np.degrees(phi[mask]), np.degrees(psi[mask]),
output_path="figures/ramachandran.pdf",
)
# SAXS profile
q, intensity = calculate_saxs_profile(structure, q_max=0.3)
rg = calculate_radius_of_gyration(structure)
plot_saxs_publication(q, intensity, rg=rg, output_path="figures/saxs.pdf")