Skip to content

Commit

Permalink
swap echo_coordinate for confirmed_microns
Browse files Browse the repository at this point in the history
  • Loading branch information
David Erb committed May 2, 2023
1 parent 1027f1e commit 18a8743
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 76 deletions.
8 changes: 4 additions & 4 deletions src/echolocator_lib/composers/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def compose_image_list(self, models: List[CrystalWellNeedingDroplocationModel]):
{"text": "well centroid x,y", "class": "T_well_centroid_x_y"},
{"text": "auto x,y", "class": "T_auto_target_x_y"},
{"text": "confirmed x,y", "class": "T_confirmed_target_x_y"},
{"text": "echo coordinate x,y", "class": "T_echo_coordinate_x_y"},
{"text": "echo coordinate x,y", "class": "T_confirmed_microns_x_y"},
{"text": "use", "class": "T_is_usable"},
{"text": "error", "class": "T_error"},
]
Expand Down Expand Up @@ -146,11 +146,11 @@ def compose_image_list(self, models: List[CrystalWellNeedingDroplocationModel]):
t = f"{model.confirmed_target_x}, {model.confirmed_target_y}"
html_lines.append("<td class='T_confirmed_target_x_y'>" + t + "</td>")

if model.echo_coordinate_x is None or model.echo_coordinate_y is None:
if model.confirmed_microns_x is None or model.confirmed_microns_y is None:
t = "-"
else:
t = f"{model.echo_coordinate_x}, {model.echo_coordinate_y}"
html_lines.append("<td class='T_echo_coordinate_x_y'>" + t + "</td>")
t = f"{model.confirmed_microns_x}, {model.confirmed_microns_y}"
html_lines.append("<td class='T_confirmed_microns_x_y'>" + t + "</td>")

t = model.is_usable
if t is None:
Expand Down
8 changes: 4 additions & 4 deletions src/echolocator_lib/guis/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ async def _export(self, opaque, request_dict):
for m in crystal_well_models:
row = []
row.append(m.position)
row.append(m.echo_coordinate_x or "")
row.append(m.echo_coordinate_y or "")
row.append(m.confirmed_microns_x or "")
row.append(m.confirmed_microns_y or "")
writer.writerow(row)

response = {
Expand All @@ -494,8 +494,8 @@ async def _export(self, opaque, request_dict):
LabVisit=visit,
CrystalPlate=crystal_plate_model.rockminer_collected_stem,
CrystalWell=m.position,
EchoX=m.echo_coordinate_x,
EchoY=m.echo_coordinate_y,
EchoX=m.confirmed_microns_x,
EchoY=m.confirmed_microns_y,
)
)

Expand Down
6 changes: 6 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

# Configurator.
from dls_multiconf_lib.multiconfs import Multiconfs, multiconfs_set_default

# Types which the CrystalPlateObjects factory can use to build an instance.
from xchembku_api.crystal_plate_objects.constants import (
ThingTypes as CrystalPlateObjectThingTypes,
)
from xchembku_api.models.crystal_plate_model import CrystalPlateModel
from xchembku_api.models.crystal_well_autolocation_model import (
CrystalWellAutolocationModel,
Expand Down Expand Up @@ -100,6 +105,7 @@ async def inject_plate(self, xchembku):
barcode=self.barcode,
rockminer_collected_stem=self.rockminer_collected_stem,
visit=self.visit,
thing_type=CrystalPlateObjectThingTypes.SWISS3,
)

await xchembku.upsert_crystal_plates([crystal_plate_model])
Expand Down
74 changes: 6 additions & 68 deletions tests/test_fetch_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
# Things xchembku provides.
from xchembku_api.datafaces.context import Context as XchembkuDatafaceClientContext
from xchembku_api.datafaces.datafaces import xchembku_datafaces_get_default
from xchembku_api.models.crystal_plate_model import CrystalPlateModel
from xchembku_api.models.crystal_well_autolocation_model import (
CrystalWellAutolocationModel,
)
from xchembku_api.models.crystal_well_droplocation_model import (
CrystalWellDroplocationModel,
)
from xchembku_api.models.crystal_well_model import CrystalWellModel

# Client context creator.
from echolocator_api.guis.context import Context as GuiClientContext
Expand Down Expand Up @@ -108,26 +100,15 @@ async def __run_part1(self, constants, output_directory):

await self.__request_initial()

# Make the plate on which the wells reside.
visit = "cm00001-1"
crystal_plate_model = CrystalPlateModel(
formulatrix__plate__id=10,
barcode="98ab",
visit=visit,
)

await xchembku.upsert_crystal_plates([crystal_plate_model])
self.__crystal_plate_uuid = crystal_plate_model.uuid

crystal_wells = []

# Inject some wells.
crystal_wells.append(await self.__inject(xchembku, False, False))
crystal_wells.append(await self.__inject(xchembku, True, True))
crystal_wells.append(await self.__inject(xchembku, True, False))
crystal_wells.append(await self.__inject(xchembku, True, True))
crystal_wells.append(await self.__inject(xchembku, True, True))
crystal_wells.append(await self.__inject(xchembku, True, False))
crystal_wells.append(await self.inject(xchembku, False, False))
crystal_wells.append(await self.inject(xchembku, True, True))
crystal_wells.append(await self.inject(xchembku, True, False))
crystal_wells.append(await self.inject(xchembku, True, True))
crystal_wells.append(await self.inject(xchembku, True, True))
crystal_wells.append(await self.inject(xchembku, True, False))

await self.__request_all(crystal_wells)

Expand Down Expand Up @@ -200,46 +181,3 @@ async def __request_all(self, crystal_wells):
columns = row.find_all(class_="T_filename")
assert len(columns) == 1
assert columns[0].get_text() == Path(crystal_wells[5].filename).stem

# ----------------------------------------------------------------------------------------

async def __inject(self, xchembku, autolocation: bool, droplocation: bool):
""" """
if not hasattr(self, "injected_count"):
self.injected_count = 0

filename = "/tmp/aaaa_%03d_1.jpg" % (self.injected_count)

# Write well record.
m = CrystalWellModel(
position="01A_1",
filename=filename,
crystal_plate_uuid=self.__crystal_plate_uuid,
)

await xchembku.upsert_crystal_wells([m])

if autolocation:
# Add a crystal well autolocation.
t = CrystalWellAutolocationModel(
crystal_well_uuid=m.uuid,
number_of_crystals=self.injected_count,
auto_target_x=self.injected_count * 10 + 1,
auto_target_y=self.injected_count * 10 + 2,
)

await xchembku.originate_crystal_well_autolocations([t])

if droplocation:
# Add a crystal well droplocation.
t = CrystalWellDroplocationModel(
crystal_well_uuid=m.uuid,
confirmed_target_x=self.injected_count * 10 + 3,
confirmed_target_y=self.injected_count * 10 + 4,
)

await xchembku.originate_crystal_well_droplocations([t])

self.injected_count += 1

return m

0 comments on commit 18a8743

Please sign in to comment.