Skip to content

Commit 9b25f9e

Browse files
authored
Opentrons plate holder (#775)
1 parent 9e7e382 commit 9b25f9e

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

docs/resources/library/opentrons.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ Unfortunately, most of the other labware (plates) is missing information that is
5353
- `opentrons_96_aluminumblock_generic_pcr_strip_200ul`
5454
- `opentrons_96_aluminumblock_nest_wellplate_100ul`
5555
- `opentrons_96_well_aluminum_block`
56+
57+
58+
## Plate Adapters
59+
60+
- `opentrons_96_deep_well_temp_mod_adapter`
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from pylabrobot.resources.carrier import PlateHolder
2+
from pylabrobot.resources.opentrons.load import load_ot_plate_holder
3+
4+
5+
def opentrons_96_deep_well_temp_mod_adapter(name: str) -> PlateHolder:
6+
z_offset = 5.1
7+
return load_ot_plate_holder(
8+
"opentrons_96_deep_well_temp_mod_adapter", z_offset=z_offset, plr_resource_name=name
9+
)

pylabrobot/resources/opentrons/load.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict, List, cast
66

77
from pylabrobot.resources import Coordinate, Tip, TipRack, TipSpot
8+
from pylabrobot.resources.carrier import PlateHolder
89
from pylabrobot.resources.resource_holder import ResourceHolder
910
from pylabrobot.resources.tube_rack import TubeRack
1011

@@ -26,7 +27,10 @@ def _download_ot_resource_file(ot_name: str, force_download: bool):
2627
The labware definition as a dictionary.
2728
"""
2829
url = f"https://raw.githubusercontent.com/Opentrons/opentrons/5b51a98ce736b2bb5aff780bf3fdf91941a038fa/shared-data/labware/definitions/2/{ot_name}/1.json"
29-
path = f"/tmp/{ot_name}.json"
30+
if os.path.exists("/tmp"):
31+
path = f"/tmp/{ot_name}.json" # only works with linux/mac systems
32+
else:
33+
path = f"C:/Windows/Temp/{ot_name}.json"
3034
if force_download or not os.path.exists(path):
3135
data = _download_file(url=url, local_path=path)
3236
else:
@@ -147,3 +151,27 @@ def load_ot_tube_rack(
147151
ordered_items=cast(Dict[str, ResourceHolder], ordered_items),
148152
model=data["metadata"]["displayName"],
149153
)
154+
155+
156+
def load_ot_plate_holder(
157+
ot_name: str, plr_resource_name: str, z_offset: float, force_download: bool = False
158+
) -> PlateHolder:
159+
"""Convert an Opentrons adapter definition file to a PyLabRobot PlateHolder resource."""
160+
161+
data = _download_ot_resource_file(ot_name=ot_name, force_download=force_download)
162+
163+
display_category = data["metadata"]["displayCategory"]
164+
if display_category not in {"adapter", "aluminumBlock"}:
165+
raise ValueError("Not a plate adapter definition file.")
166+
167+
location = data["cornerOffsetFromSlot"]
168+
169+
return PlateHolder(
170+
name=plr_resource_name,
171+
size_x=data["dimensions"]["xDimension"],
172+
size_y=data["dimensions"]["yDimension"],
173+
size_z=data["dimensions"]["zDimension"],
174+
child_location=Coordinate(location["x"], location["y"], z_offset),
175+
pedestal_size_z=0,
176+
model=data["metadata"]["displayName"],
177+
)

0 commit comments

Comments
 (0)