Skip to content

Commit 5bf9842

Browse files
author
David Erb
committed
changes export sort order
1 parent 72190cd commit 5bf9842

File tree

5 files changed

+68
-29
lines changed

5 files changed

+68
-29
lines changed

src/echolocator_lib/guis/aiohttp.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,16 @@ async def __export_to_soakdb3(self, opaque, request_dict):
571571
crystal_well_filter, why="[EXPFIL] get list to be epxorted"
572572
)
573573

574+
# Sort the list based on the (computed) row_first_position field.
575+
sorted_models = sorted(
576+
crystal_well_models,
577+
key=lambda crystal_well_model: crystal_well_model.row_first_position(),
578+
)
579+
574580
logger.debug(f"[EXPFIL] found {len(crystal_well_models)} to be exported")
575581

576582
# Export the crystal wells to the appropriate soakdb3 visit.
577-
await self.__export_to_soakdb3_visit(visit_filter, crystal_well_models)
583+
await self.__export_to_soakdb3_visit(visit_filter, sorted_models)
578584

579585
# Make the list of droplocations to update with the exported flag.
580586
crystal_well_droplocation_models: List[CrystalWellDroplocationModel] = list()
@@ -692,9 +698,16 @@ async def __export_to_csv(self, opaque, request_dict):
692698
crystal_plate_uuid,
693699
plate_crystal_well_models,
694700
) in plates_crystal_well_models.items():
701+
702+
# Sort the list based on the (computed) row_first_position field.
703+
sorted_models = sorted(
704+
plate_crystal_well_models,
705+
key=lambda crystal_well_model: crystal_well_model.row_first_position(),
706+
)
707+
695708
# Export the crystal wells for this plate to the appropriate csv file named for the plate.
696709
filename = await self.__export_to_csv_plate(
697-
visit_filter, crystal_plate_uuid, plate_crystal_well_models
710+
visit_filter, crystal_plate_uuid, sorted_models
698711
)
699712

700713
confirmations.append(

tests/base.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self):
3535
self.tasks_execution_outputs = {}
3636
self.residuals = ["stdout.txt", "stderr.txt", "main.log"]
3737

38-
self.injected_count = 0
38+
self.__injected_count = 0
3939
self.visit = "cm00001-1"
4040
self.__barcode_template = "98a%d"
4141
self.crystal_plate_uuid = None
@@ -131,13 +131,33 @@ async def inject(self, xchembku, autolocation: bool, droplocation: bool):
131131
if self.crystal_plate_uuid is None:
132132
await self.inject_plate(xchembku)
133133

134-
self.injected_count += 1
135-
136-
filename = "/tmp/%03d.jpg" % (self.injected_count)
134+
letter = "A"
135+
if self.__injected_count > 3:
136+
letter = "B"
137+
138+
self.__injected_count += 1
139+
filename = "/tmp/%02d%s_1.jpg" % (self.__injected_count, letter)
140+
position = "%s%02da" % (letter, self.__injected_count)
141+
142+
positions = [
143+
"A01a",
144+
"A02a",
145+
"A03a",
146+
"B01a",
147+
"B02a",
148+
"B02a",
149+
"C01a",
150+
"C02a",
151+
"C03a",
152+
"D01a",
153+
"D02a",
154+
"D03a",
155+
]
156+
position = positions[self.__injected_count - 1]
137157

138158
# Write well record.
139159
m = CrystalWellModel(
140-
position="%02dA_1" % (self.injected_count),
160+
position=position,
141161
filename=filename,
142162
crystal_plate_uuid=self.crystal_plate_uuid,
143163
)
@@ -148,11 +168,11 @@ async def inject(self, xchembku, autolocation: bool, droplocation: bool):
148168
# Add a crystal well autolocation.
149169
t = CrystalWellAutolocationModel(
150170
crystal_well_uuid=m.uuid,
151-
number_of_crystals=self.injected_count,
171+
number_of_crystals=self.__injected_count,
152172
well_centroid_x=400,
153173
well_centroid_y=500,
154-
auto_target_x=self.injected_count * 10 + 0,
155-
auto_target_y=self.injected_count * 10 + 1,
174+
auto_target_x=self.__injected_count * 10 + 0,
175+
auto_target_y=self.__injected_count * 10 + 1,
156176
)
157177

