Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/resources/library/opentrons.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ Unfortunately, most of the other labware (plates) is missing information that is
- `opentrons_96_aluminumblock_generic_pcr_strip_200ul`
- `opentrons_96_aluminumblock_nest_wellplate_100ul`
- `opentrons_96_well_aluminum_block`


## Plate Adapters

- `opentrons_96_deep_well_temp_mod_adapter`
9 changes: 9 additions & 0 deletions pylabrobot/resources/opentrons/adapters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pylabrobot.resources.carrier import PlateHolder
from pylabrobot.resources.opentrons.load import load_ot_plate_holder


def opentrons_96_deep_well_temp_mod_adapter(name: str) -> PlateHolder:
z_offset = 5.1
return load_ot_plate_holder(
"opentrons_96_deep_well_temp_mod_adapter", z_offset=z_offset, plr_resource_name=name
)
30 changes: 29 additions & 1 deletion pylabrobot/resources/opentrons/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Dict, List, cast

from pylabrobot.resources import Coordinate, Tip, TipRack, TipSpot
from pylabrobot.resources.carrier import PlateHolder
from pylabrobot.resources.resource_holder import ResourceHolder
from pylabrobot.resources.tube_rack import TubeRack

Expand All @@ -26,7 +27,10 @@ def _download_ot_resource_file(ot_name: str, force_download: bool):
The labware definition as a dictionary.
"""
url = f"https://raw.githubusercontent.com/Opentrons/opentrons/5b51a98ce736b2bb5aff780bf3fdf91941a038fa/shared-data/labware/definitions/2/{ot_name}/1.json"
path = f"/tmp/{ot_name}.json"
if os.path.exists("/tmp"):
path = f"/tmp/{ot_name}.json" # only works with linux/mac systems
else:
path = f"C:/Windows/Temp/{ot_name}.json"
if force_download or not os.path.exists(path):
data = _download_file(url=url, local_path=path)
else:
Expand Down Expand Up @@ -147,3 +151,27 @@ def load_ot_tube_rack(
ordered_items=cast(Dict[str, ResourceHolder], ordered_items),
model=data["metadata"]["displayName"],
)


def load_ot_plate_holder(
ot_name: str, plr_resource_name: str, z_offset: float, force_download: bool = False
) -> PlateHolder:
"""Convert an Opentrons adapter definition file to a PyLabRobot PlateHolder resource."""

data = _download_ot_resource_file(ot_name=ot_name, force_download=force_download)

display_category = data["metadata"]["displayCategory"]
if display_category not in {"adapter", "aluminumBlock"}:
raise ValueError("Not a plate adapter definition file.")

location = data["cornerOffsetFromSlot"]

return PlateHolder(
name=plr_resource_name,
size_x=data["dimensions"]["xDimension"],
size_y=data["dimensions"]["yDimension"],
size_z=data["dimensions"]["zDimension"],
child_location=Coordinate(location["x"], location["y"], z_offset),
pedestal_size_z=0,
model=data["metadata"]["displayName"],
)