Skip to content

Commit

Permalink
protopiler will recognize flex pipette and tip rack names
Browse files Browse the repository at this point in the history
  • Loading branch information
abestroka committed Nov 12, 2024
1 parent 265d335 commit fc5cc56
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 20 deletions.
3 changes: 1 addition & 2 deletions ot2_driver/protopiler/protopiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def _create_commands(self, payload: Optional[Dict]) -> List[str]:
pipette_mount = self.resource_manager.determine_pipette(
volume, False
)
print(pipette_mount)

if pipette_mount is None:
raise Exception(
f"No pipette available for {block_name} with volume: {volume}"
Expand Down Expand Up @@ -763,7 +763,6 @@ def _create_commands(self, payload: Optional[Dict]) -> List[str]:
pipette_mount = self.resource_manager.determine_pipette(
volume, True
)
print(pipette_mount)
if pipette_mount is None:
raise Exception(
f"No pipette available for {block_name} with volume: {volume}"
Expand Down
64 changes: 46 additions & 18 deletions ot2_driver/protopiler/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ def get_next_tip(self, pipette_name: str, tip_num: int) -> str:
for loc in valid_tiprack_locations:
tiprack_name = self.location_to_labware[loc]
# dependent on opentrons naming scheme
capacity = int(tiprack_name.split("_")[1])
if 'flex' in tiprack_name:
capacity = int(tiprack_name.split("_")[2])
else:
capacity = int(tiprack_name.split("_")[1])
# just in case someone manually messed with the json...
if self.resources[loc]["used"] >= capacity:
# data sanitization
Expand Down Expand Up @@ -391,7 +394,10 @@ def update_tip_count(self, loc, well, tip_num) -> None:
"""
tiprack_name = self.location_to_labware[loc]
# dependent on opentrons naming scheme
capacity = int(tiprack_name.split("_")[1])
if 'flex' in tiprack_name:
capacity = int(tiprack_name.split("_")[2])
else:
capacity = int(tiprack_name.split("_")[1])

if self.resources[loc]["used"] >= capacity:
raise Exception("ERROR no more available tips")
Expand Down Expand Up @@ -485,22 +491,44 @@ def find_valid_tipracks(self, pipette_name: str) -> List[str]:
A list of string integers representing the location of the valid tipracks on the deck `['1', '2', ... ]`
"""
pip_volume_pattern = re.compile(r"p\d{2,}")
rack_volume_pattern = re.compile(r"\d{2,}ul$")
# find suitable tipracks
pip_volume = int(
pip_volume_pattern.search(pipette_name).group().replace("p", "")
)
valid_tipracks = []
for labware_name, locations in self.labware_to_location.items():
matches = rack_volume_pattern.search(labware_name)
if matches is not None:
vol = int(matches.group().replace("ul", ""))
if vol == pip_volume:
for location in locations:
valid_tipracks.append(str(location))

return valid_tipracks
if 'flex' in pipette_name:
flex_volume_pattern = re.compile(r"(\d+)(?:ul)?$")
pip_volume = int(
flex_volume_pattern.search(pipette_name).group()
)
valid_tipracks = []
for labware_name, locations in self.labware_to_location.items():
matches = flex_volume_pattern.search(labware_name)
if matches is not None:
vol = int(matches.group().replace("ul", ""))
if vol == pip_volume: #TODO
for location in locations:
valid_tipracks.append(str(location))
elif vol == 200 and pip_volume == 1000:
for location in locations:
valid_tipracks.append(str(location))

return valid_tipracks


else:
pip_volume_pattern = re.compile(r"p\d{2,}")
rack_volume_pattern = re.compile(r"\d{2,}ul$")
# find suitable tipracks
pip_volume = int(
pip_volume_pattern.search(pipette_name).group().replace("p", "")
)
# print("PIP_VOLUME", pip_volume)
valid_tipracks = []
for labware_name, locations in self.labware_to_location.items():
matches = rack_volume_pattern.search(labware_name)
if matches is not None:
vol = int(matches.group().replace("ul", ""))
if vol == pip_volume:
for location in locations:
valid_tipracks.append(str(location))

return valid_tipracks

def determine_pipette(self, target_volume: int, is_multi: bool) -> str:
"""Determines which pipette to use for a given volume
Expand Down
29 changes: 29 additions & 0 deletions ot2_driver/protopiler/test_configs/flex_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
equipment:
- name: nest_96_wellplate_2ml_deep
location: "1"
alias: plate
offset: [0, 1.7, 3.9]
- name: opentrons_flex_96_tiprack_200ul
location: "9"
offset: [0.5, 0.9, -0.3]
- name: flex_1channel_1000
mount: right

commands:
- name: test
command: transfer
source: 1:A1
aspirate_clearance: 2
destination: 1:A4
dispense_clearance: 2
volume: [10, 10, 10]
mix_cycles: 0
mix_volume: 0
drop_tip: [false, false, true]

metadata:
protocolName: Flex test
author: Abe astroka@anl.gov
description: testing flex protocol generation
apiLevel: "2.12"

0 comments on commit fc5cc56

Please sign in to comment.