pytme 0.2.9.post1__cp311-cp311-macosx_15_0_arm64.whl → 0.3b0__cp311-cp311-macosx_15_0_arm64.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 (63) hide show
  1. pytme-0.2.9.post1.data/scripts/estimate_ram_usage.py → pytme-0.3b0.data/scripts/estimate_memory_usage.py +16 -33
  2. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/match_template.py +224 -223
  3. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/postprocess.py +283 -163
  4. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/preprocess.py +11 -8
  5. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/preprocessor_gui.py +10 -9
  6. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/METADATA +10 -9
  7. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/RECORD +61 -58
  8. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/entry_points.txt +1 -1
  9. scripts/{estimate_ram_usage.py → estimate_memory_usage.py} +16 -33
  10. scripts/extract_candidates.py +224 -0
  11. scripts/match_template.py +224 -223
  12. scripts/postprocess.py +283 -163
  13. scripts/preprocess.py +11 -8
  14. scripts/preprocessor_gui.py +10 -9
  15. scripts/refine_matches.py +626 -0
  16. tests/preprocessing/test_frequency_filters.py +9 -4
  17. tests/test_analyzer.py +143 -138
  18. tests/test_matching_cli.py +85 -30
  19. tests/test_matching_exhaustive.py +1 -2
  20. tests/test_matching_optimization.py +4 -9
  21. tests/test_orientations.py +0 -1
  22. tme/__version__.py +1 -1
  23. tme/analyzer/__init__.py +2 -0
  24. tme/analyzer/_utils.py +25 -17
  25. tme/analyzer/aggregation.py +384 -220
  26. tme/analyzer/base.py +138 -0
  27. tme/analyzer/peaks.py +150 -91
  28. tme/analyzer/proxy.py +122 -0
  29. tme/backends/__init__.py +4 -3
  30. tme/backends/_cupy_utils.py +25 -24
  31. tme/backends/_jax_utils.py +4 -3
  32. tme/backends/cupy_backend.py +4 -13
  33. tme/backends/jax_backend.py +6 -8
  34. tme/backends/matching_backend.py +4 -3
  35. tme/backends/mlx_backend.py +4 -3
  36. tme/backends/npfftw_backend.py +7 -5
  37. tme/backends/pytorch_backend.py +14 -4
  38. tme/cli.py +126 -0
  39. tme/density.py +4 -3
  40. tme/filters/__init__.py +1 -1
  41. tme/filters/_utils.py +4 -3
  42. tme/filters/bandpass.py +6 -4
  43. tme/filters/compose.py +5 -4
  44. tme/filters/ctf.py +426 -214
  45. tme/filters/reconstruction.py +58 -28
  46. tme/filters/wedge.py +139 -61
  47. tme/filters/whitening.py +36 -36
  48. tme/matching_data.py +4 -3
  49. tme/matching_exhaustive.py +17 -16
  50. tme/matching_optimization.py +5 -4
  51. tme/matching_scores.py +4 -3
  52. tme/matching_utils.py +41 -3
  53. tme/memory.py +4 -3
  54. tme/orientations.py +9 -6
  55. tme/parser.py +5 -4
  56. tme/preprocessor.py +4 -3
  57. tme/rotations.py +10 -7
  58. tme/structure.py +4 -3
  59. tests/data/Maps/.DS_Store +0 -0
  60. tests/data/Structures/.DS_Store +0 -0
  61. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/WHEEL +0 -0
  62. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/licenses/LICENSE +0 -0
  63. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,9 @@
1
- """ Implements methods for non-exhaustive template matching.
1
+ """
2
+ Implements methods for non-exhaustive template matching.
2
3
 
