def setUp(self): self.robot = Robot() self.robot.connect() self.trash = containers_load(self.robot, 'point', 'A1', 'trash') self.tiprack = containers_load(self.robot, 'tiprack-200ul', 'B2', 'p200-rack') self.trough = containers_load(self.robot, 'trough-12row', 'B2', 'trough') self.plate = containers_load(self.robot, '96-flat', 'A2', 'magbead') self.p200 = pipette.Pipette( self.robot, name="p200", trash_container=self.trash, tip_racks=[self.tiprack], min_volume=10, # These are variable axis="b", channels=1) self.p1000 = pipette.Pipette( self.robot, name="p1000", trash_container=self.trash, tip_racks=[self.tiprack], min_volume=100, # These are variable axis="a", channels=1)
def test_serializing_configured_robot_with_2_instruments(self): plate = containers_load(self.robot, '96-flat', 'A1') trash = containers_load(self.robot, 'point', 'A2') tiprack = containers_load(self.robot, 'tiprack-200ul', 'A3') p200 = pipette.Pipette( self.robot, axis='b', tip_racks=[tiprack], trash_container=trash, max_volume=200 ) p100 = pipette.Pipette( self.robot, 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 r2_p200 = deserialized_robot_instruments[0][1] r2_p100 = deserialized_robot_instruments[1][1] self.make_commands(r2_p200, plate, r2_p100, plate)
def test_new_containers(self): p200 = pipette.Pipette( self.robot, axis='a', max_volume=1000, name='stupid-pipette') p200.aspirate(100, self.wheaton_vial_rack[0]) p200.aspirate(100, self.tube_rack_80well[0]) p200.aspirate(100, self.T75_flask[0]) p200.aspirate(100, self.T25_flask[0]) p200.dispense(self.trash_box)
def test_save_load_calibration_data(self): self.p200 = pipette.Pipette(self.robot, name="p200-diff", axis="b") self.assertDictEqual(self.p200.calibration_data, {}) self.p200 = pipette.Pipette(self.robot, name="p200", axis="a") self.p200.delete_calibration_data() self.assertDictEqual(self.p200.calibration_data, {}) self.p200 = pipette.Pipette(self.robot, name="p200", axis="b") expected_delta = {'delta': (1.0, 2.0, 3.0), 'type': '96-flat'} self.assertTrue('A1' in self.p200.calibration_data) actual = self.p200.calibration_data['A1']['children'] self.assertTrue('plate' in actual) actual = self.p200.calibration_data['A1']['children']['plate'] self.assertEquals(expected_delta, actual)
def protocol(self): self.robot.get_serial_ports_list() self.robot.home() tiprack = containers_load( self.robot, 'tiprack-200ul', # container type 'A1', # slot 'tiprack' # user-defined name ) plate = containers_load( self.robot, '96-flat', 'B1', 'plate' ) trash = containers_load( self.robot, 'point', 'C2', 'trash' ) trough = containers_load( self.robot, 'trough-12row', 'B2', 'trough' ) p200 = pipette.Pipette( self.robot, name="p200", trash_container=trash, tip_racks=[tiprack], min_volume=0.5, axis="b", channels=1 ) self.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])
def test_deck_setup(self): deck = self.robot.deck pip = pipette.Pipette(self.robot, mount='left') # Check that the fixed trash has loaded on to the pipette trash = pip.trash_container tiprack = containers_load(self.robot, 'tiprack-10ul', '5') self.assertTrue(isinstance(tiprack, Container)) self.assertTrue(isinstance(deck, Deck)) # Check that well location is the same on the robot as the pipette self.assertEqual(self.robot._deck['12']['tall-fixed-trash'][0], trash) self.assertTrue(deck.has_container(tiprack))
def test_delete_calibrations_data(self): self.p200 = pipette.Pipette(self.robot, name="p200", axis="b") expected_delta = {'delta': (1.0, 2.0, 3.0), 'type': '96-flat'} self.assertTrue('A1' in self.p200.calibration_data) actual = self.p200.calibration_data['A1']['children'] self.assertTrue('plate' in actual) actual = self.p200.calibration_data['A1']['children']['plate'] self.assertEquals(expected_delta, actual) self.p200.delete_calibration_data() self.assertDictEqual(self.p200.calibration_data, {}) self.p200 = pipette.Pipette(self.robot, name="p200", axis="b") self.assertDictEqual(self.p200.calibration_data, {}) self.assertDictEqual( self.p200.positions, { 'top': 0.0101, 'bottom': 10.0101, 'blow_out': 12.0101, 'drop_tip': 14.0101 })
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 = pipette.Pipette(self.robot, axis='b', name='my-fancy-pancy-pipette') plate = containers_load(self.robot, '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 setUp(self): self.robot = Robot() self.robot.connect() self.plate = containers_load(self.robot, '96-flat', 'A1', 'plate') self.p200 = pipette.Pipette(self.robot, 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_protocol_head(self): trash = containers_load(self.robot, 'point', 'A1', 'myTrash') tiprack = containers_load(self.robot, 'tiprack-10ul', 'B2') p200 = pipette.Pipette( self.robot, 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 setUp(self): self.robot = Robot() self.robot.home() self.trash = containers_load(self.robot, 'point', 'A1') self.tiprack1 = containers_load(self.robot, 'tiprack-10ul', 'B2') self.tiprack2 = containers_load(self.robot, 'tiprack-10ul', 'B3') self.plate = containers_load(self.robot, '96-flat', 'A2') self.p200 = pipette.Pipette( self.robot, trash_container=self.trash, tip_racks=[self.tiprack1, self.tiprack2], max_volume=200, min_volume=10, # These are variable axis="a", channels=1) self.p200.aspirate(100, self.plate[0]).dispense()
def test_create_arc(self): p200 = pipette.Pipette(self.robot, axis='b', name='my-fancy-pancy-pipette') plate = containers_load(self.robot, '96-flat', 'A1') plate2 = containers_load(self.robot, '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_serial_dilution(self): plate = load(self.robot, '96-flat', '2', 'plate') tiprack = load( self.robot, 'tiprack-200ul', # container type from library '1', # slot on deck 'tiprack' # calibration reference for 1.2 compatibility ) trough = load(self.robot, 'trough-12row', '5', 'trough') trash = load(self.robot, 'point', '3', 'trash') p200 = pipette.Pipette( self.robot, ul_per_mm=18.5, trash_container=trash, tip_racks=[tiprack], min_volume=10, max_volume=200, # These are variable mount='left', 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 test_serializing_configured_robot(self): plate = containers_load(self.robot, '96-flat', 'A1') p200 = pipette.Pipette(self.robot, 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 protocol(self): self.robot.get_serial_ports_list() self.robot.home() tiprack = containers_load( self.robot, 'tiprack-200ul', # container type 'A1', # slot 'tiprack' # user-defined name ) plate = containers_load(self.robot, '96-flat', 'B1', 'plate') trash = containers_load(self.robot, 'point', 'C2', 'trash') trough = containers_load(self.robot, 'trough-12row', 'B2', 'trough') p200 = pipette.Pipette(self.robot, 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, self.robot, True) self.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])
def setUp(self): # TODO(Ahmed): Why does this test setup a plate, robot, container # when it doesnt use them in any test cases? self.robot = Robot() self.p200 = pipette.Pipette(self.robot, mount='left') self.plate = containers_load(self.robot, '96-flat', '3')