def getEquipment(): equipment={} #DECK: equipment['trash']=containers.load('point', "C1","trash") equipment['p200rack'] = containers.load('tiprack-200ul', 'E2', 'tiprack200') equipment['p1000rack'] = containers.load('tiprack-1000ul', 'A1', 'tiprack1000') equipment['TubMedia']=containers.load('point', "D1","TubMedia") #PIPETTE(S) equipment['p1000'] = instruments.Pipette( name="P1000", axis="b", min_volume=20, max_volume=1000, tip_racks=[equipment['p1000rack']], trash_container=equipment['trash'] ) equipment['p200x8'] = instruments.Pipette( name="p200x8", axis="a", min_volume=20, max_volume=200, trash_container=equipment['trash'], channels=8 ) return(equipment)
def run_custom_protocol( volumes_csv: FileInput = example_csv, pipette_axis: StringSelection('B (left side)', 'A (right side)') = 'B (left side)', pipette_model: StringSelection('p200', 'p100', 'p50', 'p20', 'p10', 'p1000') = 'p200', source_plate_type: StringSelection('96-flat', '384-plate') = '96-flat', destination_plate_type: StringSelection('96-flat', '384-plate') = '96-flat', tip_reuse: StringSelection('new tip each time', 'reuse tip') = 'new tip each time'): pipette_max_vol = int(pipette_model[1:]) pipette = instruments.Pipette(axis='b' if pipette_axis[0] == 'B' else 'a', max_volume=pipette_max_vol, min_volume=pipette_max_vol / 10, tip_racks=tipracks, trash_container=trash) data = [[well, float(vol)] for well, vol in [row.split(',') for row in volumes_csv.strip().split('\n') if row]] source_plate = containers.load(source_plate_type, 'B1') dest_plate = containers.load(destination_plate_type, 'C1') tip_strategy = 'always' if tip_reuse == 'new tip each time' else 'once' for well_idx, (source_well, vol) in enumerate(data): pipette.transfer(vol, source_plate.wells(source_well), dest_plate(well_idx), new_tip=tip_strategy)
def setUp(self): self.robot = Robot.reset_for_tests() myport = self.robot.VIRTUAL_SMOOTHIE_PORT self.robot.connect(port=myport) self.robot.home() self.trash = containers.load('point', 'A1') self.tiprack1 = containers.load('tiprack-10ul', 'B2') self.tiprack2 = containers.load('tiprack-10ul', 'B3') self.plate = containers.load('96-flat', 'A2') self.p200 = instruments.Pipette( trash_container=self.trash, tip_racks=[self.tiprack1, self.tiprack2], max_volume=200, min_volume=10, # These are variable axis="b", channels=1 ) self.p200.reset() self.p200.calibrate_plunger(top=0, bottom=10, blow_out=12, drop_tip=13) self.robot.home(enqueue=False) _, _, starting_z = self.robot._driver.get_head_position()['current']
def setUp(self): Robot.reset_for_tests() self.robot = Robot.get_instance() self.robot.connect() self.trash = containers.load('point', 'A1', 'trash') self.tiprack = containers.load('tiprack-200ul', 'B2', 'p200-rack') self.trough = containers.load('trough-12row', 'B2', 'trough') self.plate = containers.load('96-flat', 'A2', 'magbead') self.p200 = instruments.Pipette( name="p200", trash_container=self.trash, tip_racks=[self.tiprack], min_volume=10, # These are variable axis="b", channels=1) self.p1000 = instruments.Pipette( name="p1000", trash_container=self.trash, tip_racks=[self.tiprack], min_volume=100, # These are variable axis="a", channels=1)
def setUp(self): Robot.reset_for_tests() self.robot = Robot.get_instance() self.robot.connect() self.trash = containers.load('point', 'A1', 'trash') self.tiprack = containers.load('tiprack-200ul', 'B2', 'p200-rack') self.trough = containers.load('trough-12row', 'B2', 'trough') self.plate = containers.load('96-flat', 'A2', 'magbead') self.p200 = instruments.Pipette( name="p200", trash_container=self.trash, tip_racks=[self.tiprack], min_volume=10, # These are variable axis="b", channels=1 ) self.p1000 = instruments.Pipette( name="p1000", trash_container=self.trash, tip_racks=[self.tiprack], min_volume=100, # These are variable axis="a", channels=1 )
def test_serial_dilution(self): plate = containers.load('96-flat', 'B1', 'plate') tiprack = containers.load( 'tiprack-200ul', # container type from library 'A1', # slot on deck 'tiprack' # calibration reference for 1.2 compatibility ) trough = containers.load('trough-12row', 'B1', 'trough') trash = containers.load('point', 'A2', 'trash') p200 = instruments.Pipette( trash_container=trash, tip_racks=[tiprack], max_volume=200, min_volume=10, # These are variable axis="b", channels=1) p200.calibrate_plunger(top=0, bottom=10, blow_out=12, drop_tip=13) for t, col in enumerate(plate.cols): p200.pick_up_tip(tiprack[t]) p200.aspirate(10, trough[t]) p200.dispense(10, col[0]) for well, next_well in zip(col[:-1], col[1:]): p200.aspirate(10, well) p200.dispense(10, next_well) p200.mix(repetitions=3, volume=10, location=next_well) p200.drop_tip(trash)
def stock_solution(amine, solvent): # Deck setup tiprack_1000 = containers.load("tiprack-1000ul-H", "B3") source_trough4row = containers.load("trough-12row", "C2") trash = containers.load("point", "C3") # Pipettes SetUp p1000 = instruments.Pipette( name='eppendorf1000', axis='b', trash_container=trash, tip_racks=[tiprack_1000], max_volume=1000, min_volume=30, channels=1, ) id_header = "CPD ID" solvent = "DMA" stock_sol1 = "stock reagent 1" location_header = "Location_trough" volume_stock_header = "Volume to dispense (uL)" for i, x in enumerate(solvent_df[id_header].tolist()): if x == solvent: solvent_location = solvent_df[location_header].tolist()[i] if x == stock_sol1: stock_sol1_loc = solvent_df[location_header].tolist()[i] stock_sol1_volume = solvent_df[volume_stock_header].tolist()[i] # Using the desired solvent, dilution of reagents 1 and/or 2 to the desired conc, in the big trough p1000.pick_up_tip() p1000.transfer([stock_sol1_volume], source_trough4row.wells(solvent_location), source_trough4row.wells(stock_sol1_loc).top(-5), new_tip='never') p1000.drop_tip() robot.home()
def labware_setup(hardware): from opentrons import containers, instruments tip_racks = \ [containers.load('opentrons-tiprack-300ul', slot, slot) for slot in ['1', '4']] plates = \ [containers.load('96-flat', slot, slot) for slot in ['2', '5']] p50 = instruments.P50_Multi( mount='right', tip_racks=tip_racks) p1000 = instruments.P1000_Single( mount='left', tip_racks=tip_racks) commands = [ { 'location': plates[0][0], 'instrument': p50 }, { 'location': plates[1] }, { 'locations': [plates[0][0], plates[1]], 'instrument': p1000 } ] return (p50, p1000), tip_racks, plates, commands
def labware_setup(): from opentrons import containers, instruments tip_racks = \ [containers.load('tiprack-200ul', slot, slot) for slot in ['1', '4']] plates = \ [containers.load('96-PCR-flat', slot, slot) for slot in ['2', '5']] # TODO(mc, 2018-06-13): use standard pipette factories p100 = instruments.Pipette(name='p100', mount='right', channels=8, tip_racks=tip_racks) p1000 = instruments.Pipette(name='p1000', mount='left', channels=8, tip_racks=tip_racks) commands = [{ 'location': plates[0][0], 'instrument': p100 }, { 'location': plates[1] }, { 'locations': [plates[0][0], plates[1]], 'instrument': p1000 }] return (p100, p1000), tip_racks, plates, commands
def setUp(self): Robot.reset_for_tests() self.trash_box = containers.load('trash-box', 'A1') self.wheaton_vial_rack = containers.load('wheaton_vial_rack', 'A2') self.tube_rack_80well = containers.load('tube-rack-80well', 'A3') self.T75_flask = containers.load('T75-flask', 'B1') self.T25_flask = containers.load('T25-flask', 'B2')
def test_serial_dilution(self): plate = containers.load("96-flat", "B1", "plate") tiprack = containers.load( "tiprack-200ul", # container type from library "A1", # slot on deck "tiprack", # calibration reference for 1.2 compatibility ) trough = containers.load("trough-12row", "B1", "trough") trash = containers.load("point", "A2", "trash") p200 = instruments.Pipette( trash_container=trash, tip_racks=[tiprack], max_volume=200, min_volume=10, # These are variable axis="b", channels=1, ) p200.calibrate_plunger(top=0, bottom=10, blow_out=12, drop_tip=13) for t, col in enumerate(plate.cols): p200.pick_up_tip(tiprack[t]) p200.aspirate(10, trough[t]) p200.dispense(10, col[0]) for well, next_well in zip(col[:-1], col[1:]): p200.aspirate(10, well) p200.dispense(10, next_well) p200.mix(repetitions=3, volume=10, location=next_well) p200.drop_tip(trash)
def stock_solution_main(reaction_conditions): # Deck setup tiprack_1000 = containers.load("tiprack-1000ul-H", "B3") source_trough4row = containers.load("trough-12row", "C2") trash = containers.load("point", "C3") # Pipettes SetUp p1000 = instruments.Pipette( name='eppendorf1000', axis='b', trash_container=trash, tip_racks=[tiprack_1000], max_volume=1000, min_volume=30, channels=1, ) id_header = "reaction" reaction_to_start = "Coupling_standard" solvent_trough_location_header = "main reactant solvent Location" volume_stock_header = "main reactant volume to add - stock (uL)" destination_header = "main reactant location" for index, value in enumerate(reaction_conditions_df[id_header].tolist()): if value == reaction_to_start: solvent_location = reaction_conditions_df[solvent_trough_location_header].tolist()[index] solvent_volume = reaction_conditions_df[volume_stock_header].tolist()[index] destination_location = reaction_conditions_df[destination_header].tolist()[index] p1000.pick_up_tip() p1000.transfer([solvent_volume], source_trough4row.wells(solvent_location), source_trough4row.wells(destination_location).top(-5), new_tip='never') p1000.drop_tip() robot.home()
def test_create_arc(self): p200 = instruments.Pipette(axis='b', name='my-fancy-pancy-pipette') plate = containers.load('96-flat', 'A1') plate2 = containers.load('96-flat', 'B1') self.robot.move_head(x=10, y=10, z=10) p200.calibrate_position((plate, Vector(0, 0, 0))) self.robot.move_head(x=10, y=10, z=100) p200.calibrate_position((plate2, Vector(0, 0, 0))) res = self.robot._create_arc((0, 0, 0), plate[0]) expected = [ {'z': 100}, {'x': 0, 'y': 0}, {'z': 0} ] self.assertEquals(res, expected) res = self.robot._create_arc((0, 0, 0), plate[0]) expected = [ {'z': 20.5 + 5}, {'x': 0, 'y': 0}, {'z': 0} ] self.assertEquals(res, expected)
def setUp(self): self.robot = Robot.reset_for_tests() myport = self.robot.VIRTUAL_SMOOTHIE_PORT self.robot.connect(port=myport) self.robot.home() self.trash = containers.load('point', 'A1') self.tiprack1 = containers.load('tiprack-10ul', 'B2') self.tiprack2 = containers.load('tiprack-10ul', 'B3') self.plate = containers.load('96-flat', 'A2') self.p200 = instruments.Pipette( trash_container=self.trash, tip_racks=[self.tiprack1, self.tiprack2], max_volume=200, min_volume=10, # These are variable axis="b", channels=1) self.p200.reset() self.p200.calibrate_plunger(top=0, bottom=10, blow_out=12, drop_tip=13) self.robot.home(enqueue=False) _, _, starting_z = self.robot._driver.get_head_position()['current']
def test_serializing_configured_robot_with_2_instruments(self): plate = containers.load('96-flat', 'A1') trash = containers.load('point', 'A2') tiprack = containers.load('tiprack-200ul', 'A3') p200 = instruments.Pipette( axis='b', tip_racks=[tiprack], trash_container=trash, max_volume=200 ) p100 = instruments.Pipette( axis='a', channels=8, tip_racks=[tiprack], trash_container=trash, max_volume=100 ) self.make_commands(p200, plate, p100, plate) original_robot_cmds_txt = self.robot.commands() original_robot_cmd_cnts = len(self.robot._commands) robot_as_bytes = dill.dumps(self.robot) self.assertIsInstance(robot_as_bytes, bytes) deserialized_robot = dill.loads(robot_as_bytes) deserialized_robot_cmd_cnts = len(deserialized_robot._commands) # Check commands are unmarshalled self.assertEqual(deserialized_robot_cmd_cnts, original_robot_cmd_cnts) # Check instruments are unmarshalled original_robot_instruments = self.robot.get_instruments() deserialized_robot_instruments = self.robot.get_instruments() self.assertEqual( len(original_robot_instruments), len(deserialized_robot_instruments), ) self.assertEqual( original_robot_instruments[0][0], deserialized_robot_instruments[0][0], ) # Set deserialized robot as the global robot and attempt to # reconstruct the same commands again Singleton._instances[Robot] = deserialized_robot deserialized_robot._commands = [] r2_p200 = deserialized_robot_instruments[0][1] r2_p100 = deserialized_robot_instruments[1][1] self.make_commands(r2_p200, plate, r2_p100, plate) self.assertEqual( original_robot_cmd_cnts, len(deserialized_robot._commands) ) self.assertListEqual( original_robot_cmds_txt, deserialized_robot.commands() )
def containers(): from opentrons import robot from opentrons import containers robot.reset() return { '1': containers.load('96-flat', '1'), '11': containers.load('96-flat', '11') }
def setup(): global header, p50, p300, stock_wells, tube_rack, df df = np.genfromtxt('solutionmaker.csv', delimiter=',', skip_header=1, missing_values='') with open('solutionmaker.csv') as csvfile: reader_object = csv.reader(csvfile) header = [row for i_row, row in enumerate(reader_object) if i_row == 0] (nrows, ncols) = df.shape for n_row in range(nrows): if (df[n_row, :].sum() > 1500): raise ValueError( 'Individual wells will not tolerate addition of this much volume' ) """ The following are constants for instantiation (mm/sec or ul/sec) ----------------------------------------- """ XSPEED = 600 YSPEED = 600 ZSPEED = 125 P300_ASPIRATERATE = 150 P50_ASPIRATE = 25 P50_DISPENSERATE = 100 P300_DISPENSERATE = 600 """ ------------------------------------------ """ # connects robot and sets robot settings robot.home() robot.connect() robot.head_speed(x=XSPEED, y=YSPEED, z=ZSPEED) # sets up labware and the layout of the experiment m300rack_1 = containers.load('tiprack-200ul', '10', share='True') m300rack_2 = containers.load('tiprack-200ul', '11', share='True') stock_wells = [] slot_plate_wells = ['4', '5'] for slot in slot_plate_wells: stock_wells.append(containers.load('plate_6_well', slot, share='True')) stock_wells.append(containers.load('96-flat', '6', share='True')) tube_rack = [] slots_tube_rack = ['1', '2', '3'] for slot in slots_tube_rack: tube_rack.append(containers.load('4x6_Tube_rack', slot, share='True')) # instantiates pipettes p50 = instruments.P50_Single(mount="right", tip_racks=[m300rack_1], aspirate_flow_rate=P50_ASPIRATE, dispense_flow_rate=P50_DISPENSERATE) p300 = instruments.P300_Single(mount="left", tip_racks=[m300rack_2], aspirate_flow_rate=P300_ASPIRATERATE, dispense_flow_rate=P300_DISPENSERATE)
def test_deck_setup(self): deck = self.robot.deck trash = containers.load('point', 'A1', 'myTrash') tiprack = containers.load('tiprack-10ul', 'B2') self.assertTrue(isinstance(tiprack, Container)) self.assertTrue(isinstance(deck, Deck)) self.assertTrue(deck.has_container(trash)) self.assertTrue(deck.has_container(tiprack))
def run_custom_protocol( transfer_volume: float=20, robot_model: StringSelection('hood', 'not hood')='not hood', source_container: StringSelection(*container_choices)='96-flat', destination_container: StringSelection(*container_choices)='96-flat', number_of_destination_plates: int=4): # Load containers all_dest_plates = [ containers.load(destination_container, slotName) for slotName in dest_slots] source_plate = containers.load(source_container, 'C2') if (robot_model == 'hood' and number_of_destination_plates > max_plates_for_hood): raise Exception(( 'OT Hood model can only accomodate {} plates for ' + 'this protocol, you entered {}').format( max_plates_for_hood, number_of_destination_plates)) if ('384-plate' in [source_container, destination_container] and source_container != destination_container): raise Exception( 'This protocol currently only allows 96:96 or 384:384 transfers.' + ' You entered "{}" and "{}"'.format( source_container, destination_container)) row_count = len(all_dest_plates[0].rows()) dest_plates = all_dest_plates[:number_of_destination_plates] # fill row 1 for all plates, then row 2 for all plates, etc for row_index in range(row_count): if destination_container == '384-plate': # Use "alternating wells" trick for 8-channel in 384 plate dest_wells = [ row for plate in dest_plates for row in alternating_wells(plate, row_index)] source_wells = alternating_wells(source_plate, row_index) else: dest_wells = [plate.rows(row_index) for plate in dest_plates] source_wells = source_plate.rows(row_index) p50multi.distribute( transfer_volume, source_wells, dest_wells, touch_tip=True, disposal_vol=0 )
def mainReactant_transfer(reactant, reaction): # Deck setup tiprack_1000 = containers.load("tiprack-1000ul-H", "B3") #source_trough12row = containers.load("trough-12row", "C1") location_stock = containers.load("FluidX_24_2ml", "A1") reaction_rack = containers.load("StarLab_96_tall", "D1") trash = containers.load("point", "C3") # Pipettes SetUp p1000 = instruments.Pipette( name='eppendorf1000', axis='b', trash_container=trash, tip_racks=[tiprack_1000], max_volume=1000, min_volume=30, channels=1, ) id_header = "reaction" reaction_to_start = "Coupling_sequence" main_reactant_volume_header = "main reactant volume to add - per reaction (uL)" main_reactant_location_header = "Location 24 vial rack" volume_max_header = "Volume max per vial" nb_reaction_header = "Number reaction" for index, value in enumerate(reaction_conditions_df[id_header].tolist()): if value == reaction_to_start: volume_per_reaction = float(reaction_conditions_df[main_reactant_volume_header].tolist()[index]) nb_reactions = int(reaction_conditions_df[nb_reaction_header].tolist()[index]) reaction_counter = 0 """In each well, the volume per reaction of reaction is dispensed, successively in the logical order ("A1", "A2"...). When the maximum amount of reactant in one vial is taken out, the following vial in the fluidx rack is used. The transfer stops when the reactant is dispensed in all the wells of the 96 plate or all the wells used for the batch.""" for index, value in enumerate(reaction_df[main_reactant_location_header].tolist()): if reaction_counter < nb_reactions: nb_reaction_per_vial = int(float(reaction_df[volume_max_header].tolist()[index]) // volume_per_reaction) source_location = value if nb_reactions - reaction_counter < nb_reaction_per_vial: if nb_reactions - reaction_counter == 1: p1000.distribute(volume_per_reaction, location_stock.wells(source_location), reaction_rack.wells(reaction_counter).top()) nb_reaction_per_vial =1 else: p1000.distribute(volume_per_reaction, location_stock.wells(source_location), [x.top() for x in reaction_rack.wells(reaction_counter, to=nb_reactions)]) else: p1000.distribute(volume_per_reaction, location_stock.wells(source_location), [x.top() for x in reaction_rack.wells( reaction_counter, to=reaction_counter + nb_reaction_per_vial - 1)]) reaction_counter = reaction_counter + nb_reaction_per_vial robot.home()
def test_protocol_container_setup(self): plate = containers.load('96-flat', 'A1', 'myPlate') tiprack = containers.load('tiprack-10ul', 'B2') containers_list = self.robot.containers().values() self.assertEqual(len(containers_list), 2) self.assertEqual(self.robot._deck['A1']['myPlate'], plate) self.assertEqual(self.robot._deck['B2']['tiprack-10ul'], tiprack) self.assertTrue(plate in containers_list) self.assertTrue(tiprack in containers_list)
def create_container(): dialog = md.MyDialog(win) if dialog.name not in listbox.get(0, END): try: containers.load(dialog.container_type, dialog.slot, dialog.name) listbox.insert(END, dialog.name) print(dialog.name) print(listbox.get(0, END)) except ValueError: status_str.set('Container type not found') print(robot.containers())
def dmf_iodomethane_multi(reaction_conditions_df): # Deck setup tiprack_300 = containers.load("tiprack-300ul", "D3") source_trough12row = containers.load('trough-12row', "E2") reaction_rack = containers.load("StarLab_96_tall", "D1") trash = containers.load("point", 'C3') # Pipettes SetUp p300_multi = instruments.Pipette( name='dlab_300multi', axis="a", trash_container=trash, tip_racks=[tiprack_300], max_volume=300, min_volume=30, channels=8, ) # The protocol id_header = "reaction" reaction_to_start = "Coupling_sequence" reagent_trough_location_header = "reagent 2 location" volume_reagent_header = "reagent 2 volume" solvent_trough_location_header = "post work up solvent location" solvent_volume_header = "post workup solvent volume" row_number_header = "Number rows" for index, value in enumerate(reaction_conditions_df[id_header].tolist()): if value == reaction_to_start: solvent_volume = float( reaction_conditions_df[solvent_volume_header].tolist()[index]) reagent_volume = float( reaction_conditions_df[volume_reagent_header].tolist()[index]) reagent_trough_location = reaction_conditions_df[ reagent_trough_location_header].tolist()[index] solvent_trough_location = reaction_conditions_df[ solvent_trough_location_header].tolist()[index] number_rows = int( reaction_conditions_df[row_number_header].tolist()[index]) p300_multi.distribute( solvent_volume, source_trough12row.wells(solvent_trough_location), [x.top(-5) for x in reaction_rack.rows(0, to=number_rows)], air_gap=10) robot.pause() p300_multi.distribute( reagent_volume, source_trough12row.wells(reagent_trough_location), [x.top(-5) for x in reaction_rack.rows(0, to=number_rows)], air_gap=10) robot.home()
def stock_solution(amine, solvent): # Deck setup tiprack_1000 = containers.load("tiprack-1000ul-H", "B3") source_trough4row = containers.load("trough-12row", "C2") destination_stock = containers.load("Starlab_96_Square_2mL", "A1", "2mL_rack") trash = containers.load("point", "C3") # Pipettes SetUp p1000 = instruments.Pipette( name='eppendorf1000', axis='b', trash_container=trash, tip_racks=[tiprack_1000], max_volume=1000, min_volume=30, channels=1, ) id_header = "CPD ID" solvent = "DMA" stock_sol1 = "stock reagent 1" location_header = "Location_trough" destination_location_header = "Location" volume_stock_header = "Volume to dispense (uL)" volume_per_vial = "Volume to dispense" volume_inreactionrack_header = "Volume_stock per reaction" for i, x in enumerate(solvent_df[id_header].tolist()): if x == solvent: solvent_location = solvent_df[location_header].tolist()[i] if x == stock_sol1: stock_sol1_loc = solvent_df[location_header].tolist()[i] stock_sol1_volume = solvent_df[volume_stock_header].tolist()[i] # Reagents 1 and/or 2 are transfered to the 24 Fluidx vial rack. p1000.pick_up_tip() for i, x in enumerate( stock_reagent_df[destination_location_header].tolist()): destination_location = x vol_to_dispense = [ stock_reagent_df[volume_inreactionrack_header].tolist()[i] ] stock_id = stock_reagent_df[id_header].tolist()[i] if stock_id == stock_sol1: if vol_to_dispense != 0: p1000.transfer( vol_to_dispense, source_trough4row.wells(stock_sol1_loc), destination_stock.wells(destination_location).top(-5), new_tip='never') p1000.drop_tip() robot.home()
def test_serializing_configured_robot_with_2_instruments(self): plate = containers.load('96-flat', 'A1') trash = containers.load('point', 'A2') tiprack = containers.load('tiprack-200ul', 'A3') p200 = instruments.Pipette(axis='b', tip_racks=[tiprack], trash_container=trash, max_volume=200) p100 = instruments.Pipette(axis='a', channels=8, tip_racks=[tiprack], trash_container=trash, max_volume=100) self.make_commands(p200, plate, p100, plate) original_robot_cmds_txt = self.robot.commands() original_robot_cmd_cnts = len(self.robot._commands) robot_as_bytes = dill.dumps(self.robot) self.assertIsInstance(robot_as_bytes, bytes) deserialized_robot = dill.loads(robot_as_bytes) deserialized_robot_cmd_cnts = len(deserialized_robot._commands) # Check commands are unmarshalled self.assertEqual(deserialized_robot_cmd_cnts, original_robot_cmd_cnts) # Check instruments are unmarshalled original_robot_instruments = self.robot.get_instruments() deserialized_robot_instruments = self.robot.get_instruments() self.assertEqual( len(original_robot_instruments), len(deserialized_robot_instruments), ) self.assertEqual( original_robot_instruments[0][0], deserialized_robot_instruments[0][0], ) # Set deserialized robot as the global robot and attempt to # reconstruct the same commands again Singleton._instances[Robot] = deserialized_robot deserialized_robot._commands = [] r2_p200 = deserialized_robot_instruments[0][1] r2_p100 = deserialized_robot_instruments[1][1] self.make_commands(r2_p200, plate, r2_p100, plate) self.assertEqual(original_robot_cmd_cnts, len(deserialized_robot._commands)) self.assertListEqual(original_robot_cmds_txt, deserialized_robot.commands())
def test_robot(): robot.reset() containers.load('trough-12row', '3', 'trough') containers.load('96-PCR-flat', '1', 'plate') # a tip rack for our pipette p200rack = containers.load('tiprack-200ul', '2', 'tiprack') # create a p200 pipette on robot axis B instruments.P300_Single(mount="left", tip_racks=[p200rack]) # Robot tree is pretty big and hard to verify # Making sure we can serialize it into json tree, refs = serialize.get_object_tree(robot)
def test_remove_child(self): robot = self.robot robot.reset() slot = 'B1' plate = load(self.robot, '96-flat', slot, 'plate') self.assertEquals(len(robot.containers()), 1) plate.get_parent().remove_child(plate.get_name()) self.assertEquals(len(robot.containers()), 0) plate = load(self.robot, '96-flat', slot, 'plate') self.assertEquals(len(robot.containers()), 1) robot.deck[slot].remove_child(plate.get_name()) self.assertEquals(len(robot.containers()), 0)
def test_containers_create(self): import os import json from opentrons import Robot container_name = 'plate_for_testing_containers_create' containers.create(name=container_name, grid=(8, 12), spacing=(9, 9), diameter=4, depth=8, volume=1000) p = containers.load(container_name, 'A1') self.assertEquals(len(p), 96) self.assertEquals(len(p.rows), 12) self.assertEquals(len(p.cols), 8) self.assertEquals(p.get_parent(), Robot.get_instance().deck['A1']) self.assertEquals(p['C3'], p[18]) self.assertEquals(p['C3'].max_volume(), 1000) for i, w in enumerate(p): self.assertEquals(w, p[i]) # remove the file if we only created it for this test should_delete = False with open(environment.get_path('CONTAINERS_FILE')) as f: created_containers = json.load(f) del created_containers['containers'][p.get_name()] if not len(created_containers['containers'].keys()): should_delete = True if should_delete: os.remove(environment.get_path('CONTAINERS_FILE'))
def run_custom_protocol( volumes_csv: FileInput = example_csv, pipette_axis: StringSelection('B (left side)', 'A (right side)') = 'B (left side)', pipette_model: StringSelection('p200', 'p100', 'p50', 'p20', 'p10', 'p1000') = 'p200', plate_type: StringSelection('96-flat', '384-plate') = '96-flat', tip_reuse: StringSelection('new tip each time', 'reuse tip') = 'new tip each time'): pipette_max_vol = int(pipette_model[1:]) pipette = instruments.Pipette(axis='b' if pipette_axis[0] == 'B' else 'a', max_volume=pipette_max_vol, min_volume=pipette_max_vol / 10, tip_racks=tipracks, trash_container=trash) plate = containers.load(plate_type, 'A1') volumes = [float(cell) for cell in well_csv_to_list(volumes_csv)] for vol in volumes: if 0 < vol < pipette.min_volume: robot.comment( 'WARNING: volume {} is below pipette\'s minimum volume.'. format(vol)) tip_strategy = 'always' if tip_reuse == 'new tip each time' else 'once' pipette.transfer(volumes, source, plate, new_tip=tip_strategy)
def test_create_arc(self): p200 = instruments.Pipette(axis='b', name='my-fancy-pancy-pipette') plate = containers.load('96-flat', 'A1') plate2 = containers.load('96-flat', 'B1') self.robot.move_head(x=10, y=10, z=10) p200.calibrate_position((plate, Vector(0, 0, 0))) self.robot.move_head(x=10, y=10, z=100) p200.calibrate_position((plate2, Vector(0, 0, 0))) res = self.robot._create_arc((0, 0, 0), plate[0]) expected = [{'z': 100}, {'x': 0, 'y': 0}, {'z': 0}] self.assertEquals(res, expected) res = self.robot._create_arc((0, 0, 0), plate[0]) expected = [{'z': 20.5 + 5}, {'x': 0, 'y': 0}, {'z': 0}] self.assertEquals(res, expected)
def test_protocol_head(self): trash = containers.load('point', 'A1', 'myTrash') tiprack = containers.load('tiprack-10ul', 'B2') p200 = instruments.Pipette( name='myPipette', trash_container=trash, tip_racks=[tiprack], min_volume=10, # These are variable axis="b", channels=1) instruments_list = self.robot.get_instruments() self.assertEqual(instruments_list[0], ('B', p200)) instruments_list = self.robot.get_instruments('myPipette') self.assertEqual(instruments_list[0], ('B', p200))
def transfer_storageVial(condition, reactant): # Deck setup tiprack_1000 = containers.load("tiprack-1000ul-H", "B3") source_trough4row = containers.load("trough-12row", "C2") #destination_stock = containers.load("Starlab_96_Square_2mL", "A1", "2mL_rack") destination_stock = containers.load("FluidX_24_5ml", "A1", "stock") trash = containers.load("point", "C3") # Pipettes SetUp p1000 = instruments.Pipette( name='eppendorf1000', axis='b', trash_container=trash, tip_racks=[tiprack_1000], max_volume=1000, min_volume=30, channels=1, ) id_header = "reaction" reaction_to_start = "Coupling_sequence" solvent_trough_location_header = "main reactant solvent Location" reactant_trough_location_header = "main reactant location" storage_vial_location_header = "Location 24 vial rack" volume_per_vial_header = "Volume to dispense" for index, value in enumerate(reaction_conditions_df[id_header].tolist()): if value == reaction_to_start: reactant_trough_location = reaction_conditions_df[ reactant_trough_location_header].tolist()[index] # Reactant 1 is transfered to the 24 Fluidx storage vial rack. p1000.pick_up_tip() for i, v in enumerate( stock_reagent_df[storage_vial_location_header].tolist()): vial_location = v volume_to_dispense = [ stock_reagent_df[volume_per_vial_header].tolist()[i] ] if volume_to_dispense != 0: p1000.transfer(volume_to_dispense, source_trough4row.wells(reactant_trough_location), destination_stock.wells(vial_location).top(-5), new_tip='never') p1000.drop_tip() robot.home()
def dmf_iodomethane_multi(solvent): # Deck setup tiprack_300 = containers.load("tiprack-300ul", "D3") source_trough12row = containers.load('trough-12row', "E2") reaction_rack = containers.load("StarLab_96_tall", "D1") trash = containers.load("point", 'C3') # Pipettes SetUp p300_multi = instruments.Pipette( name='dlab_300multi', axis="a", trash_container=trash, tip_racks=[tiprack_300], max_volume=300, min_volume=30, channels=8, ) # The protocol id_header = "CPD ID" solvent = "MeCN2" reagent = "MeI" solvent_location_header = "Location_trough" volume_to_dispense_header = "Volume to dispense (uL)" nb_rows_header = "nb_rows" for i, x in enumerate(solvent_df[id_header].tolist()): if x == solvent: solvent_location = solvent_df[solvent_location_header].tolist()[i] solvent_volume = int( solvent_df[volume_to_dispense_header].tolist()[i]) nb_rows = solvent_df[nb_rows_header].tolist()[i] if x == reagent: reagent_location = solvent_df[solvent_location_header].tolist()[i] reagent_volume = int( solvent_df[volume_to_dispense_header].tolist()[i]) p300_multi.distribute( solvent_volume, source_trough12row.wells(solvent_location), [x.top(-5) for x in reaction_rack.rows(0, to=nb_rows)]) p300_multi.distribute( reagent_volume, source_trough12row.wells(reagent_location), [x.top(-5) for x in reaction_rack.rows(0, to=nb_rows)]) robot.home()
def calibrateToSlot(item_type, name, slot, instrument): # data for eppendorf pipette pos_dict = { 'A1': { '96-flat': (23, 36, -50) }, 'B1': { '96-flat': (116, 36, -50) }, 'C1': { '96-flat': (208, 36, -50) }, 'D1': { '96-flat': (299, 36, -50) }, 'A2': { '96-flat': (23, 172, -50) }, 'B2': { '96-flat': (116, 172, -50) }, 'C2': { '96-flat': (208, 172, -50) }, 'D2': { '96-flat': (299, 172, -50) }, 'A3': { '96-flat': (23, 305, -50) }, 'B3': { '96-flat': (116, 305, -50) }, 'C3': { '96-flat': (208, 305, -50) }, 'D3': { '96-flat': (299, 305, -50) }, } point_types = ['scale', 'trough', 'trash'] if item_type in point_types: ot_type = 'point' else: ot_type = item_type curr_container = containers.load(ot_type, slot, name) # print(curr_container) rel_pos = curr_container[0].from_center(x=0, y=0, z=-1, reference=curr_container) # print(rel_pos) # print(pos_dict[slot][item_type]) instrument.calibrate_position((curr_container, rel_pos), pos_dict[slot][item_type]) return curr_container
def test_protocol_head(self): trash = containers.load('point', 'A1', 'myTrash') tiprack = containers.load('tiprack-10ul', 'B2') p200 = instruments.Pipette( name='myPipette', trash_container=trash, tip_racks=[tiprack], min_volume=10, # These are variable axis="b", channels=1 ) instruments_list = self.robot.get_instruments() self.assertEqual(instruments_list[0], ('B', p200)) instruments_list = self.robot.get_instruments('myPipette') self.assertEqual(instruments_list[0], ('B', p200))
def intermediate_transfer(reaction, solvent): #Deck setup tiprack_1000 = containers.load("tiprack-1000ul-H", "B3") source_trough12row = containers.load("trough-12row", "C1") location_int = containers.load("FluidX_24_5ml", "A1", "int") reaction_rack = containers.load("StarLab_96_tall", "D1") trash = containers.load("point", "C3") #Pipettes SetUp p1000 = instruments.Pipette( name='eppendorf1000', axis='b', trash_container=trash, tip_racks=[tiprack_1000], max_volume=1000, min_volume=30, channels=1, ) location_header = "Location" #stock1 = "ImidInt-1" #stock2 = "ImidInt-2" #code_header = "Code" nb_reaction_header = "number of reaction" volume_per_reaction_header = "Volume_stock per reaction" n = 0 for i, x in enumerate(reaction_df[location_header].tolist()): nb_reaction = int(reaction_df[nb_reaction_header].tolist()[i]) volume_per_reaction = int( reaction_df[volume_per_reaction_header].tolist()[i]) source_location = reaction_df[location_header].tolist()[i] volume_list = [] destination_list = [] #for i in range (n+0, n+nb_reaction): #destination_list.append(i) #volume_list.append(volume_per_reaction) p1000.distribute( volume_per_reaction, location_int.wells(source_location), [ x.top() for x in reaction_rack.wells(n + 0, to=n + nb_reaction - 1) ]) n = nb_reaction + n
def setUp(self): self.robot = Robot.reset_for_tests() options = { 'limit_switches': False } self.robot.connect(options=options) self.robot.home() self.plate = containers.load('96-flat', 'A2') self.magbead = instruments.Magbead(mosfet=0, container=self.plate) self.robot._driver.set_mosfet = mock.Mock() self.robot._driver.wait = mock.Mock()
def test_calibrated_max_dimension(self): expected = self.robot._deck.max_dimensions(self.robot._deck) res = self.robot._calibrated_max_dimension() self.assertEquals(res, expected) p200 = instruments.Pipette(axis='b', name='my-fancy-pancy-pipette') plate = containers.load('96-flat', 'A1') self.robot.move_head(x=10, y=10, z=10) p200.calibrate_position((plate, Vector(0, 0, 0))) res = self.robot._calibrated_max_dimension() expected = Vector(plate.max_dimensions(plate)) + Vector(10, 10, 10) self.assertEquals(res, expected)
def process_deck(self): """ "deck": { "p200-rack": { "labware": "tiprack-200ul", "slot" : "A1" }, ".75 mL Tube Rack": { "labware": "tube-rack-.75ml", "slot" : "C1" }, "trash": { "labware": "point", "slot" : "B2" } } :return: """ deck_info = self.protocol['deck'] deck_data = {} for container_label, definition in deck_info.items(): try: container_type = definition.get('labware') except KeyError: raise JSONProcessorRuntimeError( 'Labware and Slot are required items for "{}" container ' 'definition'.format(container_label) ) slot = definition.get('slot') if not slot: slot = self.get_unallocated_slot() self.warnings.append( 'No SLOT was associated with container "{}", auto ' 'assigning container to slot {}' .format(container_label, slot) ) container_obj = containers.load( container_type, slot, container_label ) deck_data[container_label] = {'instance': container_obj} self.deck = deck_data
def setUp(self): Robot.reset_for_tests() self.robot = Robot.get_instance() self.robot.connect() self.plate = containers.load('96-flat', 'A1', 'plate') self.p200 = instruments.Pipette(name="p200", axis="b") self.p200.delete_calibration_data() well = self.plate[0] pos = well.from_center(x=0, y=0, z=0, reference=self.plate) self.location = (self.plate, pos) well_deck_coordinates = well.center(well.get_deck()) dest = well_deck_coordinates + Vector(1, 2, 3) self.robot.move_head(x=dest['x'], y=dest['y'], z=dest['z']) self.p200.calibrate_position(self.location)
def test_send_to_app_with_configured_robot(self, req_get, req_post): def fake_get(url, data, headers): res = mock.Mock() res.ok = True return res def fake_post(*args, **kwargs): res = mock.Mock() res.ok = True return res plate = containers.load('96-flat', 'A1') p200 = instruments.Pipette(axis='b', max_volume=200) for well in plate: p200.aspirate(well).delay(5).dispense(well) req_get.side_effect = fake_get req_post.side_effect = fake_post self.robot.send_to_app() self.assertTrue(req_get.called) self.assertTrue(req_post.called)
def test_serializing_configured_robot(self): plate = containers.load('96-flat', 'A1') p200 = instruments.Pipette(axis='b', max_volume=200) for well in plate: p200.aspirate(well).delay(5).dispense(well) original_robot_cmd_cnts = len(self.robot._commands) robot_as_bytes = dill.dumps(self.robot) self.assertIsInstance(robot_as_bytes, bytes) deserialized_robot = dill.loads(robot_as_bytes) deserialized_robot_cmd_cnts = len(deserialized_robot._commands) self.assertEqual(deserialized_robot_cmd_cnts, original_robot_cmd_cnts) original_robot_instruments = self.robot.get_instruments() deserialized_robot_instruments = self.robot.get_instruments() self.assertEqual( len(original_robot_instruments), len(deserialized_robot_instruments), ) self.assertEqual( original_robot_instruments[0][0], deserialized_robot_instruments[0][0], )
def setUp(self): Robot.reset_for_tests() self.plate = containers.load("96-flat", "A2")
import os from opentrons import containers from opentrons.labware import instruments from opentrons import Robot from opentrons.drivers.motor import CNCDriver from helpers.calibration import import_json_calibration robot = Robot.get_instance() robot._driver = CNCDriver() plate = containers.load("96-flat", "A2", "magbead") trash = containers.load("point", "A1", "trash") tiprack = containers.load("tiprack-200ul", "B2", "p200-rack") # tipracks need a Well height equal to the tip length for tip in tiprack: tip.properties["height"] = 80 p200 = instruments.Pipette( name="p200", trash_container=trash, tip_racks=[tiprack], max_volume=200, min_volume=0.1, # These are variable axis="b", channels=1, )
def protocol(self): robot = Robot.get_instance() robot.get_serial_ports_list() robot.connect() robot.home() tiprack = containers.load( 'tiprack-200ul', # container type 'A1', # slot 'tiprack' # user-defined name ) plate = containers.load( '96-flat', 'B1', 'plate' ) trash = containers.load( 'point', 'C2', 'trash' ) trough = containers.load( 'trough-12row', 'B2', 'trough' ) p200 = instruments.Pipette( name="p200", trash_container=trash, tip_racks=[tiprack], max_volume=200, min_volume=0.5, axis="b", channels=1 ) calibration_data = """ { "b": { "blowout": 28.0, "bottom": 26.0, "droptip": 32.0, "resting": 0, "theContainers": { "plate": { "rel_x": 181.696, "rel_y": 0.700999999999965, "rel_z": 9.600999999999999, "x": 202.195, "y": 370.304, "z": 125.7 }, "tiprack": { "rel_x": 0.0, "rel_y": 0.0, "rel_z": 0.0, "x": 20.499, "y": 369.603, "z": 116.099 }, "trough": { "rel_x": 0.0, "rel_y": 0.0, "rel_z": 0.0, "x": 20.499, "y": 269.603, "z": 116.099 }, "trash": { "rel_x": 212.701, "rel_y": -200.801, "rel_z": -58.399, "x": 233.2, "y": 171.305, "z": 57.7 } }, "tip_rack_origin": "tiprack", "tip_racks": [ { "container": "tiprack" } ], "top": 13.0, "trash_container": { "container": "trash" }, "volume": 200 } } """ import_calibration_json(calibration_data, robot, True) robot.clear_commands() # distribute p200.pick_up_tip(tiprack[0]) p200.aspirate(96 * 2, trough[0]) for i in range(96): p200.dispense(2, plate[i]).touch_tip() p200.drop_tip(tiprack[0]) p200.pick_up_tip(tiprack[1]) for i in range(96): p200.aspirate(2, plate[95 - i]) p200.dispense(trough[0]) p200.drop_tip(tiprack[1])