158178
await xchembku.originate_crystal_well_autolocations([t])
@@ -161,8 +181,8 @@ async def inject(self, xchembku, autolocation: bool, droplocation: bool):
161181
# Add a crystal well droplocation.
162182
t = CrystalWellDroplocationModel(
163183
crystal_well_uuid=m.uuid,
164-
confirmed_target_x=self.injected_count * 100 + 2,
165-
confirmed_target_y=self.injected_count * 100 + 3,
184+
confirmed_target_x=self.__injected_count * 100 + 2,
185+
confirmed_target_y=self.__injected_count * 100 + 3,
166186
is_usable=True,
167187
)
168188

tests/test_export_to_csv.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,16 @@ async def __export_wells(self, crystal_wells):
195195

196196
# Check the well positions are those that are considered "confirmed".
197197
# The position constants are fromt the Swiss3 microns computation.
198-
assert rows[0][0] == "02A_1"
199-
assert int(rows[0][1]) == -561
200-
assert int(rows[0][2]) == -842
201-
assert rows[1][0] == "04A_1"
202-
assert int(rows[1][1]) == 6
203-
assert int(rows[1][2]) == -274
204-
assert rows[2][0] == "05A_1"
198+
# Note the order here: row_first_position gives get all letters in row 01 before any letters in row 02.
199+
assert rows[0][0] == "B01a"
200+
assert int(rows[0][1]) == 6
201+
assert int(rows[0][2]) == -274
202+
203+
assert rows[1][0] == "A02a"
204+
assert int(rows[1][1]) == -561
205+
assert int(rows[1][2]) == -842
206+
207+
assert rows[2][0] == "B02a"
205208
assert int(rows[2][1]) == 289
206209
assert int(rows[2][2]) == 9
207210

tests/test_export_to_soakdb3.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,16 @@ async def __export_wells(self, crystal_wells):
211211
assert len(queried_models) == 3
212212

213213
# The position constants are fromt the Swiss3 microns computation.
214-
assert queried_models[0].CrystalWell == "02A_1"
215-
assert int(queried_models[0].EchoX) == -561
216-
assert int(queried_models[0].EchoY) == -842
217-
assert queried_models[1].CrystalWell == "04A_1"
218-
assert int(queried_models[1].EchoX) == 6
219-
assert int(queried_models[1].EchoY) == -274
220-
assert queried_models[2].CrystalWell == "05A_1"
214+
# Note the order here: row_first_position gives get all letters in row 01 before any letters in row 02.
215+
assert queried_models[0].CrystalWell == "B01a"
216+
assert int(queried_models[0].EchoX) == 6
217+
assert int(queried_models[0].EchoY) == -274
218+
219+
assert queried_models[1].CrystalWell == "A02a"
220+
assert int(queried_models[1].EchoX) == -561
221+
assert int(queried_models[1].EchoY) == -842
222+
223+
assert queried_models[2].CrystalWell == "B02a"
221224
assert int(queried_models[2].EchoX) == 289
222225
assert int(queried_models[2].EchoY) == 9
223226

tests/test_fetch_image.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ async def __request_anchor(self, crystal_wells):
205205
Cookies.IMAGE_LIST_UX,
206206
],
207207
Keywords.COMMAND: Commands.FETCH_IMAGE,
208-
Keywords.CRYSTAL_WELL_INDEX: 2, # 04A_1
208+
Keywords.CRYSTAL_WELL_INDEX: 2, # B01a
209209
}
210210

211211
response = await echolocator_guis_get_default().client_protocolj(
@@ -218,7 +218,7 @@ async def __request_anchor(self, crystal_wells):
218218

219219
record = response["record"]
220220
assert record is not None
221-
assert record["position"] == "04A_1"
221+
assert record["position"] == "B01a"
222222

223223
# -------------------------------------------------------------------------------------
224224
# Same query again, but rely on cookie for index.
@@ -230,4 +230,4 @@ async def __request_anchor(self, crystal_wells):
230230
)
231231

232232
record = response["record"]
233-
assert record["position"] == "04A_1"
233+
assert record["position"] == "B01a"

0 commit comments

Comments
 (0)