pytme 0.1.8__cp311-cp311-macosx_14_0_arm64.whl → 0.2.0b0__cp311-cp311-macosx_14_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 (36) hide show
  1. {pytme-0.1.8.data → pytme-0.2.0b0.data}/scripts/match_template.py +148 -126
  2. pytme-0.2.0b0.data/scripts/postprocess.py +570 -0
  3. {pytme-0.1.8.data → pytme-0.2.0b0.data}/scripts/preprocessor_gui.py +244 -60
  4. {pytme-0.1.8.dist-info → pytme-0.2.0b0.dist-info}/METADATA +3 -1
  5. pytme-0.2.0b0.dist-info/RECORD +66 -0
  6. {pytme-0.1.8.dist-info → pytme-0.2.0b0.dist-info}/WHEEL +1 -1
  7. scripts/extract_candidates.py +218 -0
  8. scripts/match_template.py +148 -126
  9. scripts/match_template_filters.py +852 -0
  10. scripts/postprocess.py +380 -435
  11. scripts/preprocessor_gui.py +244 -60
  12. scripts/refine_matches.py +218 -0
  13. tme/__init__.py +2 -1
  14. tme/__version__.py +1 -1
  15. tme/analyzer.py +545 -78
  16. tme/backends/cupy_backend.py +80 -15
  17. tme/backends/npfftw_backend.py +33 -2
  18. tme/backends/pytorch_backend.py +15 -7
  19. tme/density.py +156 -63
  20. tme/extensions.cpython-311-darwin.so +0 -0
  21. tme/matching_constrained.py +195 -0
  22. tme/matching_data.py +76 -32
  23. tme/matching_exhaustive.py +366 -204
  24. tme/matching_memory.py +1 -0
  25. tme/matching_optimization.py +728 -651
  26. tme/matching_utils.py +152 -8
  27. tme/orientations.py +561 -0
  28. tme/preprocessor.py +21 -18
  29. tme/structure.py +2 -37
  30. pytme-0.1.8.data/scripts/postprocess.py +0 -625
  31. pytme-0.1.8.dist-info/RECORD +0 -61
  32. {pytme-0.1.8.data → pytme-0.2.0b0.data}/scripts/estimate_ram_usage.py +0 -0
  33. {pytme-0.1.8.data → pytme-0.2.0b0.data}/scripts/preprocess.py +0 -0
  34. {pytme-0.1.8.dist-info → pytme-0.2.0b0.dist-info}/LICENSE +0 -0
  35. {pytme-0.1.8.dist-info → pytme-0.2.0b0.dist-info}/entry_points.txt +0 -0
  36. {pytme-0.1.8.dist-info → pytme-0.2.0b0.dist-info}/top_level.txt +0 -0
@@ -152,101 +152,83 @@ def crop_data(data: Density, cutoff: float, data_mask: Density = None) -> bool:
152
152
 
153
153
  def parse_args():
154
154
  parser = argparse.ArgumentParser(description="Perform template matching.")
