Opentrons Flex Skeleton/Template Protocol File

Hello everyone, I just wanted to share a skeleton/template .py file that I made here for quick unit tests etc in case it’s helpful. It’s been really convenient as opposed to building a protocol file from scratch every time. And it’s also a good starting point to hand to a LLM for vibe coding a protocol. Maybe also helpful to see the overall structure of an Opentrons .py if you’re starting out.

Feedback also welcome!

from opentrons import protocol_api, types
from opentrons.protocol_api import ALL, SINGLE, PARTIAL_COLUMN
import math
import csv
import datetime

# Metadata
metadata = {
    'protocolName': 'Template OT Flex Protocol',
    'author': 'YN',
    'description': 'Template OT Flex Protocol',
    'source': 'YN'
}

# requirements
requirements = {"robotType": "Flex", "apiLevel": "2.27"}

# Global Offsets
Y_OFFSET_96_WELL = types.Point(y=-2.5)
XY_OFFSET_96_D_WELL = types.Point(x=1, y=-1)

# --------------- Opentrons Parameters --------------

def add_parameters(parameters: protocol_api.Parameters):
    """
    Adds user-configurable parameters to the protocol.
    """
# --------------- /Opentrons Parameters --------------

# ----------- Helper Functions -----------


# ----------- /Helper Functions -----------

def run(protocol: protocol_api.ProtocolContext):
    
    # --- Labware Setup ---
    # Modules
    heater_shaker = protocol.load_module(module_name="heaterShakerModuleV1", location="B3")
    #heater_shaker_adapter = heater_shaker.load_adapter("opentrons_96_flat_bottom_adapter")
    trash = protocol.load_waste_chute()

    # Labware
    plate = protocol.load_labware("corning_96_wellplate_360ul_flat", "B1", "Well Plate")

    # Wells
    dpbs = plate.wells_by_name()['A1']
    
    # Liquids
    liquid_dpbs = protocol.define_liquid(
        name="DPBS",
        description="DPBS Wash Buffer",
        display_color="#DAF5FF", # Light Blue
    )

    # Load Liquids
    plate.load_liquid(
        liquid=liquid_dpbs,
        volume=1,
        wells=[dpbs]
        )

    # --- Designated Tip Locations for Re-use ---
    #dpbs_tip_location = tiprack_1000ul_1.wells_by_name()['A12']
    
    #default_aspirate_1000 = p1000_multi.flow_rate.aspirate
    #default_dispense_1000 = p1000_multi.flow_rate.dispense

    # --- /Labware Setup ---

    ###################### PROTOCOL START ######################
    




    protocol.comment("--- Protocol Complete ---")
    heater_shaker.close_labware_latch()
    heater_shaker.deactivate_heater()
    heater_shaker.deactivate_shaker()
2 Likes