-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathalign_and_merge.py
More file actions
72 lines (63 loc) · 2.19 KB
/
Copy pathalign_and_merge.py
File metadata and controls
72 lines (63 loc) · 2.19 KB
1
2
3
4
5
6
7
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
71
72
"""
Script to allow Murfey to request for an image alignment, colorisation, and merge job
from cryoemservices.
"""
from __future__ import annotations
from pathlib import Path
from typing import Optional
from murfey.util.config import get_machine_config
try:
from murfey.server.ispyb import TransportManager # Session
except AttributeError:
pass # Ignore if ISPyB credentials environment variable not set
def run(
# Session parameters
session_id: int,
instrument_name: str,
# Processing parameters
series_name: str,
images: list[Path],
metadata: Path,
# Optional session parameters
messenger: Optional[TransportManager] = None,
):
if not messenger:
raise Exception("Unable to find transport manager")
# Load feedback queue
machine_config = get_machine_config()[instrument_name]
feedback_queue: str = messenger.feedback_queue
# Work out session directory from file path
processed_folder = machine_config.processed_directory_name
if not images:
raise ValueError(f"No image files have been provided for {series_name!r}")
reference_file = images[0]
path_parts = list(reference_file.parts)
path_parts[0] = "" if path_parts[0] == "/" else path_parts[0]
try:
root_index = path_parts.index(processed_folder)
except ValueError:
raise ValueError(
f"The processed directory {processed_folder!r} could not be found in the "
f"file path for {str(reference_file)!r}"
)
session_dir = Path("/".join(path_parts[:root_index]))
# Submit message to cryoemservices
messenger.send(
"processing_recipe",
{
"recipes": ["clem-align-and-merge"],
"parameters": {
# Job parameters
"series_name": series_name,
"images": [str(file) for file in images],
"metadata": str(metadata),
# Other recipe parameters
"session_dir": str(session_dir),
"session_id": session_id,
"job_name": series_name,
"feedback_queue": feedback_queue,
},
},
new_connection=True,
)
return {"success": True}