-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_process_sxt_tilt_series.py
More file actions
143 lines (133 loc) · 4.63 KB
/
Copy pathtest_process_sxt_tilt_series.py
File metadata and controls
143 lines (133 loc) · 4.63 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from unittest import mock
from sqlmodel import Session, select
from murfey.util.db import (
AutoProcProgram,
DataCollection,
DataCollectionGroup,
ProcessingJob,
TiltSeries,
)
from murfey.workflows.sxt import process_sxt_tilt_series
from tests.conftest import ExampleVisit, get_or_create_db_entry
def set_up_db(murfey_db_session: Session):
# Insert common elements needed in all picking tests
dcg_entry: DataCollectionGroup = get_or_create_db_entry(
murfey_db_session,
DataCollectionGroup,
lookup_kwargs={
"id": 0,
"session_id": ExampleVisit.murfey_session_id,
"tag": "/path/to/tomogram_source",
},
)
dc_entry: DataCollection = get_or_create_db_entry(
murfey_db_session,
DataCollection,
lookup_kwargs={
"id": 0,
"tag": "tomogram_tag",
"dcg_id": dcg_entry.id,
},
)
aretomo_pj_entry: ProcessingJob = get_or_create_db_entry(
murfey_db_session,
ProcessingJob,
lookup_kwargs={
"id": 1,
"recipe": "sxt-aretomo",
"dc_id": dc_entry.id,
},
)
imod_pj_entry: ProcessingJob = get_or_create_db_entry(
murfey_db_session,
ProcessingJob,
lookup_kwargs={
"id": 2,
"recipe": "sxt-imod-patch-wbp",
"dc_id": dc_entry.id,
},
)
aretomo_autoproc_entry = get_or_create_db_entry(
murfey_db_session,
AutoProcProgram,
lookup_kwargs={
"id": 0,
"pj_id": aretomo_pj_entry.id,
},
)
imod_autoproc_entry = get_or_create_db_entry(
murfey_db_session,
AutoProcProgram,
lookup_kwargs={
"id": 1,
"pj_id": imod_pj_entry.id,
},
)
return dcg_entry.id, dc_entry.id, aretomo_autoproc_entry.id, imod_autoproc_entry.id
@mock.patch("murfey.workflows.sxt.process_sxt_tilt_series._transport_object")
def test_process_new_sxt_tilt_series(
mock_transport, murfey_db_session: Session, tmp_path
):
"""Run the picker feedback with less particles than needed for classification"""
dcg_id, dc_id, app_id_aretomo, app_id_imod = set_up_db(murfey_db_session)
new_parameters = process_sxt_tilt_series.SXTTiltSeriesInfo(
session_id=ExampleVisit.murfey_session_id,
tag="tomogram_tag",
source="/path/to/tomogram_source",
txrm=f"{tmp_path}/cm12345-6/raw/tomogram_tag.txrm",
xrm_reference=f"{tmp_path}/cm12345-6/raw/ref.xrm",
tilt_series_length=5,
pixel_size=100,
tilt_offset=1,
)
# Run the registration
process_sxt_tilt_series.process_sxt_tilt_series(
"cm12345-6",
ExampleVisit.murfey_session_id,
new_parameters,
murfey_db_session,
)
# Check the processing message
mock_transport.send.assert_any_call(
"processing_recipe",
{
"recipes": ["sxt-aretomo"],
"parameters": {
"txrm_file": f"{tmp_path}/cm12345-6/raw/tomogram_tag.txrm",
"xrm_reference": f"{tmp_path}/cm12345-6/raw/ref.xrm",
"dcid": dc_id,
"appid": app_id_aretomo,
"stack_file": f"{tmp_path}/cm12345-6/processed/tomogram_tag/sxt-aretomo/Tomograms/tomogram_tag_stack.mrc",
"tilt_axis": 0,
"pixel_size": 100,
"manual_tilt_offset": -1,
"node_creator_queue": "node_creator",
},
},
new_connection=True,
)
mock_transport.send.assert_any_call(
"processing_recipe",
{
"recipes": ["sxt-imod-patch-wbp"],
"parameters": {
"txrm_file": f"{tmp_path}/cm12345-6/raw/tomogram_tag.txrm",
"xrm_reference": f"{tmp_path}/cm12345-6/raw/ref.xrm",
"dcid": dc_id,
"appid": app_id_imod,
"stack_file": f"{tmp_path}/cm12345-6/processed/tomogram_tag/sxt-imod-patch-wbp/Tomograms/tomogram_tag_stack.mrc",
"tilt_axis": 0,
"pixel_size": 100,
"manual_tilt_offset": -1,
"node_creator_queue": "node_creator",
},
},
new_connection=True,
)
# Check the database insert
tilt_series_entry = murfey_db_session.exec(select(TiltSeries)).one()
assert tilt_series_entry.session_id == ExampleVisit.murfey_session_id
assert tilt_series_entry.tag == "tomogram_tag"
assert tilt_series_entry.rsync_source == "/path/to/tomogram_source"
assert tilt_series_entry.tilt_series_length == 5
assert tilt_series_entry.processing_requested