From b4bfa2d34bfd1894b81e46aedea92c3a42b989a6 Mon Sep 17 00:00:00 2001 From: rclarke0 Date: Thu, 9 Jan 2025 17:07:26 -0500 Subject: [PATCH] abr12 pcr plate stacker place onto modules --- .../12_KAPA HyperPlus Library Prep.py | 271 +++++------------- abr-testing/abr_testing/protocols/helpers.py | 45 ++- abr-testing/test_debug | 42 +++ 3 files changed, 142 insertions(+), 216 deletions(-) diff --git a/abr-testing/abr_testing/protocols/active_protocols/12_KAPA HyperPlus Library Prep.py b/abr-testing/abr_testing/protocols/active_protocols/12_KAPA HyperPlus Library Prep.py index 5d167131005..e2652b23a2b 100644 --- a/abr-testing/abr_testing/protocols/active_protocols/12_KAPA HyperPlus Library Prep.py +++ b/abr-testing/abr_testing/protocols/active_protocols/12_KAPA HyperPlus Library Prep.py @@ -6,7 +6,6 @@ Well, InstrumentContext, ) - from opentrons import types import math from abr_testing.protocols import helpers @@ -15,7 +14,7 @@ MagneticBlockContext, ThermocyclerContext, ) -from typing import List, Tuple, Dict +from typing import List, Dict, Tuple metadata = { "protocolName": "KAPA HyperPlus Library Preparation", @@ -40,8 +39,8 @@ def add_parameters(parameters: ParameterContext) -> None: default=False, ) helpers.create_disposable_lid_parameter(parameters) - helpers.create_tc_lid_deck_riser_parameter(parameters) helpers.create_two_pipette_mount_parameters(parameters) + helpers.create_tc_lid_deck_riser_parameter(parameters) helpers.create_deactivate_modules_parameter(parameters) parameters.add_int( variable_name="num_samples", @@ -96,6 +95,10 @@ def run(protocol: ProtocolContext) -> None: trash_tips = False num_cols = math.ceil(num_samples / 8) + unused_lids: List[Labware] = [] + # Load TC Lids + if disposable_lid: + unused_lids = helpers.load_disposable_lids(protocol, 5, ["D3"], deck_riser) # Pre-set parameters # sample_vol = 35.0 @@ -122,10 +125,15 @@ def run(protocol: ProtocolContext) -> None: temp_mod: TemperatureModuleContext = protocol.load_module( helpers.temp_str, "B3" ) # type: ignore[assignment] - temp_plate, temp_adapter = helpers.load_temp_adapter_and_labware( - "armadillo_96_wellplate_200ul_pcr_full_skirt", - temp_mod, - "Temp Module Reservoir Plate", + temp_adapter = temp_mod.load_adapter("opentrons_96_well_aluminum_block") + tip_stacker_200 = helpers.load_stacker_module( + protocol, "PS241204SZEVT24", "D4", "opentrons_flex_96_tiprack_200ul" + ) + tip_stacker_50 = helpers.load_stacker_module( + protocol, "PS241204SZEVT26", "A4", "opentrons_flex_96_tiprack_50ul" + ) + tip_stacker_plates = helpers.load_stacker_module( + protocol, "PS241204SZEVT18", "C4", "armadillo_96_wellplate_200ul_pcr_full_skirt" ) if not dry_run: @@ -133,38 +141,36 @@ def run(protocol: ProtocolContext) -> None: tc_mod: ThermocyclerContext = protocol.load_module(helpers.tc_str) # type: ignore[assignment] # Just in case tc_mod.open_lid() + # Unload Armadillo plates + FLP_plate = tip_stacker_plates.unload_and_move_labware(magblock) - FLP_plate = magblock.load_labware( - "armadillo_96_wellplate_200ul_pcr_full_skirt", "FLP Plate" - ) samples_flp = FLP_plate.rows()[0][:num_cols] - - sample_plate = protocol.load_labware( - "armadillo_96_wellplate_200ul_pcr_full_skirt", "D1", "Sample Plate 1" - ) - - sample_plate_2 = protocol.load_labware( - "armadillo_96_wellplate_200ul_pcr_full_skirt", "B2", "Sample Plate 2" - ) + sample_plate = tip_stacker_plates.unload_and_move_labware("D1") + sample_plate_2 = tip_stacker_plates.unload_and_move_labware("B2") + temp_plate = tip_stacker_plates.unload_and_move_labware(temp_adapter) samples_2 = sample_plate_2.rows()[0][:num_cols] samples = sample_plate.rows()[0][:num_cols] reservoir = protocol.load_labware( "nest_96_wellplate_2ml_deep", "C2", "Beads + Buffer + Ethanol" ) - # Load tipracks - tiprack_50_1 = protocol.load_labware("opentrons_flex_96_tiprack_50ul", "A3") - tiprack_50_2 = protocol.load_labware("opentrons_flex_96_tiprack_50ul", "A2") - - tiprack_200_1 = protocol.load_labware("opentrons_flex_96_tiprack_200ul", "C1") - tiprack_200_2 = protocol.load_labware("opentrons_flex_96_tiprack_200ul", "C3") + # Unload tipracks + tiprack_50_locations = ["A2", "A3"] + tiprack_200_locations = ["C1", "C3"] + tipracks_50 = [] + tipracks_200 = [] + + # Unload 50 ul tips + for tip_rack_destination_50 in tiprack_50_locations: + tip_rack_50 = tip_stacker_50.unload_and_move_labware(tip_rack_destination_50) + tipracks_50.append(tip_rack_50) + # Unload 200 ul tips + for tip_rack_destination_200 in tiprack_200_locations: + tip_rack_200 = tip_stacker_200.unload_and_move_labware(tip_rack_destination_200) + tipracks_200.append(tip_rack_200) if trash_tips: protocol.load_waste_chute() - unused_lids: List[Labware] = [] - # Load TC Lids - if disposable_lid: - unused_lids = helpers.load_disposable_lids(protocol, 5, ["C4"], deck_riser) # Import Global Variables global tip50 @@ -176,10 +182,10 @@ def run(protocol: ProtocolContext) -> None: p200 = protocol.load_instrument( "flex_8channel_1000", pipette_1000_mount, - tip_racks=[tiprack_200_1, tiprack_200_2], + tip_racks=tipracks_200, ) p50 = protocol.load_instrument( - "flex_8channel_50", pipette_50_mount, tip_racks=[tiprack_50_1, tiprack_50_2] + "flex_8channel_50", pipette_50_mount, tip_racks=tipracks_50 ) # Load Reagent Locations in Reservoirs @@ -261,22 +267,11 @@ def run_tag_profile( # Move Plate to TC protocol.comment("****Moving Plate to Pre-Warmed TC Module Block****") - print("Moving to TC") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate, - dest=tc_mod, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate, tc_mod, use_gripper=USE_GRIPPER) if disposable_lid: lid_on_plate, unused_lids, used_lids = helpers.use_disposable_lid_with_tc( - protocol, - unused_lids, - used_lids, - sample_plate, - tc_mod, - flex_stacker=True, + protocol, unused_lids, used_lids, sample_plate, tc_mod ) else: tc_mod.close_lid() @@ -287,27 +282,13 @@ def run_tag_profile( if disposable_lid: if len(used_lids) <= 1: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest="D4", - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, "D4", use_gripper=True) else: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest=used_lids[-2], - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, used_lids[-2], use_gripper=True) # #Move Plate to H-S protocol.comment("****Moving Plate off of TC****") - helpers.move_labware_to_destination( - protocol=protocol, labware=sample_plate, dest="D1", use_gripper=USE_GRIPPER - ) + protocol.move_labware(sample_plate, "D1", use_gripper=USE_GRIPPER) return unused_lids, used_lids def run_er_profile( @@ -323,21 +304,11 @@ def run_er_profile( # Move Plate to TC protocol.comment("****Moving Plate to Pre-Warmed TC Module Block****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate, - dest=tc_mod, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate, tc_mod, use_gripper=USE_GRIPPER) if disposable_lid: lid_on_plate, unused_lids, used_lids = helpers.use_disposable_lid_with_tc( - protocol, - unused_lids, - used_lids, - sample_plate, - tc_mod, - flex_stacker=True, + protocol, unused_lids, used_lids, sample_plate, tc_mod ) else: tc_mod.close_lid() @@ -351,27 +322,13 @@ def run_er_profile( if disposable_lid: # move lid if len(used_lids) <= 1: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest="C4", - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, "C4", use_gripper=True) else: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest=used_lids[-2], - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, used_lids[-2], use_gripper=True) # #Move Plate to H-S protocol.comment("****Moving Plate off of TC****") - helpers.move_labware_to_destination( - protocol=protocol, labware=sample_plate, dest="D1", use_gripper=USE_GRIPPER - ) + protocol.move_labware(sample_plate, "D1", use_gripper=USE_GRIPPER) return unused_lids, used_lids def run_ligation_profile( @@ -388,21 +345,11 @@ def run_ligation_profile( # Move Plate to TC protocol.comment("****Moving Plate to Pre-Warmed TC Module Block****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate, - dest=tc_mod, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate, tc_mod, use_gripper=USE_GRIPPER) if disposable_lid: lid_on_plate, unused_lids, used_lids = helpers.use_disposable_lid_with_tc( - protocol, - unused_lids, - used_lids, - sample_plate, - tc_mod, - flex_stacker=True, + protocol, unused_lids, used_lids, sample_plate, tc_mod ) else: tc_mod.close_lid() @@ -417,28 +364,14 @@ def run_ligation_profile( tc_mod.open_lid() if disposable_lid: if len(used_lids) <= 1: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest="C4", - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, "C4", use_gripper=True) else: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest=used_lids[-2], - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, used_lids[-2], use_gripper=True) # #Move Plate to H-S protocol.comment("****Moving Plate off of TC****") - helpers.move_labware_to_destination( - protocol=protocol, labware=sample_plate, dest="D1", use_gripper=USE_GRIPPER - ) + protocol.move_labware(sample_plate, "D1", use_gripper=USE_GRIPPER) return unused_lids, used_lids def run_amplification_profile( @@ -454,23 +387,13 @@ def run_amplification_profile( # Move Plate to TC protocol.comment("****Moving Sample Plate onto TC****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate_2, - dest=tc_mod, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate_2, tc_mod, use_gripper=USE_GRIPPER) if not dry_run: tc_mod.set_lid_temperature(105) if disposable_lid: lid_on_plate, unused_lids, used_lids = helpers.use_disposable_lid_with_tc( - protocol, - unused_lids, - used_lids, - sample_plate_2, - tc_mod, - flex_stacker=True, + protocol, unused_lids, used_lids, sample_plate_2, tc_mod ) else: tc_mod.close_lid() @@ -489,35 +412,16 @@ def run_amplification_profile( tc_mod.open_lid() if disposable_lid: if len(used_lids) <= 1: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest="C4", - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, "C4", use_gripper=True) else: - helpers.move_labware_to_destination( - protocol=protocol, - labware=lid_on_plate, - dest=used_lids[-2], - use_gripper=True, - flex_stacker=True, - ) + protocol.move_labware(lid_on_plate, used_lids[-2], use_gripper=True) # Move Sample Plate to H-S protocol.comment("****Moving Sample Plate back to H-S****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate_2, - dest="D1", - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate_2, "D1", use_gripper=USE_GRIPPER) # get FLP plate out of the way protocol.comment("****Moving FLP Plate back to TC****") - helpers.move_labware_to_destination( - protocol=protocol, labware=FLP_plate, dest=tc_mod, use_gripper=USE_GRIPPER - ) + protocol.move_labware(FLP_plate, tc_mod, use_gripper=USE_GRIPPER) return unused_lids, used_lids def mix_beads( @@ -726,12 +630,7 @@ def lib_cleanup() -> None: # Move FLP plate off magnetic module if it's there if FLP_plate.parent == magblock: protocol.comment("****Moving FLP Plate off Magnetic Module****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=FLP_plate, - dest=tc_mod, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(FLP_plate, tc_mod, use_gripper=USE_GRIPPER) for x, i in enumerate(samples): mix_beads(p200, bead_res, bead_vol_1, 7 if x == 0 else 2, x) @@ -761,12 +660,7 @@ def lib_cleanup() -> None: ) protocol.comment("****Moving Labware to Magnet for Pelleting****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate, - dest=magblock, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate, magblock, use_gripper=USE_GRIPPER) protocol.delay(minutes=4.5, msg="Time for Pelleting") @@ -819,9 +713,7 @@ def lib_cleanup() -> None: # Return Plate to H-S from Magnet protocol.comment("****Moving sample plate off of Magnet****") - helpers.move_labware_to_destination( - protocol=protocol, labware=sample_plate, dest="D1", use_gripper=USE_GRIPPER - ) + protocol.move_labware(sample_plate, "D1", use_gripper=USE_GRIPPER) # Adding RSB and Mixing @@ -856,12 +748,7 @@ def lib_cleanup() -> None: ) protocol.comment("****Move Samples to Magnet for Pelleting****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate, - dest=magblock, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate, magblock, use_gripper=USE_GRIPPER) protocol.delay(minutes=2, msg="Please allow 2 minutes for beads to pellet.") @@ -881,23 +768,14 @@ def lib_cleanup() -> None: # move new sample plate to D1 or heatershaker protocol.comment("****Moving sample plate off of Magnet****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate_2, - dest="D1", - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate_2, "D1", use_gripper=USE_GRIPPER) # Keep Sample PLate 1 to B2 protocol.comment("****Moving Sample_plate_1 Plate off magnet to B2****") - helpers.move_labware_to_destination( - protocol=protocol, labware=sample_plate, dest="B2", use_gripper=USE_GRIPPER - ) + protocol.move_labware(sample_plate, "B2", use_gripper=USE_GRIPPER) protocol.comment("****Moving FLP Plate off TC****") - helpers.move_labware_to_destination( - protocol=protocol, labware=FLP_plate, dest=magblock, use_gripper=USE_GRIPPER - ) + protocol.move_labware(FLP_plate, magblock, use_gripper=USE_GRIPPER) def lib_amplification( unused_lids: List[Labware], used_lids: List[Labware] @@ -972,12 +850,7 @@ def lib_cleanup_2() -> None: ) protocol.comment("****Moving Labware to Magnet for Pelleting****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate_2, - dest=magblock, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate_2, magblock, use_gripper=USE_GRIPPER) protocol.delay(minutes=4.5, msg="Time for Pelleting") @@ -1029,12 +902,7 @@ def lib_cleanup_2() -> None: protocol.delay(minutes=3, msg="Allow 3 minutes for residual ethanol to dry") protocol.comment("****Moving sample plate off of Magnet****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate_2, - dest="D1", - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate_2, "D1", use_gripper=USE_GRIPPER) # Adding RSB and Mixing @@ -1069,12 +937,7 @@ def lib_cleanup_2() -> None: ) protocol.comment("****Move Samples to Magnet for Pelleting****") - helpers.move_labware_to_destination( - protocol=protocol, - labware=sample_plate_2, - dest=magblock, - use_gripper=USE_GRIPPER, - ) + protocol.move_labware(sample_plate_2, magblock, use_gripper=USE_GRIPPER) protocol.delay(minutes=2, msg="Please allow 2 minutes for beads to pellet.") diff --git a/abr-testing/abr_testing/protocols/helpers.py b/abr-testing/abr_testing/protocols/helpers.py index 64862eb930c..3a205822f86 100644 --- a/abr-testing/abr_testing/protocols/helpers.py +++ b/abr-testing/abr_testing/protocols/helpers.py @@ -636,7 +636,7 @@ def move_labware_to_destination( except IndexError: print("OT-2") return - if isinstance(dest, Labware): + elif isinstance(dest, Labware): labware_location = get_parent(dest) # type: ignore if str(labware_location)[1] == "4": protocol.move_labware( @@ -645,13 +645,14 @@ def move_labware_to_destination( use_gripper=use_gripper, drop_offset=offsets, ) - return - protocol.move_labware( - labware=labware, - new_location=dest, - use_gripper=use_gripper, - pick_up_offset=offsets, - ) + else: + protocol.move_labware( + labware=labware, + new_location=dest, + use_gripper=use_gripper, + pick_up_offset=offsets, + ) + print(f"{labware.load_name} was moved to {labware.parent}") def get_parent(labware: Labware) -> Any: @@ -665,12 +666,20 @@ def get_parent(labware: Labware) -> Any: # Stacker Functions # TODO add more stacker functions and incorporate them into protocols -def load_stacker_module(protocol: ProtocolContext, serial_number: str, slot:str, labware_name: str)-> StackerModule: +def load_stacker_module( + protocol: ProtocolContext, serial_number: str, slot: str, labware_name: str +) -> StackerModule: + """Load stacker module.""" hardware = protocol._hw_manager.hardware hardware.cache_instruments() - return StackerModule(serial_number = serial_number, labware_name = "", slot = slot, protocol=protocol) - - + return StackerModule( + serial_number=serial_number, + labware_name=labware_name, + slot=slot, + protocol=protocol, + ) + + def unload_and_move( stacker: StackerModule, new_location: Labware | str, @@ -684,6 +693,18 @@ def move_to_stacker_and_store(stacker: StackerModule, lw: Labware) -> None: stacker.move_and_store_labware(lw=lw) +def move_lid_from_stacker_to_tc_plate( + stacker: StackerModule, + plate_on_thermocycler: Labware, + thermocycler: ThermocyclerContext, +) -> Labware: + """Move lid from stacker to thermocycler plate.""" + thermocycler.open_lid() + lid_on_plate = stacker.unload_and_move_labware(plate_on_thermocycler) + thermocycler.close_lid() + return lid_on_plate + + # CONSTANTS hs_str = "heaterShakerModuleV1" diff --git a/abr-testing/test_debug b/abr-testing/test_debug index e69de29bb2d..49cf77c4fc8 100644 --- a/abr-testing/test_debug +++ b/abr-testing/test_debug @@ -0,0 +1,42 @@ +Exception raised by protocol +Traceback (most recent call last): + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocols\execution\execute_python.py", line 160, in exec_run + exec("run(__context)", new_globs) + File "", line 1, in + File "tc_lid_x_offset_test.py", line 99, in run + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocols\api_support\util.py", line 389, in _check_version_wrapper + return decorated_obj(*args, **kwargs) + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_api\labware.py", line 560, in load_labware + labware_core = self._protocol_core.load_labware( + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_api\core\engine\protocol.py", line 225, in load_labware + load_result = self._engine_client.execute_command_without_recovery( + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_engine\clients\sync_client.py", line 120, in execute_command_without_recovery + return self._transport.execute_command(create_request) + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_engine\clients\transports.py", line 84, in execute_command + raise ProtocolCommandFailedError( +opentrons.protocol_engine.errors.error_occurrence.ProtocolCommandFailedError: Error 4000 GENERAL_ERROR (ProtocolCommandFailedError): PythonException: ValueError: Labware Lid opentrons_tough_pcr_auto_sealing_lid may not be loaded on parent labware Opentrons Flex Deck Riser. + +The above exception was the direct cause of the following exception: + +Traceback (most recent call last): + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_runner\task_queue.py", line 84, in _run + await self._run_func() + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_runner\task_queue.py", line 61, in _do_run + await func(*args, **kwargs) + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_runner\protocol_runner.py", line 254, in run_func + await self._protocol_executor.execute( + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocol_runner\python_protocol_wrappers.py", line 159, in execute + await to_thread.run_sync( + File "C:\Users\Rhyann Clarke\.virtualenvs\abr-testing-6acHInfl\lib\site-packages\anyio\to_thread.py", line 33, in run_sync + return await get_asynclib().run_sync_in_worker_thread( + File "C:\Users\Rhyann Clarke\.virtualenvs\abr-testing-6acHInfl\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread + return await future + File "C:\Users\Rhyann Clarke\.virtualenvs\abr-testing-6acHInfl\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run + result = context.run(func, *args) + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocols\execution\execute.py", line 39, in run_protocol + exec_run( + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocols\execution\execute_python.py", line 169, in exec_run + _raise_pretty_protocol_error(exception=e, filename=filename) + File "c:\users\rhyann clarke\opentrons\api\src\opentrons\protocols\execution\execute_python.py", line 71, in _raise_pretty_protocol_error + raise ExceptionInProtocolError( +opentrons.protocols.execution.errors.ExceptionInProtocolError: ProtocolCommandFailedError [line 99]: Error 4000 GENERAL_ERROR (ProtocolCommandFailedError): PythonException: ValueError: Labware Lid opentrons_tough_pcr_auto_sealing_lid may not be loaded on parent labware Opentrons Flex Deck Riser.