3
- Copyright (c) 2023 European Molecular Biology Laboratory
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  import warnings
@@ -1308,4 +1309,4 @@ def optimize_match(
1308
1309
  result.x = np.zeros_like(result.x)
1309
1310
  translation, rotation = result.x[:ndim], result.x[ndim:]
1310
1311
  rotation_matrix = euler_to_rotationmatrix(rotation)
1311
- return translation, rotation_matrix, result.fun
1312
+ return translation, rotation_matrix, float(result.fun)
tme/matching_scores.py CHANGED
@@ -1,8 +1,9 @@
1
- """ Implements a range of cross-correlation coefficients.
1
+ """
2
+ Implements a range of cross-correlation coefficients.
2
3
 
3
- Copyright (c) 2023-2024 European Molecular Biology Laboratory
4
+ Copyright (c) 2023-2024 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  import warnings
tme/matching_utils.py CHANGED
@@ -1,8 +1,9 @@
1
- """ Utility functions for template matching.
1
+ """
2
+ Utility functions for template matching.
2
3
 
3
- Copyright (c) 2023 European Molecular Biology Laboratory
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  import os
@@ -1150,3 +1151,40 @@ def compute_extraction_box(
1150
1151
  keep = be.multiply(keep, clamp_change == 0)
1151
1152
 
1152
1153
  return obs_beg_clamp, obs_end_clamp, cand_beg, cand_end, keep
1154
+
1155
+
1156
+ class TqdmParallel(Parallel):
1157
+ """
1158
+ A minimal Parallel implementation using tqdm for progress reporting.
1159
+
1160
+ Parameters:
1161
+ -----------
1162
+ tqdm_args : dict, optional
1163
+ Dictionary of arguments passed to tqdm.tqdm
1164
+ *args, **kwargs:
1165
+ Arguments to pass to joblib.Parallel
1166
+ """
1167
+
1168
+ def __init__(self, tqdm_args: Dict = {}, *args, **kwargs):
1169
+ from tqdm import tqdm
1170
+
1171
+ super().__init__(*args, **kwargs)
1172
+ self.pbar = tqdm(**tqdm_args)
1173
+
1174
+ def __call__(self, iterable, *args, **kwargs):
1175
+ self.n_tasks = len(iterable) if hasattr(iterable, "__len__") else None
1176
+ return super().__call__(iterable, *args, **kwargs)
1177
+
1178
+ def print_progress(self):
1179
+ if self.n_tasks is None:
1180
+ return super().print_progress()
1181
+
1182
+ if self.n_tasks != self.pbar.total:
1183
+ self.pbar.total = self.n_tasks
1184
+ self.pbar.refresh()
1185
+
1186
+ self.pbar.n = self.n_completed_tasks
1187
+ self.pbar.refresh()
1188
+
1189
+ if self.n_completed_tasks >= self.n_tasks:
1190
+ self.pbar.close()
tme/memory.py CHANGED
@@ -1,8 +1,9 @@
1
- """ Compute memory consumption of template matching components.
1
+ """
2
+ Compute memory consumption of template matching components.
2
3
 
3
- Copyright (c) 2023 European Molecular Biology Laboratory
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  from abc import ABC, abstractmethod
tme/orientations.py CHANGED
@@ -1,10 +1,11 @@
1
- #!python3
2
- """ Handle template matching orientations and conversion between formats.
1
+ """
2
+ Handle template matching orientations and conversion between formats.
3
3
 
4
- Copyright (c) 2024 European Molecular Biology Laboratory
4
+ Copyright (c) 2024 European Molecular Biology Laboratory
5
5
 
6
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
7
7
  """
8
+
8
9
  from typing import List, Tuple
9
10
  from dataclasses import dataclass
10
11
  from string import ascii_lowercase, ascii_uppercase
@@ -14,7 +15,7 @@ import numpy as np
14
15
  from .parser import StarParser
15
16
  from .matching_utils import compute_extraction_box
16
17
 
17
- # Exceeds available numpy dimensions for default installations.
18
+ # Exceeds available numpy dimensions for default installations
18
19
  NAMES = ["x", "y", "z", *ascii_lowercase[:-3], *ascii_uppercase]
19
20
 
20
21
 
@@ -81,7 +82,7 @@ class Orientations:
81
82
  self.translations = np.array(self.translations).astype(np.float32)
82
83
  self.rotations = np.array(self.rotations).astype(np.float32)
83
84
  self.scores = np.array(self.scores).astype(np.float32)
84
- self.details = np.array(self.details).astype(np.float32)
85
+ self.details = np.array(self.details)
85
86
  n_orientations = set(
86
87
  [
87
88
  self.translations.shape[0],
@@ -324,6 +325,7 @@ class Orientations:
324
325
  "_rlnAngleRot",
325
326
  "_rlnAngleTilt",
326
327
  "_rlnAnglePsi",
328
+ "_rlnClassNumber",
327
329
  ]
328
330
  if source_path is not None:
329
331
  header.append("_rlnMicrographName")
@@ -339,6 +341,7 @@ class Orientations:
339
341
  for index, (translation, rotation, score, detail) in enumerate(self):
340
342
  line = [str(x) for x in translation]
341
343
  line.extend([str(x) for x in rotation])
344
+ line.extend([str(detail)])
342
345
 
343
346
  if source_path is not None:
344
347
  line.append(source_path)
tme/parser.py CHANGED
@@ -1,8 +1,9 @@
1
- """ Implements parsers for atomic structure file formats.
1
+ """
2
+ Implements parsers for atomic structure file formats.
2
3
 
3
- Copyright (c) 2023 European Molecular Biology Laboratory
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  import re
@@ -560,7 +561,7 @@ class StarParser(MMCIFParser):
560
561
  .. [1] https://www.iucr.org/__data/assets/file/0013/11416/star.5.html
561
562
  """
562
563
 
563
- def parse_input(self, lines: List[str], delimiter: str = "\t") -> Dict:
564
+ def parse_input(self, lines: List[str], delimiter: str = None) -> Dict:
564
565
  pattern = re.compile(r"\s*#.*")
565
566
 
566
567
  ret, category, block = {}, None, []
tme/preprocessor.py CHANGED
@@ -1,8 +1,9 @@
1
- """ Implements Preprocessor class for filtering operations.
1
+ """
2
+ Implements Preprocessor class for filtering operations.
2
3
 
3
- Copyright (c) 2023 European Molecular Biology Laboratory
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  import os
tme/rotations.py CHANGED
@@ -1,8 +1,9 @@
1
- """ Implements various means of generating rotation matrices.
1
+ """
2
+ Implements various means of generating rotation matrices.
2
3
 
3
- Copyright (c) 2023-2025 European Molecular Biology Laboratory
4
+ Copyright (c) 2023-2025 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  import yaml
@@ -183,12 +184,14 @@ def euler_to_rotationmatrix(angles: Tuple[float], seq: str = "zyz") -> NDArray:
183
184
  NDArray
184
185
  The generated rotation matrix.
185
186
  """
187
+ angles = np.asarray(angles)
188
+
186
189
  n_angles = len(angles)
187
- angle_convention = seq[:n_angles]
188
- if n_angles == 1:
189
- angles = (angles, 0, 0)
190
+ if angles.ndim == 2:
191
+ n_angles = angles.shape[1]
192
+
190
193
  rotation_matrix = Rotation.from_euler(
191
- seq=angle_convention, angles=angles, degrees=True
194
+ seq=seq[:n_angles], angles=angles, degrees=True
192
195
  )
193
196
  return rotation_matrix.as_matrix().astype(np.float32)
194
197
 
tme/structure.py CHANGED
@@ -1,8 +1,9 @@
1
- """ Implements class Structure to represent atomic structures.
1
+ """
2
+ Implements class Structure to represent atomic structures.
2
3
 
3
- Copyright (c) 2023 European Molecular Biology Laboratory
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
4
5
 
5
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
7
  """
7
8
 
8
9
  import warnings
tests/data/Maps/.DS_Store DELETED
Binary file
Binary file