API Reference
This section documents the internal modules of synth-cryo-em.
synth_cryo_em.core
apply_ctf(data, voxel_size, defoc=2.0, cs=2.7, voltage=300, amplitude_contrast=0.1, b_factor=0.0)
Apply a simple Contrast Transfer Function (CTF) to the 3D data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The input 3D density map. |
required |
voxel_size
|
tuple
|
Voxel size in Angstroms (x, y, z). |
required |
defoc
|
float
|
Defocus in micrometers. Defaults to 2.0. |
2.0
|
cs
|
float
|
Spherical aberration in mm. Defaults to 2.7. |
2.7
|
voltage
|
float
|
Acceleration voltage in kV. Defaults to 300. |
300
|
amplitude_contrast
|
float
|
Amplitude contrast fraction. Defaults to 0.1. |
0.1
|
b_factor
|
float
|
Envelope function B-factor. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
numpy.ndarray: The CTF-corrupted 3D density map. |
Source code in src/synth_cryo_em/core.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
compute_ccc(data1, data2)
Compute the Cross-Correlation Coefficient (CCC) between two 3D maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data1
|
ndarray
|
The first 3D density map. |
required |
data2
|
ndarray
|
The second 3D density map. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The Pearson cross-correlation coefficient between the two maps. |
Source code in src/synth_cryo_em/core.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
generate_density_map(input_path, resolution, grid_spacing=None, use_bfactors=False, margin=None)
Generate a density map from an atomic model file (PDB, mmCIF, BCIF) using gemmi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_path
|
str
|
Path to the input structure file. |
required |
resolution
|
float
|
Target resolution in Angstroms. |
required |
grid_spacing
|
float
|
Grid spacing (pixel size) in Angstroms. Defaults to resolution / 3.0. |
None
|
use_bfactors
|
bool
|
If True, use atomic B-factors for local resolution. Defaults to False. |
False
|
margin
|
float
|
Margin around the structure in Angstroms. Defaults to resolution * 2.0. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[FloatGrid, NDArray[float64]]
|
A tuple containing: - numpy.ndarray: The 3D density grid. - numpy.ndarray: The origin coordinate of the map. |
Source code in src/synth_cryo_em/core.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
save_mrc(data, output_path, origin=(0, 0, 0), spacing=(1, 1, 1))
Save numpy array to an MRC file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The 3D density map to save. |
required |
output_path
|
str
|
Path to the output MRC file. |
required |
origin
|
tuple
|
The origin coordinates (x, y, z). Defaults to (0, 0, 0). |
(0, 0, 0)
|
spacing
|
tuple
|
The voxel size in Angstroms (x, y, z). Defaults to (1, 1, 1). |
(1, 1, 1)
|
Source code in src/synth_cryo_em/core.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
synth_cryo_em.cli
main(input_path, output_path, resolution, spacing, snr, defocus, voltage, cs, bfactor, bfactors, apply_physics)
Generate a synthetic Cryo-EM map from an atomic model (PDB, mmCIF, or BCIF).
This function acts as the CLI entrypoint for map generation. It parses arguments and coordinates the voxelization, CTF physics, and noise simulation.
Source code in src/synth_cryo_em/cli.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
synth_cryo_em.validate
compute_and_report_fsc(freqs, fsc, ccc, output=None)
Report FSC and CCC results to the console and optionally to a file.
Source code in src/synth_cryo_em/validate.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
main(map1_path, map2_path, output)
Compare two Cryo-EM maps using Fourier Shell Correlation (FSC) and CCC.
This function acts as the CLI entrypoint for map validation. It loads two MRC maps, verifies their dimensions, and computes correlation metrics.
Source code in src/synth_cryo_em/validate.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |