cryojax 0.3.3rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. cryojax/__init__.py +10 -0
  2. cryojax/constants/__init__.py +7 -0
  3. cryojax/constants/_scattering_factor_parameters.py +57 -0
  4. cryojax/constants/_unit_conversions.py +12 -0
  5. cryojax/constants/peng1996_element_params.npy +0 -0
  6. cryojax/coordinates/__init__.py +8 -0
  7. cryojax/coordinates/_geometry.py +24 -0
  8. cryojax/coordinates/_make_coordinate_grids.py +204 -0
  9. cryojax/cryojax_version.py +16 -0
  10. cryojax/data/__init__.py +15 -0
  11. cryojax/data/_dataset.py +89 -0
  12. cryojax/data/_particle_stack.py +15 -0
  13. cryojax/data/_relion/__init__.py +13 -0
  14. cryojax/data/_relion/_starfile_reading.py +788 -0
  15. cryojax/data/_relion/_starfile_writing.py +578 -0
  16. cryojax/experimental/__init__.py +16 -0
  17. cryojax/image/__init__.py +34 -0
  18. cryojax/image/_average.py +88 -0
  19. cryojax/image/_downsample.py +132 -0
  20. cryojax/image/_edges.py +192 -0
  21. cryojax/image/_fft.py +99 -0
  22. cryojax/image/_map_coordinates.py +255 -0
  23. cryojax/image/_normalize.py +99 -0
  24. cryojax/image/_rescale_pixel_size.py +138 -0
  25. cryojax/image/_spectrum.py +60 -0
  26. cryojax/image/operators/__init__.py +42 -0
  27. cryojax/image/operators/_filters.py +338 -0
  28. cryojax/image/operators/_fourier_operator.py +202 -0
  29. cryojax/image/operators/_masks.py +420 -0
  30. cryojax/image/operators/_operator.py +207 -0
  31. cryojax/image/operators/_real_operator.py +86 -0
  32. cryojax/inference/__init__.py +20 -0
  33. cryojax/inference/_grid_search/__init__.py +17 -0
  34. cryojax/inference/_grid_search/custom_types.py +10 -0
  35. cryojax/inference/_grid_search/pytree_manipulation.py +205 -0
  36. cryojax/inference/_grid_search/search_loop.py +158 -0
  37. cryojax/inference/_grid_search/search_method.py +309 -0
  38. cryojax/inference/_lie_group_transforms.py +138 -0
  39. cryojax/inference/distributions/__init__.py +9 -0
  40. cryojax/inference/distributions/_base_distribution.py +58 -0
  41. cryojax/inference/distributions/_gaussian_distributions.py +321 -0
  42. cryojax/internal/__init__.py +7 -0
  43. cryojax/internal/_errors.py +35 -0
  44. cryojax/internal/_loop.py +114 -0
  45. cryojax/io/__init__.py +23 -0
  46. cryojax/io/_gemmi.py +182 -0
  47. cryojax/io/_mdtraj.py +43 -0
  48. cryojax/io/_mrc.py +240 -0
  49. cryojax/io/_pdb_and_cif.py +224 -0
  50. cryojax/io/_starfile.py +28 -0
  51. cryojax/rotations/__init__.py +9 -0
  52. cryojax/rotations/_lie_group.py +522 -0
  53. cryojax/rotations/_rotation.py +67 -0
  54. cryojax/rotations/_utils.py +61 -0
  55. cryojax/simulator/__init__.py +69 -0
  56. cryojax/simulator/_detector.py +218 -0
  57. cryojax/simulator/_imaging_pipeline.py +423 -0
  58. cryojax/simulator/_instrument_config.py +261 -0
  59. cryojax/simulator/_multislice_integrator/__init__.py +4 -0
  60. cryojax/simulator/_multislice_integrator/base_multislice_integrator.py +24 -0
  61. cryojax/simulator/_multislice_integrator/fft_multislice_integrator.py +221 -0
  62. cryojax/simulator/_pose.py +279 -0
  63. cryojax/simulator/_potential_integrator/__init__.py +14 -0
  64. cryojax/simulator/_potential_integrator/atom_potential_integrator.py +159 -0
  65. cryojax/simulator/_potential_integrator/base_potential_integrator.py +82 -0
  66. cryojax/simulator/_potential_integrator/fourier_voxel_extract.py +513 -0
  67. cryojax/simulator/_potential_integrator/nufft_project.py +134 -0
  68. cryojax/simulator/_potential_representation/__init__.py +17 -0
  69. cryojax/simulator/_potential_representation/atom_potential.py +569 -0
  70. cryojax/simulator/_potential_representation/base_potential.py +26 -0
  71. cryojax/simulator/_potential_representation/voxel_potential.py +435 -0
  72. cryojax/simulator/_scattering_theory/__init__.py +18 -0
  73. cryojax/simulator/_scattering_theory/base_scattering_theory.py +120 -0
  74. cryojax/simulator/_scattering_theory/common_functions.py +44 -0
  75. cryojax/simulator/_scattering_theory/high_energy_scattering_theory.py +110 -0
  76. cryojax/simulator/_scattering_theory/multislice_scattering_theory.py +53 -0
  77. cryojax/simulator/_scattering_theory/weak_phase_scattering_theory.py +337 -0
  78. cryojax/simulator/_solvent.py +123 -0
  79. cryojax/simulator/_structural_ensemble/__init__.py +18 -0
  80. cryojax/simulator/_structural_ensemble/assembly/__init__.py +9 -0
  81. cryojax/simulator/_structural_ensemble/assembly/base_assembly.py +199 -0
  82. cryojax/simulator/_structural_ensemble/assembly/helix.py +280 -0
  83. cryojax/simulator/_structural_ensemble/base_conformation.py +19 -0
  84. cryojax/simulator/_structural_ensemble/base_ensemble.py +63 -0
  85. cryojax/simulator/_structural_ensemble/discrete_ensemble.py +60 -0
  86. cryojax/simulator/_transfer_theory/__init__.py +12 -0
  87. cryojax/simulator/_transfer_theory/base_transfer_theory.py +53 -0
  88. cryojax/simulator/_transfer_theory/common_functions.py +63 -0
  89. cryojax/simulator/_transfer_theory/contrast_transfer_theory.py +150 -0
  90. cryojax/simulator/_transfer_theory/wave_transfer_theory.py +139 -0
  91. cryojax/utils/__init__.py +17 -0
  92. cryojax/utils/_filter_specs.py +46 -0
  93. cryojax/utils/_filtered_transformations.py +117 -0
  94. cryojax/utils/_transforms.py +130 -0
  95. cryojax-0.3.3rc1.dist-info/METADATA +666 -0
  96. cryojax-0.3.3rc1.dist-info/RECORD +98 -0
  97. cryojax-0.3.3rc1.dist-info/WHEEL +4 -0
  98. cryojax-0.3.3rc1.dist-info/licenses/LICENSE +504 -0
