|
57 | 57 | TiltSeries, |
58 | 58 | ) |
59 | 59 | from murfey.util.models import ProcessingParametersSPA, ProcessingParametersTomo |
60 | | -from murfey.util.processing_params import cryolo_model_path, default_spa_parameters |
| 60 | +from murfey.util.processing_params import ( |
| 61 | + cryolo_model_path, |
| 62 | + default_spa_parameters, |
| 63 | + motion_corrected_mrc, |
| 64 | +) |
61 | 65 | from murfey.util.tomo import midpoint |
62 | 66 |
|
63 | 67 | logger = getLogger("murfey.server.api.workflow") |
@@ -364,29 +368,7 @@ async def request_spa_preprocessing( |
364 | 368 | machine_config = get_machine_config(instrument_name=instrument_name)[ |
365 | 369 | instrument_name |
366 | 370 | ] |
367 | | - parts = [secure_filename(p) for p in Path(proc_file.path).parts] |
368 | | - visit_idx = parts.index(visit_name) |
369 | | - core = Path("/") / Path(*parts[: visit_idx + 1]) |
370 | | - ppath = Path("/") / Path(*parts) |
371 | | - sub_dataset = ppath.relative_to(core).parts[0] |
372 | | - extra_path = machine_config.processed_extra_directory |
373 | | - for i, p in enumerate(ppath.parts): |
374 | | - if p.startswith("raw"): |
375 | | - movies_path_index = i |
376 | | - break |
377 | | - else: |
378 | | - raise ValueError(f"{proc_file.path} does not contain a raw directory") |
379 | | - mrc_out = ( |
380 | | - core |
381 | | - / machine_config.processed_directory_name |
382 | | - / sub_dataset |
383 | | - / extra_path |
384 | | - / "MotionCorr" |
385 | | - / "job002" |
386 | | - / "Movies" |
387 | | - / "/".join(ppath.parts[movies_path_index + 1 : -1]) |
388 | | - / str(ppath.stem + "_motion_corrected.mrc") |
389 | | - ) |
| 371 | + mrc_out = motion_corrected_mrc(Path(proc_file.path), visit_name, machine_config) |
390 | 372 | try: |
391 | 373 | collected_ids = db.exec( |
392 | 374 | select(DataCollectionGroup, DataCollection, ProcessingJob, AutoProcProgram) |
@@ -490,7 +472,8 @@ async def request_spa_preprocessing( |
490 | 472 | _transport_object.send("processing_recipe", zocalo_message) |
491 | 473 | else: |
492 | 474 | logger.error( |
493 | | - f"Pe-processing was requested for {sanitise(ppath.name)} but no Zocalo transport object was found" |
| 475 | + f"Pre-processing was requested for {sanitise(Path(proc_file.path).name)} " |
| 476 | + "but no Zocalo transport object was found" |
494 | 477 | ) |
495 | 478 | return proc_file |
496 | 479 |
|
@@ -645,22 +628,7 @@ async def request_tomography_preprocessing( |
645 | 628 | machine_config = get_machine_config(instrument_name=instrument_name)[ |
646 | 629 | instrument_name |
647 | 630 | ] |
648 | | - visit_idx = Path(proc_file.path).parts.index(visit_name) |
649 | | - core = Path(*Path(proc_file.path).parts[: visit_idx + 1]) |
650 | | - ppath = Path("/".join(secure_filename(p) for p in Path(proc_file.path).parts)) |
651 | | - sub_dataset = "/".join(ppath.relative_to(core).parts[:-1]) |
652 | | - extra_path = machine_config.processed_extra_directory |
653 | | - mrc_out = ( |
654 | | - core |
655 | | - / machine_config.processed_directory_name |
656 | | - / sub_dataset |
657 | | - / extra_path |
658 | | - / "MotionCorr" |
659 | | - / "job002" |
660 | | - / "Movies" |
661 | | - / str(ppath.stem + "_motion_corrected.mrc") |
662 | | - ) |
663 | | - mrc_out = Path("/".join(secure_filename(p) for p in mrc_out.parts)) |
| 631 | + mrc_out = motion_corrected_mrc(Path(proc_file.path), visit_name, machine_config) |
664 | 632 |
|
665 | 633 | recipe_name = machine_config.recipes.get("em-tomo-preprocess", "em-tomo-preprocess") |
666 | 634 |
|
@@ -731,7 +699,8 @@ async def request_tomography_preprocessing( |
731 | 699 | _transport_object.send("processing_recipe", zocalo_message) |
732 | 700 | else: |
733 | 701 | logger.error( |
734 | | - f"Pe-processing was requested for {sanitise(ppath.name)} but no Zocalo transport object was found" |
| 702 | + f"Pre-processing was requested for {sanitise(Path(proc_file.path).name)} " |
| 703 | + f"but no Zocalo transport object was found" |
735 | 704 | ) |
736 | 705 | return proc_file |
737 | 706 | else: |
|
0 commit comments