BMS.OTProto.get_locations Example¶
The Opetrons API uses opentrons.protocol_api.labware.Well objects to capture specific locations on the Opentrons deck. These tend to refer to wells within some piece of labware. The OTProto.get_locations() function is intended to convert a well ID (e.g. "A4"), a well range (e.g. "B2:C6"), or a list of wells (e.g. ["A1", "B6", "C7"]) into a location, or list of locations, the Opentrons can understand.
from BiomationScripter import OTProto
# This code is used to create an opentrons protocol object required for this function
from opentrons import simulate as OT2 # This line simulates the protocol
# Get the correct api version
protocol = OT2.get_protocol_api('2.11')
# Home the pipetting head
protocol.home()
Converting a Well IDs to Locations¶
The OTProto.get_locations function has two mandatory arguments: Labware and Wells. The Labware argument must be supplied with an opentrons.protocol_api.labware.Labware object.
A labware object can be generated using the following BMS functions:
Other methods of generating an opentrons.protocol_api.labware.Labware object can be found in the Opentrons API documentation
labware_type = "opentrons_24_aluminumblock_nest_1.5ml_snapcap"
Labware1 = OTProto.load_labware(
parent = protocol,
labware_api_name = labware_type
)
There are three formats the Well argument can take:
# Using a single well ID
Well = "B2"
OTProto.get_locations(
Labware = Labware1,
Wells = Well
)
B2 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1
# Using a list of wells
Wells = ["A1", "B4", "D6"]
OTProto.get_locations(
Labware = Labware1,
Wells = Wells
)
[A1 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, D6 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1]
# Using a well range
Well_Range = "A4:B5"
OTProto.get_locations(
Labware = Labware1,
Wells = Well_Range
)
[A4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, A5 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, A6 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B1 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B2 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B3 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B5 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1]
When a well range is specified, two more arguments can be given: Direction and Box.
The Direction argument determines whether wells are added horizontally (A1, A2, A3, A4...), or vertically (A1, B1, C1...). The default value for this argument is "Horizontal"
# Using a well range vertically
Well_Range = "A4:B5"
OTProto.get_locations(
Labware = Labware1,
Wells = Well_Range,
Direction = "Vertical"
)
[A4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, C4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, D4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, A5 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B5 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1]
The Box argument is used to specify whether the well range should form a 'box' shape, or if wells should be counted to the end of the row/column before moving on. The default value for this is False
# Using a 'boxed' well range
Well_Range = "A4:B5"
OTProto.get_locations(
Labware = Labware1,
Wells = Well_Range,
Direction = "Vertical",
Box = True
)
[A4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B4 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, A5 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1, B5 of Opentrons 24 Well Aluminum Block with NEST 1.5 mL Snapcap on 1]