cryojax/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ from . import (
2
+ coordinates as coordinates,
3
+ data as data,
4
+ image as image,
5
+ inference as inference,
6
+ rotations as rotations,
7
+ simulator as simulator,
8
+ utils as utils,
9
+ )
10
+ from .cryojax_version import __version__ as __version__
@@ -0,0 +1,7 @@
1
+ from ._scattering_factor_parameters import (
2
+ get_tabulated_scattering_factor_parameters as get_tabulated_scattering_factor_parameters, # noqa: E501
3
+ peng_element_scattering_factor_parameter_table as peng_element_scattering_factor_parameter_table, # noqa: E501
4
+ )
5
+ from ._unit_conversions import (
6
+ convert_keV_to_angstroms as convert_keV_to_angstroms,
7
+ )
@@ -0,0 +1,57 @@
1
+ """
2
+ Routines for loading atomic structures.
3
+ Large amounts of the code are adapted from the ioSPI package
4
+ """
5
+
6
+ import importlib.resources as pkg_resources
7
+ import os
8
+
9
+ import jax.numpy as jnp
10
+ import numpy as np
11
+ from jaxtyping import Array, Float, Int
12
+
13
+
14
+ def _load_peng_element_scattering_factor_parameter_table():
15
+ """Internal function to load the atomic scattering factor parameter
16
+ table."""
17
+ with pkg_resources.as_file(
18
+ pkg_resources.files("cryojax").joinpath("constants")
19
+ ) as path:
20
+ atom_scattering_factor_params = jnp.load(
21
+ os.path.join(path, "peng1996_element_params.npy")
22
+ )
23
+
24
+ return jnp.asarray(atom_scattering_factor_params)
25
+
26
+
27
+ peng_element_scattering_factor_parameter_table = (
28
+ _load_peng_element_scattering_factor_parameter_table()
29
+ )
30
+
31
+
32
+ def get_tabulated_scattering_factor_parameters(
33
+ atom_identities: Int[Array, " n_atoms"] | Int[np.ndarray, " n_atoms"],
34
+ scattering_factor_parameter_table: (
35
+ Float[Array, "n_params n_elements n_scattering_factors"]
36
+ | Float[np.ndarray, "n_params n_elements n_scattering_factors"]
37
+ ) = peng_element_scattering_factor_parameter_table,
38
+ ) -> Float[Array, "n_params n_atoms n_scattering_factors"]:
39
+ """Gets the parameters for the scattering factor for each atom in
40
+ `atom_names`.
41
+
42
+ **Arguments:**
43
+
44
+ - `atom_identitites`:
45
+ Array containing the index of the one-hot encoded atom names.
46
+ By default, Hydrogen is "1", Carbon is "6", Nitrogen is "7", etc.
47
+ - `scattering_factor_parameter_table`:
48
+ Array containing the table of scattering factors. By default, this
49
+ is the tabulation from "Robust Parameterization of Elastic and
50
+ Absorptive Electron Atomic Scattering Factors" by Peng et al. (1996).
51
+
52
+ **Returns:**
53
+
54
+ The particular scattering factor parameters stored in
55
+ `scattering_factor_parameter_table` for `atom_identities`.
56
+ """
57
+ return jnp.asarray(scattering_factor_parameter_table)[:, jnp.asarray(atom_identities)]
@@ -0,0 +1,12 @@
1
+ """Unit conversions."""
2
+
3
+ import jax.numpy as jnp
4
+ from jaxtyping import Array, Float
5
+
6
+
7
+ def convert_keV_to_angstroms(
8
+ energy_in_keV: Float[Array, ""] | float,
9
+ ) -> Float[Array, ""]:
10
+ """Get the relativistic electron wavelength at a given accelerating voltage."""
11
+ energy_in_eV = 1000.0 * energy_in_keV # keV to eV
12
+ return jnp.asarray(12.2643 / (energy_in_eV + 0.97845e-6 * energy_in_eV**2) ** 0.5)
@@ -0,0 +1,8 @@
1
+ from ._geometry import cartesian_to_polar as cartesian_to_polar
2
+ from ._make_coordinate_grids import (
3
+ make_1d_coordinate_grid as make_1d_coordinate_grid,
4
+ make_1d_frequency_grid as make_1d_frequency_grid,
5
+ make_coordinate_grid as make_coordinate_grid,
6
+ make_frequency_grid as make_frequency_grid,
7
+ make_frequency_slice as make_frequency_slice,
8
+ )
@@ -0,0 +1,24 @@
1
+ import jax.numpy as jnp
2
+ from jaxtyping import Array, Float, Inexact
3
+
4
+
5
+ def cartesian_to_polar(
6
+ coordinate_or_frequency_grid: Float[Array, "y_dim x_dim 2"], square: bool = False
7
+ ) -> tuple[Inexact[Array, "y_dim x_dim"], Inexact[Array, "y_dim x_dim"]]:
8
+ """Convert from cartesian to polar coordinates.
9
+
10
+ **Arguments:**
11
+
12
+ -`coordinate_or_frequency_grid`: The cartesian coordinate system.
13
+ -`square`: If ``True``, return the square of the radial coordinate
14
+ $|r|^2$. Otherwise, return $|r|$.
15
+ """
16
+ theta = jnp.arctan2(
17
+ coordinate_or_frequency_grid[..., 0], coordinate_or_frequency_grid[..., 1]
18
+ )
19
+ k_sqr = jnp.sum(jnp.square(coordinate_or_frequency_grid), axis=-1)
20
+ if square:
21
+ return k_sqr, theta
22
+ else:
23
+ kr = jnp.sqrt(k_sqr)
24
+ return kr, theta
@@ -0,0 +1,204 @@
1
+ """
2
+ Functions for creating coordinate systems.
3
+ """
4
+
5
+ from typing import Optional
6
+
7
+ import jax.numpy as jnp
8
+ import numpy as np
9
+ from jaxtyping import Array, Float
10
+
11
+
12
+ def make_coordinate_grid(
13
+ shape: tuple[int, ...],
14
+ grid_spacing: float | Float[np.ndarray, ""] | Float[Array, ""] = 1.0,
15
+ ) -> Float[Array, "*shape ndim"]:
16
+ """
17
+ Create a real-space cartesian coordinate system on a grid.
18
+
19
+ **Arguments:**
20
+
21
+ - `shape`: Shape of the voxel grid, with `ndim = len(shape)`.
22
+ - `grid_spacing`: The grid spacing, in units of length.
23
+
24
+ **Returns:**
25
+
26
+ A cartesian coordinate system in real space.
27
+ """
28
+ coordinate_grid = _make_coordinates_or_frequencies(
29
+ shape, grid_spacing=grid_spacing, real_space=True
30
+ )
31
+ return coordinate_grid
32
+
33
+
34
+ def make_frequency_grid(
35
+ shape: tuple[int, ...],
36
+ grid_spacing: float | Float[np.ndarray, ""] | Float[Array, ""] = 1.0,
37
+ half_space: bool = True,
38
+ ) -> Float[Array, "*shape ndim"]:
39
+ """Create a fourier-space cartesian coordinate system on a grid.
40
+ The zero-frequency component is in the corner.
41
+
42
+ Arguments
43
+ ---------
44
+ - `shape`: Shape of the voxel grid, with `ndim = len(shape)`.
45
+ - `grid_spacing`: The grid spacing, in units of length.
46
+ - `half_space`:
47
+ Return a frequency grid on the half space.
48
+ `shape[-1]` is the axis on which the negative
49
+ frequencies are omitted.
50
+
51
+ **Returns:**
52
+
53
+ A cartesian coordinate system in frequency space.
54
+ """
55
+ frequency_grid = _make_coordinates_or_frequencies(
56
+ shape,
57
+ grid_spacing=grid_spacing,
58
+ real_space=False,
59
+ half_space=half_space,
60
+ )
61
+ return frequency_grid
62
+
63
+
64
+ def make_frequency_slice(
65
+ shape: tuple[int, int],
66
+ grid_spacing: float | Float[np.ndarray, ""] | Float[Array, ""] = 1.0,
67
+ half_space: bool = True,
68
+ ) -> Float[Array, "1 {shape[0]} {shape[1]} 3"]:
69
+ """Create a fourier-space cartesian coordinate system on a grid. The
70
+ zero-frequency component is in the *center*. This is different
71
+ than in [`make_frequency_grid`][].
72
+
73
+ **Returns:**
74
+
75
+ The central, $q_z = 0$ slice of a 3D frequency grid `$(q_x, q_y, q_z)$`.
76
+ """
77
+ frequency_slice = make_frequency_grid(shape, grid_spacing, half_space=half_space)
78
+ if half_space:
79
+ frequency_slice = jnp.fft.fftshift(frequency_slice, axes=(0,))
80
+ else:
81
+ frequency_slice = jnp.fft.fftshift(frequency_slice, axes=(0, 1))
82
+ frequency_slice = jnp.expand_dims(
83
+ jnp.pad(
84
+ frequency_slice,
85
+ ((0, 0), (0, 0), (0, 1)),
86
+ mode="constant",
87
+ constant_values=0.0,
88
+ ),
89
+ axis=0,
90
+ )
91
+ return frequency_slice
92
+
93
+
94
+ def make_1d_coordinate_grid(
95
+ size: int,
96
+ grid_spacing: float | Float[np.ndarray, ""] | Float[Array, ""] = 1.0,
97
+ ) -> Float[Array, "*shape ndim"]:
98
+ """
99
+ Create a 1D real-space cartesian coordinate array.
100
+
101
+ **Arguments:**
102
+
103
+ - `size`: Size of the coordinate array.
104
+ - `grid_spacing`: The grid spacing, in units of length.
105
+
106
+ **Returns:**
107
+
108
+ A 1D cartesian coordinate array in real space.
109
+ """
110
+ coordinate_array = _make_coordinates_or_frequencies_1d(
111
+ size, grid_spacing=grid_spacing, real_space=True
112
+ )
113
+ return coordinate_array
114
+
115
+
116
+ def make_1d_frequency_grid(
117
+ size: int,
118
+ grid_spacing: float | Float[np.ndarray, ""] | Float[Array, ""] = 1.0,
119
+ half_space: bool = True,
120
+ ) -> Float[Array, "*shape ndim"]:
121
+ """Create a 1D fourier-space cartesian coordinate array.
122
+ If `half_space = False`, the zero-frequency component is in the beginning.
123
+
124
+ Arguments
125
+ ---------
126
+ - `size`: Size of the coordinate array.
127
+ - `grid_spacing`: The grid spacing, in units of length.
128
+ - `half_space`:
129
+ Return a frequency grid on the half space.
130
+ `shape[-1]` is the axis on which the negative
131
+ frequencies are omitted.
132
+
133
+ **Returns:**
134
+
135
+ A 1D cartesian coordinate array in frequency space.
136
+ """
137
+ frequency_array = _make_coordinates_or_frequencies_1d(
138
+ size,
139
+ grid_spacing=grid_spacing,
140
+ real_space=False,
141
+ rfftfreq=half_space,
142
+ )
143
+ return frequency_array
144
+
145
+
146
+ def _make_coordinates_or_frequencies(
147
+ shape: tuple[int, ...],
148
+ grid_spacing: float | Float[np.ndarray, ""] | Float[Array, ""] = 1.0,
149
+ real_space: bool = False,
150
+ half_space: bool = True,
151
+ ) -> Float[Array, "*shape ndim"]:
152
+ ndim = len(shape)
153
+ coords1D = []
154
+ for idx in range(ndim):
155
+ if real_space:
156
+ c1D = _make_coordinates_or_frequencies_1d(
157
+ shape[idx], grid_spacing, real_space
158
+ )
159
+ else:
160
+ if not half_space:
161
+ rfftfreq = False
162
+ else:
163
+ rfftfreq = False if idx < ndim - 1 else True
164
+ c1D = _make_coordinates_or_frequencies_1d(
165
+ shape[idx], grid_spacing, real_space, rfftfreq
166
+ )
167
+ coords1D.append(c1D)
168
+ if ndim == 2:
169
+ y, x = coords1D
170
+ xv, yv = jnp.meshgrid(x, y, indexing="xy")
171
+ coords = jnp.stack([xv, yv], axis=-1)
172
+ elif ndim == 3:
173
+ z, y, x = coords1D
174
+ xv, yv, zv = jnp.meshgrid(x, y, z, indexing="xy")
175
+ xv, yv, zv = [
176
+ jnp.transpose(rv, axes=[2, 0, 1]) for rv in [xv, yv, zv]
177
+ ] # Change axis ordering to [z, y, x]
178
+ coords = jnp.stack([xv, yv, zv], axis=-1)
179
+ else:
180
+ raise ValueError(
181
+ "Only 2D and 3D coordinate grids are supported. "
182
+ f"Tried to create a grid of shape {shape}."
183
+ )
184
+
185
+ return coords
186
+
187
+
188
+ def _make_coordinates_or_frequencies_1d(
189
+ size: int,
190
+ grid_spacing: float | Float[np.ndarray, ""] | Float[Array, ""],
191
+ real_space: bool = False,
192
+ rfftfreq: Optional[bool] = None,
193
+ ) -> Float[Array, " size"]:
194
+ """One-dimensional coordinates in real or fourier space"""
195
+ if real_space:
196
+ make_1d = lambda size, dx: jnp.fft.fftshift(jnp.fft.fftfreq(size, 1 / dx)) * size
197
+ else:
198
+ if rfftfreq is None:
199
+ raise ValueError("Argument rfftfreq cannot be None if real_space=False.")
200
+ else:
201
+ fn = jnp.fft.rfftfreq if rfftfreq else jnp.fft.fftfreq
202
+ make_1d = lambda size, dx: fn(size, grid_spacing)
203
+
204
+ return make_1d(size, grid_spacing)
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '0.3.3rc1'
16
+ __version_tuple__ = version_tuple = (0, 3, 3)
@@ -0,0 +1,15 @@
1
+ from ._dataset import AbstractDataset as AbstractDataset
2
+ from ._particle_stack import (
3
+ AbstractParticleStack as AbstractParticleStack,
4
+ )
5
+ from ._relion import (
6
+ AbstractRelionDataset as AbstractRelionDataset,
7
+ RelionHelicalDataset as RelionHelicalDataset,
8
+ RelionHelicalMetadata as RelionHelicalMetadata,
9
+ RelionParticleDataset as RelionParticleDataset,
10
+ RelionParticleMetadata as RelionParticleMetadata,
11
+ RelionParticleParameters as RelionParticleParameters,
12
+ RelionParticleStack as RelionParticleStack,
13
+ write_simulated_image_stack_from_starfile as write_simulated_image_stack_from_starfile, # noqa
14
+ write_starfile_with_particle_parameters as write_starfile_with_particle_parameters,
15
+ )
@@ -0,0 +1,89 @@
1
+ """Functionality in `cryojax` for representing datasets."""
2
+
3
+ import abc
4
+ import dataclasses
5
+ from typing import Any
6
+
7
+
8
+ @dataclasses.dataclass(frozen=True)
9
+ class AbstractDataset(metaclass=abc.ABCMeta):
10
+ """An abstraction of a dataset in `cryojax`. To create an
11
+ `AbstractDataset`, implement its `__init__`, `__getitem__`, and
12
+ `__len__` methods.
13
+
14
+ This follows the
15
+ [`torch.utils.data.Dataset`](https://pytorch.org/docs/stable/data.html#torch.utils.data.Dataset)
16
+ API and can easily be wrapped into a pytorch `Dataset` with the
17
+ following pattern:
18
+
19
+ ```python
20
+ from torch.utils.data import Dataset
21
+
22
+ class CustomTorchDataset(Dataset):
23
+
24
+ def __init__(cryojax_dataset: AbstractDataset):
25
+ self.cryojax_dataset = cryojax_dataset
26
+
27
+ def __getitem___(self, index) -> AbstractParticleStack:
28
+ return self.cryojax_dataset[index]
29
+
30
+ def __len__(self) -> int:
31
+ return len(self.cryojax_dataset)
32
+ ```
33
+
34
+ !!! question "How do I implement an `AbstractDataset`?"
35
+
36
+ Implementing an `AbstractDataset` is not like implementing
37
+ most other classes in `cryojax`, which are `equinox.Module`s.
38
+ An `equinox.Module` is just a pytree, so it can be safely
39
+ passed to `jax` transformations. However, an `AbstractDataset`
40
+ can *not* be passed to `jax` transformations. Therefore, it is
41
+ not a pytree. Rather, it is a [frozen dataclass](https://docs.python.org/3/library/dataclasses.html#frozen-instances).
42
+
43
+ There are gotchas when implementing frozen dataclasses. For example,
44
+ the following will result in a `FrozenInstanceError`:
45
+
46
+ ```python
47
+ import dataclasses
48
+
49
+ @dataclasses.dataclass(frozen=True)
50
+ class BuggyFrozenDataclass:
51
+
52
+ a: int
53
+
54
+ def __init__(self, a: int):
55
+ self.a = a
56
+
57
+ BuggyFrozenDataclass(10) # Will raise the FrozenInstanceError
58
+ ```
59
+
60
+ As of the time of writing this, frozen dataclasses must use the following
61
+ syntax to set attributes in a custom `__init__`:
62
+
63
+ ```python
64
+ import dataclasses
65
+
66
+ @dataclasses.dataclass(frozen=True)
67
+ class CorrectFrozenDataclass:
68
+
69
+ a: int
70
+
71
+ def __init__(self, a: int):
72
+ object.__setattr__(self, "a", a)
73
+
74
+ example = CorrectFrozenDataclass(10) # Will not raise a FrozenInstanceError
75
+ print(example.a) # This will print a, which here was 10
76
+ ```
77
+ """
78
+
79
+ @abc.abstractmethod
80
+ def __init__(self, *args: Any, **kwargs: Any):
81
+ raise NotImplementedError
82
+
83
+ @abc.abstractmethod
84
+ def __getitem__(self, index) -> Any:
85
+ raise NotImplementedError
86
+
87
+ @abc.abstractmethod
88
+ def __len__(self) -> int:
89
+ raise NotImplementedError
@@ -0,0 +1,15 @@
1
+ """Pytrees that represent particle stacks."""
2
+
3
+ from equinox import AbstractVar, Module
4
+ from jaxtyping import Array, Inexact
5
+
6
+
7
+ class AbstractParticleStack(Module, strict=True):
8
+ """An abstraction of a particle stack, represented by a pytree
9
+ that stores an image stack.
10
+
11
+ Subclasses should also include parameters included in the
12
+ image formation model, typically represented with `cryojax` objects.
13
+ """
14
+
15
+ image_stack: AbstractVar[Inexact[Array, "... y_dim x_dim"]]
@@ -0,0 +1,13 @@
1
+ from ._starfile_reading import (
2
+ AbstractRelionDataset as AbstractRelionDataset,
3
+ RelionHelicalDataset as RelionHelicalDataset,
4
+ RelionHelicalMetadata as RelionHelicalMetadata,
5
+ RelionParticleDataset as RelionParticleDataset,
6
+ RelionParticleMetadata as RelionParticleMetadata,
7
+ RelionParticleParameters as RelionParticleParameters,
8
+ RelionParticleStack as RelionParticleStack,
9
+ )
10
+ from ._starfile_writing import (
11
+ write_simulated_image_stack_from_starfile as write_simulated_image_stack_from_starfile, # noqa: E501
12
+ write_starfile_with_particle_parameters as write_starfile_with_particle_parameters,
13
+ )