Skip to content

Commit

Permalink
abr protocols and liquid set ups
Browse files Browse the repository at this point in the history
  • Loading branch information
rclarke0 committed Nov 7, 2024
1 parent f5f28b6 commit 8ba70e9
Show file tree
Hide file tree
Showing 24 changed files with 3,481 additions and 558 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Flex ZymoBIOMICS Magbead DNA Extraction: Cells."""
import math
from opentrons import types
from typing import List, Union
from typing import List, Dict
from opentrons import protocol_api
from opentrons.protocol_api import Well, InstrumentContext
import numpy as np
Expand Down Expand Up @@ -51,7 +51,7 @@
def add_parameters(parameters: protocol_api.ParameterContext) -> None:
"""Define parameters."""
helpers.create_hs_speed_parameter(parameters)
helpers.create_pipette_mount_parameter(parameters)
helpers.create_single_pipette_mount_parameter(parameters)
helpers.create_dot_bottom_parameter(parameters)


Expand Down Expand Up @@ -100,25 +100,23 @@ def run(ctx: protocol_api.ProtocolContext) -> None:
binding_buffer_vol = bind_vol + bead_vol
ctx.load_trash_bin("A3")
h_s: HeaterShakerContext = ctx.load_module(helpers.hs_str, "D1") # type: ignore[assignment]
h_s_adapter = h_s.load_adapter("opentrons_96_deep_well_adapter")
sample_plate = h_s_adapter.load_labware(deepwell_type, "Samples")
labware_name = "Samples"
sample_plate, h_s_adapter = helpers.load_hs_adapter_and_labware(
deepwell_type, h_s, labware_name
)
h_s.close_labware_latch()

temp: TemperatureModuleContext = ctx.load_module(
helpers.temp_str, "D3"
) # type: ignore[assignment]
temp_block = temp.load_adapter("opentrons_96_well_aluminum_block")
elutionplate = temp_block.load_labware(
"opentrons_96_wellplate_200ul_pcr_full_skirt", "Elution Plate"
elutionplate, temp_adapter = helpers.load_temp_adapter_and_labware(
"armadillo_96_wellplate_200ul_pcr_full_skirt", temp, "Elution Plate"
)
magblock: MagneticBlockContext = ctx.load_module(
helpers.mag_str, "C1"
) # type: ignore[assignment]
waste = (
ctx.load_labware("nest_1_reservoir_195ml", "B3", "Liquid Waste")
.wells()[0]
.top()
)
waste_reservoir = ctx.load_labware("nest_1_reservoir_195ml", "B3", "Liquid Waste")
waste = waste_reservoir.wells()[0].top()
res1 = ctx.load_labware(res_type, "D2", "reagent reservoir 1")
res2 = ctx.load_labware(res_type, "C2", "reagent reservoir 2")
num_cols = math.ceil(num_samples / 8)
Expand All @@ -130,7 +128,9 @@ def run(ctx: protocol_api.ProtocolContext) -> None:
tips = [*tips1000.wells()[num_samples:96], *tips1001.wells(), *tips1002.wells()]
tips_sn = tips1000.wells()[:num_samples]
# load instruments
m1000 = ctx.load_instrument("flex_8channel_1000", mount)
m1000 = ctx.load_instrument(
"flex_8channel_1000", mount, tip_racks=[tips1000, tips1001, tips1002]
)

"""
Here is where you can define the locations of your reagents.
Expand All @@ -148,100 +148,21 @@ def run(ctx: protocol_api.ProtocolContext) -> None:
# Redefine per well for liquid definitions
samps = sample_plate.wells()[: (8 * num_cols)]

colors = helpers.liquid_colors

