opentrons
Expert guidance for Opentrons Python API v2 - automated liquid handling, protocol development, labware management, and hardware module integration for OT-2 and Flex robots
jkitchin · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add jkitchin/knowhow --skill opentrons技能说明
name: opentrons description: Expert guidance for Opentrons Python API v2 - automated liquid handling, protocol development, labware management, and hardware module integration for OT-2 and Flex robots allowed-tools: ["*"]
Opentrons Python API v2
Overview
The Opentrons Python API v2 enables laboratory automation through Python protocols that control liquid handling robots (OT-2 and Flex). Write protocols that automate pipetting, temperature control, magnetic separation, plate reading, and complex multi-step workflows with reproducible precision.
Core value: Transform manual, error-prone pipetting workflows into automated, reproducible protocols. A 100-line protocol can replace hours of manual work with precise, documented liquid handling.
When to Use
Use the Opentrons skill when:
- Writing automated liquid handling protocols
- Setting up serial dilutions, plate replication, or reagent distribution
- Integrating temperature control, magnetic separation, or plate reading into workflows
- Adapting OT-2 protocols for Opentrons Flex
- Troubleshooting protocol execution or hardware integration
- Optimizing pipetting parameters (flow rates, tip positions, mixing)
Specialized subskills available:
heater-shaker- Temperature control with orbital mixingabsorbance-reader- Microplate spectrophotometrygripper- Automated labware movement (Flex only)thermocycler- PCR thermal cyclingtemperature-module- Precise heating/cooling (4-95°C)magnetic-block- Magnetic bead separation (Flex only)
Don't use when:
- Working with non-Opentrons liquid handlers
- Writing general Python code unrelated to lab automation
- You need detailed module-specific guidance (use the specialized subskills)
Robot Platforms
Opentrons Flex
Modern platform with advanced capabilities:
- Gripper for automated labware movement
- 96-channel pipetting
- Coordinate-based deck slots (A1-D3)
- Larger working volume and deck space
- Trash bin requires explicit loading (API 2.16+)
- Staging area slots in column 4
OT-2
Established platform:
- Numeric deck slots (1-12)
- Fixed trash in slot 12
- 1-channel and 8-channel pipettes
- Proven reliability for standard protocols
Both platforms use identical API syntax with platform-specific parameters.
Protocol Structure
Every Opentrons protocol follows this framework:
from opentrons import protocol_api
# 1. Metadata - Protocol identification
metadata = {
'protocolName': 'My Protocol',
'author': 'Name <email@example.com>',
'description': 'Brief description of what this protocol does',
'apiLevel': '2.19'
}
# 2. Requirements - Robot specification (Flex)
requirements = {"robotType": "Flex", "apiLevel": "2.19"}
# 3. Main function - Setup and commands
def run(protocol: protocol_api.ProtocolContext):
# Setup: Load labware, pipettes, modules
tips = protocol.load_labware("opentrons_flex_96_tiprack_1000ul", "A1")
plate = protocol.load_labware("corning_96_wellplate_360ul_flat", "B1")
pipette = protocol.load_instrument("flex_1channel_1000", "left", tip_racks=[tips])
# Commands: Sequential robot instructions
pipette.pick_up_tip()
pipette.aspirate(100, plate["A1"])
pipette.dispense(100, plate["B1"])
pipette.drop_tip()
Key principles:
- Protocols execute completely linearly - follow line-by-line to understand robot actions
- Use descriptive variable names that mirror lab terminology
- Add comments to document workflow steps
- Group related operations logically
Core API Components
1. Loading Equipment
Labware - Plates, tubes, reservoirs:
# Load standard labware from registry
plate = protocol.load_labware("corning_96_wellplate_360ul_flat", "B1")
tips = protocol.load_labware("opentrons_flex_96_tiprack_1000ul", "A1")
# Load custom labware (JSON definition required)
custom = protocol.load_labware("custom_24_tuberack_1500ul", "C1")
Pipettes - Single, 8-channel, or 96-channel:
# Flex pipettes
left_pip = protocol.load_instrument("flex_1channel_1000", "left", tip_racks=[tips])
right_pip = protocol.load_instrument("flex_8channel_1000", "right", tip_racks=[tips])
# OT-2 pipettes
p300 = protocol.load_instrument("p300_single_gen2", "left", tip_racks=[tips])
Modules - Temperature, magnetic, thermocycler:
# Load module in specific deck slot
temp_mod = protocol.load_module("temperature module gen2", "D1")
# Load labware on module
temp_plate = temp_mod.load_labware("opentrons_96_aluminumblock_generic_pcr_strip_200ul")
Trash bin (Flex, API 2.16+):
trash = protocol.load_trash_bin("A3")
2. Accessing Wells
Individual wells:
plate["A1"] # Single well by name
plate.wells()[0] # First well by index
plate.wells_by_name()["A1"] # Dictionary access
Well ranges and groups:
plate.wells()[:8] # First row (A1-H1)
plate.rows()[0] # All wells in row A
plate.columns()[0] # All wells in column 1
plate.wells("A1", "H12") # Range from A1 to H12
8-channel pipetting patterns:
# Pipette to entire column with 8-channel
pipette.transfer(100, reservoir["A1"], plate.columns()[0])
3. Liquid Handling Commands
Basic operations:
pipette.pick_up_tip()
pipette.aspirate(volume=100, location=plate["A1"], rate=1.0)
pipette.dispense(volume=100, location=plate["B1"], rate=1.0)
pipette.blow_out(location=plate["B1"])
pipette.mix(repetitions=3, volume=50, location=plate["B1"])
pipette.drop_tip() # or pipette.return_tip()
Complex transfers:
# Single source to multiple destinations
pipette.distribute(
volume=50,
source=reservoir["A1"],
dest=[plate.wells()[i] for i in range(8)],
new_tip="once"
)
# Multiple sources to single destination (pooling)
pipette.consolidate(
volume=20,
source=plate.rows()[0],
dest=reservoir["A2"],
new_tip="always"
)
# One-to-one tra
阅读完整来源 ↗