BMS.OTProto.get_pipette Example¶
This function can be used to check if a pipette type is currently loaded. If the pipette is loaded, then the opentrons.protocol_api.contexts.InstrumentContext object is returned. If the pipette is not loaded, then None 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.
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()
OTProto.get_pipette() 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 type of pipette which should be checked and returned. Currently, get_pipette supports getting single channel pipettes using the keyword "p20", "p300", and "p1000".
# When no pipette has been loaded, `None` is returned
p20 = OTProto.get_pipette(
Protocol = protocol,
Pipette = "p20"
)
print(p20)
None
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:
pipette = protocol.load_instrument("p20_single_gen2", "left")
p20 = OTProto.get_pipette(
Protocol = protocol,
Pipette = "p20"
)
print(p20)
P20 Single-Channel GEN2 on left mount