locations: List[Union[List[Well], Well]] = [
lysis_,
lysis_,
binding_buffer,
binding_buffer,
bind2_res,
wash1,
wash2,
wash3,
elution_solution,
]
vols = [
lysis_vol,
PK_vol,
bead_vol,
bind_vol,
bind2_vol,
wash1_vol,
wash2_vol,
wash3_vol,
elution_vol,
]
liquids = [
"Lysis",
"PK",
"Beads",
"Binding",
"Binding 2",
"Wash 1",
"Wash 2",
"Wash 3",
"Final Elution",
]

# Defining liquids per sample well
samples = ctx.define_liquid(
name="Samples", description="Samples", display_color="#C0C0C0"
liquid_vols_and_wells: Dict[str, List[Dict[str, Well | List[Well] | float]]] = {
"Lysis": [{"well": lysis_, "volume": lysis_vol}],
"PK": [{"well": lysis_, "volume": PK_vol}],
"Beads": [{"well": binding_buffer, "volume": bead_vol}],
"Binding": [{"well": binding_buffer, "volume": bind_vol}],
"Binding 2": [{"well": bind2_res, "volume": bind2_vol}],
"Wash 1": [{"well": wash1_vol, "volume": wash1}],
"Wash 2": [{"well": wash2_vol, "volume": wash2}],
"Wash 3": [{"well": wash3_vol, "volume": wash3}],
"Final Elution": [{"well": elution_solution, "volume": elution_vol}],
"Samples": [{"well": samps, "volume": 0}],
}
flattened_list_of_wells = helpers.find_liquid_height_of_loaded_liquids(
ctx, liquid_vols_and_wells, m1000
)
for i in samps:
i.load_liquid(liquid=samples, volume=0)

delete = len(colors) - len(liquids)

if delete >= 1:
for i_del in range(delete):
colors.pop(-1)

def add_liquid(
liq_type: str, wells: Union[Well, List[Well]], color: str, vol: float
) -> None:
"""Assigns colored liquid to wells based on type and location."""
total_samples = math.ceil(num_samples / 8) * 8

# Calculate extra sample volume based on liquid type
extra_samples = math.ceil(
1500
/ (
lysis_vol
if liq_type == "PK"
else bind_vol
if liq_type == "Beads"
else vol
)
)

# Define liquid
liquid = ctx.define_liquid(
name=liq_type, description=liq_type, display_color=color
)

# Assign liquid to each well
if isinstance(wells, list):
samples_per_well = [sample_max // len(wells)] * (
total_samples // (sample_max // len(wells))
)
remainder = total_samples % (sample_max // len(wells))

if remainder:
samples_per_well.append(remainder)

for sample_count, well in zip(samples_per_well, wells):
well.load_liquid(
liquid=liquid, volume=vol * (sample_count + extra_samples)
)
else:
wells.load_liquid(
liquid=liquid, volume=vol * (total_samples + extra_samples)
)

# Apply function for each liquid configuration
for liq, well, color, vol in zip(liquids, locations, colors, vols):
add_liquid(liq, well, color, vol)

m1000.flow_rate.aspirate = 300
m1000.flow_rate.dispense = 300
Expand Down Expand Up @@ -447,7 +368,7 @@ def bind(vol1: float, vol2: float) -> None:
helpers.set_hs_speed(ctx, h_s, heater_shaker_speed * 0.9, bind_time_1, True)

# Transfer from H-S plate to Magdeck plate
helpers.move_labware_from_hs_to_mag_block(ctx, sample_plate, h_s, magblock)
helpers.move_labware_from_hs_to_destination(ctx, sample_plate, h_s, magblock)

for bindi in np.arange(
settling_time + 1, 0, -0.5
Expand Down Expand Up @@ -494,7 +415,7 @@ def bind(vol1: float, vol2: float) -> None:
helpers.set_hs_speed(ctx, h_s, heater_shaker_speed, bind_time_2, True)

# Transfer from H-S plate to Magdeck plate
helpers.move_labware_from_hs_to_mag_block(ctx, sample_plate, h_s, magblock)
helpers.move_labware_from_hs_to_destination(ctx, sample_plate, h_s, magblock)

for bindi in np.arange(
settling_time + 1, 0, -0.5
Expand Down Expand Up @@ -550,7 +471,7 @@ def wash(vol: float, source: List[Well]) -> None:
m1000.drop_tip() if TIP_TRASH else m1000.return_tip()
helpers.set_hs_speed(ctx, h_s, heater_shaker_speed * 0.9, wash_time, True)

helpers.move_labware_from_hs_to_mag_block(ctx, sample_plate, h_s, magblock)
helpers.move_labware_from_hs_to_destination(ctx, sample_plate, h_s, magblock)

for washi in np.arange(
settling_time, 0, -0.5
Expand Down Expand Up @@ -578,7 +499,7 @@ def elute(vol: float) -> None:
helpers.set_hs_speed(ctx, h_s, heater_shaker_speed * 0.9, wash_time, True)

# Transfer back to magnet
helpers.move_labware_from_hs_to_mag_block(ctx, sample_plate, h_s, magblock)
helpers.move_labware_from_hs_to_destination(ctx, sample_plate, h_s, magblock)

for elutei in np.arange(settling_time, 0, -0.5):
ctx.delay(
Expand Down Expand Up @@ -616,3 +537,5 @@ def elute(vol: float) -> None:
)
elute(elution_vol)
h_s.deactivate_heater()
flattened_list_of_wells.extend([waste_reservoir["A1"], elutionplate["A1"]])
helpers.find_liquid_height_of_all_wells(ctx, m1000, flattened_list_of_wells)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
MagneticBlockContext,
)
from abr_testing.protocols import helpers
from typing import List, Union
from typing import List, Dict, Union

metadata = {
"protocolName": "Immunoprecipitation by Dynabeads - (Reagents in 15 mL tubes)",
Expand All @@ -23,7 +23,7 @@
def add_parameters(parameters: ParameterContext) -> None:
"""Define parameters."""
helpers.create_hs_speed_parameter(parameters)
helpers.create_pipette_mount_parameter(parameters)
helpers.create_two_pipette_mount_parameters(parameters)
helpers.create_dot_bottom_parameter(parameters)


Expand Down Expand Up @@ -53,6 +53,8 @@ def run(ctx: ProtocolContext) -> None:
# defining variables inside def run
heater_shaker_speed = ctx.params.heater_shaker_speed # type: ignore[attr-defined]
ASP_HEIGHT = ctx.params.dot_bottom # type: ignore[attr-defined]
single_channel_mount = ctx.params.pipette_mount_1 # type: ignore[attr-defined]
eight_channel_mount = ctx.params.pipette_mount_2 # type: ignore[attr-defined]
MIX_SPEED = heater_shaker_speed
MIX_SEC = 10

Expand Down Expand Up @@ -82,20 +84,23 @@ def run(ctx: ProtocolContext) -> None:
"opentrons_flex_96_tiprack_1000ul", "C2", "reused tips"
)
tips_reused_loc = tips_reused.wells()[:95]
p1000 = ctx.load_instrument("flex_8channel_1000", "right", tip_racks=[tips])
p1000_single = ctx.load_instrument("flex_1channel_1000", "left", tip_racks=[tips])
p1000 = ctx.load_instrument(
"flex_8channel_1000", eight_channel_mount, tip_racks=[tips]
)
p1000_single = ctx.load_instrument(
"flex_1channel_1000", single_channel_mount, tip_racks=[tips]
)
h_s: HeaterShakerContext = ctx.load_module(helpers.hs_str, "D1") # type: ignore[assignment]
h_s_adapter = h_s.load_adapter("opentrons_96_deep_well_adapter")
working_plate = h_s_adapter.load_labware(
"nest_96_wellplate_2ml_deep", "working plate"
working_plate, h_s_adapter = helpers.load_hs_adapter_and_labware(
"nest_96_wellplate_2ml_deep", h_s, "Working Plate"
)

if READY_FOR_SDSPAGE == 0:
temp: TemperatureModuleContext = ctx.load_module(
helpers.temp_str, "D3"
) # type: ignore[assignment]
final_plate = temp.load_labware(
"opentrons_96_deep_well_adapter_nest_wellplate_2ml_deep", "final plate"
final_plate, temp_adapter = helpers.load_temp_adapter_and_labware(
"nest_96_wellplate_2ml_deep", temp, "Final Plate"
)
mag: MagneticBlockContext = ctx.load_module(helpers.mag_str, "C1") # type: ignore[assignment]

Expand All @@ -110,6 +115,19 @@ def run(ctx: ProtocolContext) -> None:
working_wells = working_plate.wells()[: NUM_COL * 8] # 6
if READY_FOR_SDSPAGE == 0:
final_cols = final_plate.rows()[0][:NUM_COL]
# Define Liquids
liquid_vols_and_wells: Dict[
str, List[Dict[str, Union[Well, List[Well], float]]]
] = {
"Beads": [{"well": beads, "volume": 4900}],
"AB": [{"well": ab, "volume": 4900}],
"Elution": [{"well": elu, "volume": 4900}],
"Wash": [{"well": wash, "volume": 750}],
"Samples": [{"well": samples, "volume": 250}],
}
flattened_wells = helpers.find_liquid_height_of_loaded_liquids(
ctx, liquid_vols_and_wells, p1000_single
)

def transfer_plate_to_plate(
vol1: float, start: List[Well], end: List[Well], liquid: int
Expand Down Expand Up @@ -197,7 +215,7 @@ def discard(vol3: float, start: List[Well]) -> None:
h_s.close_labware_latch()
transfer_well_to_plate(BEADS_VOL, beads, working_wells, 2)

helpers.move_labware_from_hs_to_mag_block(ctx, working_plate, h_s, mag)
helpers.move_labware_from_hs_to_destination(ctx, working_plate, h_s, mag)

ctx.delay(minutes=MAG_DELAY_MIN)
discard(BEADS_VOL * 1.1, working_cols)
Expand All @@ -214,7 +232,7 @@ def discard(vol3: float, start: List[Well]) -> None:
ctx.delay(seconds=INCUBATION_MIN * 60)
h_s.deactivate_shaker()

helpers.move_labware_from_hs_to_mag_block(ctx, working_plate, h_s, mag)
helpers.move_labware_from_hs_to_destination(ctx, working_plate, h_s, mag)

ctx.delay(minutes=MAG_DELAY_MIN)
vol_total = SAMPLE_VOL + AB_VOL
Expand All @@ -226,7 +244,7 @@ def discard(vol3: float, start: List[Well]) -> None:

transfer_well_to_plate(WASH_VOL, wash, working_cols, 5)
helpers.set_hs_speed(ctx, h_s, MIX_SPEED, MIX_SEC / 60, True)
helpers.move_labware_from_hs_to_mag_block(ctx, working_plate, h_s, mag)
helpers.move_labware_from_hs_to_destination(ctx, working_plate, h_s, mag)
ctx.delay(minutes=MAG_DELAY_MIN)
discard(WASH_VOL * 1.1, working_cols)

Expand All @@ -246,7 +264,9 @@ def discard(vol3: float, start: List[Well]) -> None:
helpers.set_hs_speed(ctx, h_s, MIX_SPEED, (MIX_SEC / 60) + 2, True)

temp.set_temperature(4)
helpers.move_labware_from_hs_to_mag_block(ctx, working_plate, h_s, mag)
helpers.move_labware_from_hs_to_destination(ctx, working_plate, h_s, mag)
ctx.delay(minutes=MAG_DELAY_MIN)
transfer_plate_to_plate(ELUTION_VOL * 1.1, working_cols, final_cols, 6)
temp.deactivate()
flattened_wells.append(waste)
helpers.find_liquid_height_of_all_wells(ctx, p1000_single, flattened_wells)
Loading

0 comments on commit 8ba70e9

Please sign in to comment.