Skip to content

Instantly share code, notes, and snippets.

@ecormany
Created May 1, 2024 21:46
Show Gist options
  • Save ecormany/9f4d871851ec4baceb9fae177663dd00 to your computer and use it in GitHub Desktop.
Save ecormany/9f4d871851ec4baceb9fae177663dd00 to your computer and use it in GitHub Desktop.
Protocol for testing RTP use cases
from opentrons import protocol_api
requirements = {"robotType": "Flex", "apiLevel": "2.18"}
def add_parameters(parameters):
parameters.add_bool(
variable_name="dry_run",
display_name="Dry Run",
description=(
"Skip delays,"
" shorten mix steps,"
" and return tips to their racks."
),
default=False
)
def run(protocol: protocol_api.ProtocolContext):
# loads not included in snippets
# load tip rack in deck slot D3
tips_1 = protocol.load_labware(
load_name="opentrons_flex_96_tiprack_1000ul", location="C3"
)
tips_2 = protocol.load_labware(
load_name="opentrons_flex_96_tiprack_1000ul", location="C4"
)
# load well plate in deck slot D2
plate = protocol.load_labware(
load_name="corning_96_wellplate_360ul_flat", location="D2"
)
# attach pipette to left mount
pipette = protocol.load_instrument(
instrument_name="flex_1channel_1000",
mount="left",
tip_racks=[tips_1, tips_2]
)
tc_mod = protocol.load_module("thermocyclerModuleV2")
tc_mod.open_lid()
# delay
if protocol.params.dry_run == False:
protocol.delay(minutes=5)
# Thermocycler
protocol.move_labware(labware=plate, new_location=tc_mod, use_gripper=True)
if protocol.params.dry_run == False:
tc_mod.set_block_temperature(4)
tc_mod.set_lid_temperature(100)
tc_mod.close_lid()
pcr_profile = [
{"temperature": 68, "hold_time_seconds": 180},
{"temperature": 98, "hold_time_seconds": 180},
]
if protocol.params.dry_run == False:
tc_mod.execute_profile(
steps=pcr_profile, repetitions=1, block_max_volume=50
)
tc_mod.open_lid()
chute = protocol.load_waste_chute()
# pick up tip - not in snippets!
pipette.pick_up_tip()
# mixing
if protocol.params.dry_run == True:
mix_reps = 1
else:
mix_reps = 10
pipette.mix(repetitions=mix_reps, volume=50, location=plate["A1"].bottom())
# reverse mixing
if protocol.params.dry_run == False:
mix_reps = 10
else:
mix_reps = 1
# return tips
if protocol.params.dry_run == True:
pipette.return_tip()
else:
pipette.drop_tip()
# return or drop
def return_or_drop(pipette):
if protocol.params.dry_run == True:
pipette.return_tip()
else:
pipette.drop_tip()
pipette.pick_up_tip()
return_or_drop(pipette)
# reset tips
if protocol.params.dry_run == True:
pipette.reset_tipracks()
else:
protocol.move_labware(
labware=tips_1, new_location=chute, use_gripper=True
)
protocol.move_labware(
labware=tips_2, new_location="C3", use_gripper=True
)
from opentrons import protocol_api
from math import ceil
requirements = {"robotType": "Flex", "apiLevel": "2.18"}
def add_parameters(parameters):
parameters.add_int(
variable_name="sample_count",
display_name="Sample count",
description="Number of input DNA samples",
default=32,
choices=[
{"display_name": "8", "value": 8},
{"display_name": "16", "value": 16},
{"display_name": "24", "value": 24},
{"display_name": "32", "value": 32},
]
)
def run(protocol: protocol_api.ProtocolContext):
# calculate column count from sample count
column_count = protocol.params.sample_count // 8
# calculate number of required tip racks
tip_rack_50_count = ceil((1 + 7 * column_count) / 12)
tip_rack_200_count = ceil((2 + 13 * column_count) / 12)
# assign tip rack locations (maximal case)
tip_rack_50_slots = ["B3", "C3", "B4"]
tip_rack_200_slots = ["A2", "B2", "A3", "A4"]
# create lists of loaded tip racks
# limit to number of needed racks for each type
tip_racks_50 = [
protocol.load_labware(
load_name="opentrons_flex_96_tiprack_50ul",
location=slot
)
for slot in tip_rack_50_slots[:tip_rack_50_count]
]
tip_racks_200 = [
protocol.load_labware(
load_name="opentrons_flex_96_tiprack_200ul",
location=slot
)
for slot in tip_rack_200_slots[:tip_rack_200_count]
]
pipette_50 = protocol.load_instrument(
instrument_name="flex_8channel_50",
mount="right",
tip_racks=tip_racks_50
)
pipette_1000 = protocol.load_instrument(
instrument_name="flex_1channel_1000",
mount="left",
tip_racks=tip_racks_200
)
# chute! not in snippets
chute = protocol.load_waste_chute()
# labware to hold reagents
reservoir = protocol.load_labware(
load_name="nest_12_reservoir_15ml", location="C2"
)
# reagent liquid definitions
ampure_liquid = protocol.define_liquid(
name="AMPure", description="AMPure Beads", display_color="#704848"
)
tagstop_liquid = protocol.define_liquid(
name="TAGSTOP", description="Tagmentation Stop", display_color="#FF0000"
)
twb_liquid = protocol.define_liquid(
name="TWB", description="Tagmentation Wash Buffer", display_color="#FFA000"
)
reservoir["A1"].load_liquid(
liquid=ampure_liquid, volume=180 * column_count * 1.1
)
reservoir["A2"].load_liquid(
liquid=tagstop_liquid, volume=10 * column_count * 1.1
)
reservoir["A4"].load_liquid(
liquid=twb_liquid, volume=900 * column_count * 1.1
)
hs_mod = protocol.load_module(
module_name="heaterShakerModuleV1", location="D1"
)
hs_adapter = hs_mod.load_adapter(name="opentrons_96_pcr_adapter")
sample_plate = hs_adapter.load_labware(
name="opentrons_96_wellplate_200ul_pcr_full_skirt",
label="Sample Plate",
)
# close the latch! not in snippets
hs_mod.close_labware_latch()
# define sample liquid
sample_liquid = protocol.define_liquid(
name="Samples", description=None, display_color="#52AAFF"
)
# load 40 µL in each sample well
for w in range(protocol.params.sample_count):
sample_plate.wells()[w].load_liquid(liquid=sample_liquid, volume=40)
for w in ["A1", "A2", "A3", "A4"][:column_count]:
pipette_50.pick_up_tip()
pipette_50.aspirate(volume=13, location=reservoir["A2"].bottom())
pipette_50.dispense(volume=3, location=reservoir["A2"].bottom())
pipette_50.dispense(volume=10, location=sample_plate[w].bottom())
pipette_50.move_to(location=sample_plate[w].bottom())
pipette_50.mix(repetitions=10, volume=20)
pipette_50.blow_out(location=sample_plate[w].top(z=-2))
pipette_50.drop_tip()
for initial, intermediate in zip(
["A1", "A2", "A3", "A4"][:column_count],
["A5", "A6", "A7", "A8"][:column_count],
):
pipette_50.pick_up_tip()
pipette_50.aspirate(volume=13, location=sample_plate[initial])
pipette_50.dispense(volume=13, location=sample_plate[intermediate])
pipette_50.drop_tip()
# replenish tip rack
if protocol.params.sample_count == 32:
protocol.move_labware(
labware=tip_racks_200[0],
new_location=chute,
use_gripper=True,
)
protocol.move_labware(
labware=tip_racks_200[-1],
new_location="A2",
use_gripper=True,
)
# extra print-debug testing
protocol.comment(str(list(tr.parent for tr in pipette_50.tip_racks)))
protocol.comment(str(list(tr.parent for tr in pipette_1000.tip_racks)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment