BMS.OTProto.select_pipette_by_volume Example¶
This function will select the most appropriate pipette type from those currently loaded to transfer a specified volume. If no suitable pipette type is loaded, an error is raised. If a suitable pipette is identified, the opentrons.protocol_api.contexts.InstrumentContext object is returned.
The opentrons.protocol_api.contexts.InstrumentContext object can be used with native Opentrons methods to transfer liquid etc.. It is also used to assign tipboxes and starting tip positions.
Currently, this function only supports single channel p20, p300, and p1000 pipettes. The most suitable pipette is determined by looking for the smallest (and most accurate) pipette type which has the specified volume within its range, and then works its way up.
For example, 200 uL can be transferred by both the p300 and p100 pipettes. If the p300 pipette is loaded, this will be returned (as it is the smallest of the two loaded pipettes). If the p300 pipette is not loaded, then the p1000 will be returned.
If only the p20 was loaded, this would be returned, as 200 uL could be completed by the p20 in 10 transfer events.
On the other hand, if a volume of 10 uL was specified and only the p300 and p1000 were loaded, then an error would be raised as the minimum volume which can be transferred by the p300 is 20 uL.
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()
C:\Users\bradl\.opentrons\robot_settings.json not found. Loading defaults C:\Users\bradl\.opentrons\deck_calibration.json not found. Loading defaults
Pipettes can be loaded using the native opentrons opentrons.protocol_api.contexts.ProtocolContext.load_instrument function, or the BiomationScripter OTProto.load_pipettes_and_tips function, which calculate the number of tip boxes required and load them, and assign the starting tip at the same time. OTProto templates also have several methods which can load pipettes.
Here, the native Opentrons function is used:
# Two pipettes are loaded: p300 and p1000
p300 = protocol.load_instrument("p300_single_gen2", "left")
p100 = protocol.load_instrument("p1000_single_gen2", "right")
OTProto.select_pipette_by_volume() takes two arguments.
The first argument is the top-level opentrons.protocol_api.contexts.ProtocolContext object. This is either passed to the Opentrons' run() function:
def run(protocol):
# Code Here
Or it is loaded during simulation by
protocol = OT2.get_protocol_api('2.11')
For OTProto templates, it is stored using the self._protocol attribute.
The second argument is the volume, given in microlitres.
OTProto.select_pipette_by_volume(
Protocol = protocol,
Volume = 200
)
<InstrumentContext: p300_single_v2.0 in LEFT>
OTProto.select_pipette_by_volume(
Protocol = protocol,
Volume = 10
)
--------------------------------------------------------------------------- RobotConfigurationError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_29368/3666160515.py in <module> ----> 1 OTProto.select_pipette_by_volume( 2 Protocol = protocol, 3 Volume = 10 4 ) ~\anaconda3\lib\site-packages\BiomationScripter\OTProto\__init__.py in select_pipette_by_volume(Protocol, Volume) 231 return(p20) 232 else: --> 233 raise _BMS.RobotConfigurationError("A suitable pipette is not loaded to transfer {} uL.\n Currently loaded pipettes:\n{}".format(Volume, Protocol._instruments)) 234 235 def set_location_offset_top(Locations, Offset): RobotConfigurationError: A suitable pipette is not loaded to transfer 10 uL. Currently loaded pipettes: {<Mount.LEFT: 1>: <InstrumentContext: p300_single_v2.0 in LEFT>, <Mount.RIGHT: 2>: <InstrumentContext: p1000_single_v2.0 in RIGHT>}
The above resulted in an error as there is no pipette loaded suitable for transferring 10 uL