Skills › Scientific Agent Skills › opentrons-integration › runtime_parameters_template.py
runtime_parameters_template.py
111 lines · skills/opentrons-integration/scripts/runtime_parameters_template.py at 5f2bc03
1"""Flex runtime-parameter template with simulation-safe defaults.
3The operator can choose sample count, transfer volume, and dry-run mode in the
4Opentrons App without editing source code. Validate the full allowed parameter
5space and volume budget before adapting this template to an assay.
6The dry_run parameter only shortens a delay: liquid handling still occurs.
7"""
9from opentrons import protocol_api
11metadata = {
12 "protocolName": "Flex Runtime Parameters Template",
13 "author": "Customize before use",
14 "description": "Distribute buffer using operator-selected safe parameters.",
15}
17requirements = {
18 "robotType": "Flex",
19 "apiLevel": "2.29",
20}
23def add_parameters(parameters: protocol_api.ParameterContext) -> None:
24 """Define values that the operator may change during run setup."""
25 parameters.add_int(
26 variable_name="sample_count",
27 display_name="Sample count",
28 description="Number of destination wells to fill.",
29 default=8,
30 minimum=1,
31 maximum=12,
32 )
33 parameters.add_float(
34 variable_name="transfer_volume",
35 display_name="Transfer volume",
36 description="Buffer volume delivered to each well.",
37 default=50.0,
38 minimum=10.0,
39 maximum=100.0,
40 unit="µL",
41 )
42 parameters.add_bool(
43 variable_name="dry_run",
44 display_name="Dry run",
45 description="Shorten incubation only; liquid handling still occurs.",
46 default=True,
47 )
50def run(protocol: protocol_api.ProtocolContext) -> None:
51 """Distribute buffer according to validated runtime values."""
52 sample_count = protocol.params.sample_count
53 transfer_volume_ul = protocol.params.transfer_volume
54 dry_run = protocol.params.dry_run
56 tips = protocol.load_labware(
57 "opentrons_flex_96_tiprack_200ul",
58 "D1",
59 label="200 µL Tips",
60 )
61 reservoir = protocol.load_labware(
62 "nest_12_reservoir_15ml",
63 "D2",
64 label="Buffer Reservoir",
65 )
66 plate = protocol.load_labware(
67 "nest_96_wellplate_200ul_flat",
68 "C2",
69 label="Destination Plate",
70 )
71 protocol.load_trash_bin("A3")
72 pipette = protocol.load_instrument(
73 "flex_1channel_1000",
74 "left",
75 tip_racks=[tips],
76 )
78 buffer = protocol.define_liquid(
79 name="Buffer",
80 description="Example distribution buffer",
81 display_color="#1F77B4",
82 )
83 reservoir.load_liquid(
84 wells=["A1"],
85 volume=2_000,
86 liquid=buffer,
87 )
88 destinations = plate.wells()[:sample_count]
89 plate.load_empty(wells=destinations)
91 protocol.comment(
92 f"Filling {sample_count} wells with {transfer_volume_ul:.1f} µL each."
93 )
95 with protocol.group_steps(
96 name="Distribute Buffer",
97 description="Fill the selected number of destination wells.",
98 ):
99 pipette.distribute(
100 volume=transfer_volume_ul,
101 source=reservoir["A1"],
102 dest=destinations,
103 new_tip="once",
104 disposal_volume=20,
105 )
107 protocol.delay(
108 seconds=1 if dry_run else 60,
109 msg="Example incubation; replace with an assay-specific duration.",
110 )
111 protocol.comment("Parameterized distribution complete.")