155
- parser.add_argument(
155
+
156
+ io_group = parser.add_argument_group("Input / Output")
157
+ io_group.add_argument(
156
158
  "-m",
157
159
  "--target",
158
160
  dest="target",
159
161
  type=str,
160
162
  required=True,
161
- help="Path to a target in CCP4/MRC format.",
163
+ help="Path to a target in CCP4/MRC, EM, H5 or another format supported by "
164
+ "tme.density.Density.from_file "
165
+ "https://kosinskilab.github.io/pyTME/reference/api/tme.density.Density.from_file.html",
162
166
  )
163
- parser.add_argument(
167
+ io_group.add_argument(
164
168
  "--target_mask",
165
169
  dest="target_mask",
166
170
  type=str,
167
171
  required=False,
168
- help="Path to a mask for the target target in CCP4/MRC format.",
169
- )
170
- parser.add_argument(
171
- "--cutoff_target",
172
- dest="cutoff_target",
173
- type=float,
174
- required=False,
175
- help="Target contour level (used for cropping).",
176
- default=None,
177
- )
178
- parser.add_argument(
179
- "--cutoff_template",
180
- dest="cutoff_template",
181
- type=float,
182
- required=False,
183
- help="Template contour level (used for cropping).",
184
- default=None,
172
+ help="Path to a mask for the target in a supported format (see target).",
185
173
  )
186
- parser.add_argument(
187
- "--no_centering",
188
- dest="no_centering",
189
- action="store_true",
190
- help="If set, assumes the template is centered and omits centering.",
191
- )
192
- parser.add_argument(
174
+ io_group.add_argument(
193
175
  "-i",
194
176
  "--template",
195
177
  dest="template",
196
178
  type=str,
197
179
  required=True,
198
- help="Path to a template in PDB/MMCIF or CCP4/MRC format.",
180
+ help="Path to a template in PDB/MMCIF or other supported formats (see target).",
199
181
  )
200
- parser.add_argument(
182
+ io_group.add_argument(
201
183
  "--template_mask",
202
184
  dest="template_mask",
203
185
  type=str,
204
186
  required=False,
205
- help="Path to a mask for the template in CCP4/MRC format.",
187
+ help="Path to a mask for the template in a supported format (see target).",
206
188
  )
207
- parser.add_argument(
189
+ io_group.add_argument(
208
190
  "-o",
191
+ "--output",
209
192
  dest="output",
210
193
  type=str,
211
194
  required=False,
212
195
  default="output.pickle",
213
- help="Path to output pickle file.",
196
+ help="Path to the output pickle file.",
214
197
  )
215
- parser.add_argument(
198
+ io_group.add_argument(
199
+ "--invert_target_contrast",
200
+ dest="invert_target_contrast",
201
+ action="store_true",
202
+ default=False,
203
+ help="Invert the target's contrast and rescale linearly between zero and one. "
204
+ "This option is intended for targets where templates to-be-matched have "
205
+ "negative values, e.g. tomograms.",
206
+ )
207
+ io_group.add_argument(
208
+ "--scramble_phases",
209
+ dest="scramble_phases",
210
+ action="store_true",
211
+ default=False,
212
+ help="Phase scramble the template to generate a noise score background.",
213
+ )
214
+
215
+ scoring_group = parser.add_argument_group("Scoring")
216
+ scoring_group.add_argument(
216
217
  "-s",
217
218
  dest="score",
218
219
  type=str,
219
220
  default="FLCSphericalMask",
221
+ choices=list(MATCHING_EXHAUSTIVE_REGISTER.keys()),
220
222
  help="Template matching scoring function.",
221
- choices=MATCHING_EXHAUSTIVE_REGISTER.keys(),
222
- )
223
- parser.add_argument(
224
- "-n",
225
- dest="cores",
226
- required=False,
227
- type=int,
228
- default=4,
229
- help="Number of cores used for template matching.",
230
- )
231
- parser.add_argument(
232
- "-r",
233
- "--ram",
234
- dest="memory",
235
- required=False,
236
- type=int,
237
- default=None,
238
- help="Amount of memory that can be used in bytes.",
239
223
  )
240
- parser.add_argument(
241
- "--memory_scaling",
242
- dest="memory_scaling",
243
- required=False,
244
- type=check_positive,
245
- default=0.85,
246
- help="Fraction of available memory that can be used."
247
- "Defaults to 0.85. Ignored if --ram is set",
224
+ scoring_group.add_argument(
225
+ "-p",
226
+ dest="peak_calling",
227
+ action="store_true",
228
+ default=False,
229
+ help="Perform peak calling instead of score aggregation.",
248
230
  )
249
- parser.add_argument(
231
+ scoring_group.add_argument(
250
232
  "-a",
251
233
  dest="angular_sampling",
252
234
  type=check_positive,
@@ -254,21 +236,25 @@ def parse_args():
254
236
  help="Angular sampling rate for template matching. "
255
237
  "A lower number yields more rotations. Values >= 180 sample only the identity.",
256
238
  )
257
- parser.add_argument(
258
- "-p",
259
- dest="peak_calling",
260
- action="store_true",
261
- default=False,
262
- help="When set perform peak calling instead of score aggregation.",
239
+
240
+
241
+ computation_group = parser.add_argument_group("Computation")
242
+ computation_group.add_argument(
243
+ "-n",
244
+ dest="cores",
245
+ required=False,
246
+ type=int,
247
+ default=4,
248
+ help="Number of cores used for template matching.",
263
249
  )
264
- parser.add_argument(
250
+ computation_group.add_argument(
265
251
  "--use_gpu",
266
252
  dest="use_gpu",
267
253
  action="store_true",
268
254
  default=False,
269
255
  help="Whether to perform computations on the GPU.",
270
256
  )
271
- parser.add_argument(
257
+ computation_group.add_argument(
272
258
  "--gpu_indices",
273
259
  dest="gpu_indices",
274
260
  type=str,
@@ -278,79 +264,55 @@ def parse_args():
278
264
  " If not provided but --use_gpu is set, CUDA_VISIBLE_DEVICES will"
279
265
  " be respected.",
280
266
  )
281
- parser.add_argument(
282
- "--invert_target_contrast",
283
- dest="invert_target_contrast",
284
- action="store_true",
285
- default=False,
286
- help="Invert the target contrast via multiplication with negative one and"
287
- " linear rescaling between zero and one. Note that this might lead to"
288
- " different baseline scores of individual target splits when using"
289
- " unnormalized scores. This option is intended for targets, where the"
290
- " object to-be-matched has negative values, i.e. tomograms.",
291
- )
292
- parser.add_argument(
293
- "--no_edge_padding",
294
- dest="no_edge_padding",
295
- action="store_true",
296
- default=False,
297
- help="Whether to pad the edges of the target. This is useful, if the target"
298
- " has a well defined bounding box, e.g. a density map.",
299
- )
300
- parser.add_argument(
301
- "--no_fourier_padding",
302
- dest="no_fourier_padding",
303
- action="store_true",
304
- default=False,
305
- help="Whether input arrays should be zero-padded to the full convolution shape"
306
- " for numerical stability. When working with very large targets such as"
307
- " tomograms it is safe to use this flag and benefit from the performance gain.",
308
- )
309
- parser.add_argument(
310
- "--scramble_phases",
311
- dest="scramble_phases",
312
- action="store_true",
313
- default=False,
314
- help="Whether to phase scramble the template for subsequent normalization.",
315
- )
316
- parser.add_argument(
317
- "--interpolation_order",
318
- dest="interpolation_order",
267
+ computation_group.add_argument(
268
+ "-r",
269
+ "--ram",
270
+ dest="memory",
319
271
  required=False,
320
272
  type=int,
321
- default=3,
322
- help="Spline interpolation used during rotations. If less than zero"
323
- " no interpolation is performed.",
273
+ default=None,
274
+ help="Amount of memory that can be used in bytes.",
324
275
  )
325
- parser.add_argument(
276
+ computation_group.add_argument(
277
+ "--memory_scaling",
278
+ dest="memory_scaling",
279
+ required=False,
280
+ type=float,
281
+ default=0.85,
282
+ help="Fraction of available memory that can be used. Defaults to 0.85 and is "
283
+ "ignored if --ram is set",
284
+ )
285
+ computation_group.add_argument(
326
286
  "--use_mixed_precision",
327
287
  dest="use_mixed_precision",
328
288
  action="store_true",
329
289
  default=False,
330
290
  help="Use float16 for real values operations where possible.",
331
291
  )
332
- parser.add_argument(
292
+ computation_group.add_argument(
333
293
  "--use_memmap",
334
294
  dest="use_memmap",
335
295
  action="store_true",
336
296
  default=False,
337
- help="Use memmaps to offload large data objects to disk. This is"
338
- " particularly useful for large inputs when using --use_gpu..",
297
+ help="Use memmaps to offload large data objects to disk. "
298
+ "Particularly useful for large inputs in combination with --use_gpu.",
339
299
  )
340
- parser.add_argument(
300
+ computation_group.add_argument(
341
301
  "--temp_directory",
342
302
  dest="temp_directory",
343
303
  default=None,
344
- help="Directory for temporary objects. Faster I/O typically improves runtime.",
304
+ help="Directory for temporary objects. Faster I/O improves runtime.",
345
305
  )
346
- parser.add_argument(
306
+
307
+ filter_group = parser.add_argument_group("Filters")
308
+ filter_group.add_argument(
347
309
  "--gaussian_sigma",
348
310
  dest="gaussian_sigma",
349
311
  type=float,
350
312
  required=False,
351
313
  help="Sigma parameter for Gaussian filtering the template.",
352
314
  )
353
- parser.add_argument(
315
+ filter_group.add_argument(
354
316
  "--bandpass_band",
355
317
  dest="bandpass_band",
356
318
  type=str,
@@ -358,15 +320,15 @@ def parse_args():
358
320
  help="Comma separated start and stop frequency for bandpass filtering the"
359
321
  " template, e.g. 0.1, 0.5",
360
322
  )
361
- parser.add_argument(
323
+ filter_group.add_argument(
362
324
  "--bandpass_smooth",
363
325
  dest="bandpass_smooth",
364
326
  type=float,
365
327
  required=False,
366
328
  default=None,
367
- help="Smooth parameter for the bandpass filter.",
329
+ help="Sigma smooth parameter for the bandpass filter.",
368
330
  )
369
- parser.add_argument(
331
+ filter_group.add_argument(
370
332
  "--tilt_range",
371
333
  dest="tilt_range",
372
334
  type=str,
@@ -374,16 +336,16 @@ def parse_args():
374
336
  help="Comma separated start and stop stage tilt angle, e.g. '50,45'. Used"
375
337
  " to create a wedge mask to be applied to the template.",
376
338
  )
377
- parser.add_argument(
339
+ filter_group.add_argument(
378
340
  "--tilt_step",
379
341
  dest="tilt_step",
380
342
  type=float,
381
343
  required=False,
382
344
  default=None,
383
- help="Step size between tilts, e.g. '5'. When set the wedge mask"
345
+ help="Step size between tilts. e.g. '5'. When set the wedge mask"
384
346
  " reflects the individual tilts, otherwise a continuous mask is used.",
385
347
  )
386
- parser.add_argument(
348
+ filter_group.add_argument(
387
349
  "--wedge_axes",
388
350
  dest="wedge_axes",
389
351
  type=str,
@@ -392,13 +354,73 @@ def parse_args():
392
354
  help="Axis index of wedge opening and tilt axis, e.g. 0,2 for a wedge that is open in"
393
355
  " z and tilted over x.",
394
356
  )
395
- parser.add_argument(
357
+ filter_group.add_argument(
396
358
  "--wedge_smooth",
397
359
  dest="wedge_smooth",
398
360
  type=float,
399
361
  required=False,
400
362
  default=None,
401
- help="Gaussian sigma used to smooth the wedge mask.",
363
+ help="Sigma smooth parameter for the wedge mask.",
364
+ )
365
+
366
+ performance_group = parser.add_argument_group("Performance")
367
+ performance_group.add_argument(
368
+ "--cutoff_target",
369
+ dest="cutoff_target",
370
+ type=float,
371
+ required=False,
372
+ default=None,
373
+ help="Target contour level (used for cropping).",
374
+ )
375
+ performance_group.add_argument(
376
+ "--cutoff_template",
377
+ dest="cutoff_template",
378
+ type=float,
379
+ required=False,
380
+ default=None,
381
+ help="Template contour level (used for cropping).",
382
+ )
383
+ performance_group.add_argument(
384
+ "--no_centering",
385
+ dest="no_centering",
386
+ action="store_true",
387
+ help="Assumes the template is already centered and omits centering.",
388
+ )
389
+ performance_group.add_argument(
390
+ "--no_edge_padding",
391
+ dest="no_edge_padding",
392
+ action="store_true",
393
+ default=False,
394
+ help="Whether to not pad the edges of the target. Can be set if the target"
395
+ " has a well defined bounding box, e.g. a masked reconstruction.",
396
+ )
397
+ performance_group.add_argument(
398
+ "--no_fourier_padding",
399
+ dest="no_fourier_padding",
400
+ action="store_true",
401
+ default=False,
402
+ help="Whether input arrays should not be zero-padded to full convolution shape "
403
+ "for numerical stability. When working with very large targets, e.g. tomograms, "
404
+ "it is safe to use this flag and benefit from the performance gain.",
405
+ )
406
+ performance_group.add_argument(
407
+ "--interpolation_order",
408
+ dest="interpolation_order",
409
+ required=False,
410
+ type=int,
411
+ default=3,
412
+ help="Spline interpolation used for template rotations. If less than zero "
413
+ "no interpolation is performed.",
414
+ )
415
+
416
+ analyzer_group = parser.add_argument_group("Analyzer")
417
+ analyzer_group.add_argument(
418
+ "--score_threshold",
419
+ dest="score_threshold",
420
+ required=False,
421
+ type=float,
422
+ default=0,
423
+ help="Minimum template matching scores to consider for analysis.",
402
424
  )
403
425
 
404
426
  args = parser.parse_args()
@@ -673,7 +695,7 @@ def main():
673
695
  exit(-1)
674
696
 
675
697
  analyzer_args = {
676
- "score_threshold": 0,
698
+ "score_threshold": args.score_threshold,
677
699
  "number_of_peaks": 1000,
678
700
  "convolution_mode": "valid",
679
701
  "use_memmap": args.use_memmap,