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 setUp(self): self.robot = Robot() self.trash_box = containers_load(self.robot, 'trash-box', 'A1') self.wheaton_vial_rack = containers_load( self.robot, 'wheaton_vial_rack', 'A2' ) self.tube_rack_80well = containers_load( self.robot, 'tube-rack-80well', 'A3' ) self.T75_flask = containers_load(self.robot, 'T75-flask', 'B1') self.T25_flask = containers_load(self.robot, 'T25-flask', 'B2')
def setup_robot(): robot = Robot() for port in list_of_ports: trycon(robot, port) if (robot.is_simulating()): print("no connection made") else: robot.home() robot._driver.speeds['z'] = 1200 for (axis, pipette) in robot.get_instruments(): pipette.load_persisted_data() try: yield robot finally: robot.disconnect()
def setUp(self): self.robot = Robot() options = { 'limit_switches': False } self.robot.connect(options=options) self.robot.home() self.plate = containers_load(self.robot, '96-flat', 'A2') self.magbead = magbead.Magbead( self.robot, mosfet=0, container=self.plate ) self.robot._driver.set_mosfet = mock.Mock() self.robot._driver.wait = mock.Mock()
def create_command(self, do, setup=None, description=None, enqueue=True): """ Creates an instance of Command to be appended to the :any:`Robot` run queue. Parameters ---------- do : callable The method to execute on the robot. This usually includes moving an instrument's motors, or the robot head setup : callable The method to execute just before `do()`, which includes updating the instrument's state description : str Human-readable description of the action taking place enqueue : bool If set to `True` (default), the method will be appended to the robots list of commands for executing during :any:`run` or :any:`simulate`. If set to `False`, the method will skip the command queue and execute immediately Examples -------- .. >>> instrument = Instrument() >>> def setup(): >>> print('hello') >>> def do(): >>> print(' world') >>> description = 'printing "hello world"' >>> instrument.create_command(do, setup, description) hello >>> robot.simulate() hello world >>> instrument.create_command(do, setup, description, enqueue=False) hello world """ command = Command(do=do, setup=setup, description=description) if enqueue: Robot().add_command(command) else: command()
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 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 setUp(self): self.robot = Robot() # set this to True if testing with a robot connected # testing while connected allows the response handlers # and serial handshakes to be tested options = { 'firmware': 'edge-1c222d9NOMSD', 'limit_switches': True, 'config': { 'alpha_steps_per_mm': 80.0, 'beta_steps_per_mm': 80.0 } } self.robot.disconnect() self.robot.connect(options=options) self.motor = self.robot._driver
def accomplish_goals(goals, deckstate, robot=Robot()): pip = robot.get_instruments()[0][1] #do stuff with deckstate to set current volumes of all the wells for container_name in deckstate.keys(): container_instance = robot.deck.containers()[container_name] for wellname in deckstate[container_name].keys(): container_instance.wells( wellname).vol = deckstate[container_name][wellname] try: for source in goals.keys(): source_container, source_well = source.split('.') s_well = robot.containers()[source_container].wells(source_well) for destination, destination_amount in goals[source].items(): #this needs some cleverness but it'll do for now dest_cont, dest_well = destination.split('.') d_well = robot.containers()[dest_cont].wells(dest_well) get_from_fat_well(float(destination_amount), s_well, pip) pip.dispense(d_well) #TODO: annotate the goals somehow except: #is this a good idea? robot.halt() for container in deckstate.keys(): container_instance = robot.deck.containers()[container] #I'm really unsure about all this. IT seems wrong for wellname in deckstate[container].keys(): if hasattr(container_instance.wells(wellname), "vol"): deckstate[container][wellname] = container_instance.wells( wellname).vol with open("dumpedstate.yaml", 'w') as sfp: yaml.dump(deckstate, sfp) raise
def setUp(self): self.robot = Robot()
class Instrument(object): """ This class represents instrument attached to the :any:`Robot`: :Pipette:, :Magbead:. It gives the instruments ability to CRUD their calibration data, and gives access to some common methods across instruments """ calibration_key = "unique_name" persisted_attributes = [] persisted_defaults = {} calibrator = Calibrator(Robot()._deck, {}) def reset(self): """ Placeholder for instruments to reset their state between runs """ pass def setup_simulate(self, *args, **kwargs): """ Placeholder for instruments to prepare their state for simulation """ pass def teardown_simulate(self, *args, **kwargs): """ Placeholder for instruments to reverse :meth:`setup_simulate` """ pass def create_command(self, do, setup=None, description=None, enqueue=True): """ Creates an instance of Command to be appended to the :any:`Robot` run queue. Parameters ---------- do : callable The method to execute on the robot. This usually includes moving an instrument's motors, or the robot head setup : callable The method to execute just before `do()`, which includes updating the instrument's state description : str Human-readable description of the action taking place enqueue : bool If set to `True` (default), the method will be appended to the robots list of commands for executing during :any:`run` or :any:`simulate`. If set to `False`, the method will skip the command queue and execute immediately Examples -------- .. >>> instrument = Instrument() >>> def setup(): >>> print('hello') >>> def do(): >>> print(' world') >>> description = 'printing "hello world"' >>> instrument.create_command(do, setup, description) hello >>> robot.simulate() hello world >>> instrument.create_command(do, setup, description, enqueue=False) hello world """ command = Command(do=do, setup=setup, description=description) if enqueue: Robot().add_command(command) else: command() def init_calibrations(self, key, attributes=None): """ Creates empty calibrations data if not already present Parameters ---------- key : str The unique string to save this instrument's calibation data attributes : list A list of this instrument's attribute names to be saved """ self.calibration_key = key if isinstance(attributes, list): self.persisted_attributes = attributes for key in attributes: self.persisted_defaults[key] = copy.copy(getattr(self, key)) if not os.path.isdir(self._get_calibration_dir()): os.mkdir(self._get_calibration_dir()) file_path = self._get_calibration_file_path() if not os.path.isfile(file_path): with open(file_path, 'a') as f: f.write(json.dumps({})) def update_calibrations(self): """ Saves the instrument's peristed attributes to file """ last_persisted_data = self._read_calibrations() last_persisted_data[self.calibration_key] = (self._strip_vector( self._build_calibration_data())) last_persisted_data = self._strip_vector(last_persisted_data) with open(self._get_calibration_file_path(), 'w') as f: f.write(json.dumps(last_persisted_data, indent=4)) def load_persisted_data(self): """ Loads and sets the instrument's peristed attributes from file """ last_persisted_data = self._get_calibration() if last_persisted_data: last_persisted_data = self._restore_vector(last_persisted_data) for key, val in last_persisted_data.items(): setattr(self, key, val) def delete_calibration_data(self): """ Set the instrument's properties to their initialized values, and saves those initialized values to file """ for key, val in self.persisted_defaults.items(): setattr(self, key, val) self.update_calibrations() def delete_calibration_file(self): """ Deletes the entire calibrations file """ file_path = self._get_calibration_file_path() if os.path.exists(file_path): os.remove(file_path) def _get_calibration_dir(self): """ :return: the directory to save calibration data """ DATA_DIR = os.environ.get('APP_DATA_DIR') or os.getcwd() return os.path.join(DATA_DIR, CALIBRATIONS_FOLDER) def _get_calibration_file_path(self): """ :return: the absolute file path of the calibration file """ return os.path.join(self._get_calibration_dir(), CALIBRATIONS_FILE) def _get_calibration(self): """ :return: this instrument's saved calibrations data """ return self._read_calibrations().get(self.calibration_key) def _build_calibration_data(self): """ :return: copy of this instrument's persisted attributes """ calibration = {} for attr in self.persisted_attributes: calibration[attr] = copy.copy(getattr(self, attr)) return calibration def _read_calibrations(self): """ Reads calibration data from file system. :return: json of calibration data """ with open(self._get_calibration_file_path()) as f: try: loaded_json = json.load(f) except json.decoder.JSONDecodeError: loaded_json = {} return self._restore_vector(loaded_json) def _strip_vector(self, obj, root=True): """ Iterates through a dictionary, converting Vector classes to serializable dictionaries :return: json of calibration data """ obj = (copy.deepcopy(obj) if root else obj) for key, val in obj.items(): if isinstance(val, Vector): res = json.dumps(val, cls=VectorEncoder) obj[key] = res elif isinstance(val, dict): self._strip_vector(val, root=False) return obj def _restore_vector(self, obj, root=True): """ Iterates through a dictionary, converting serializable Vector dictionaries to Vector classes :return: json of calibration data """ obj = (copy.deepcopy(obj) if root else obj) for key, val in obj.items(): if isinstance(val, dict): self._restore_vector(val, root=False) elif isinstance(val, str): try: res = Vector(json.loads(val)) obj[key] = res except JSON_ERROR: pass return obj
def setUp(self): self.robot = Robot() self.plate = load(self.robot, '96-flat', '4')
def setUp(self): Robot.reset_for_tests() self.robot = Robot()
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} def set_dilution_factor(self, x): self.dilution_factor = x def set_well_list(self, mylist): self.well_list = mylist def modify_dilution_matrix(self,well_index, d_factor): self.dilution_matrix[well_index] = d_factor robot = Robot() robot.reset() User = UserInfo() User.set_dilution_factor(5) trash = containers.load('point', 'E2') tiprack = containers.load('tiprack-200ul', 'E1') big_tubes = containers.load('tube-rack-15_50ml', 'A2') #this 96-well plate has the samples samples = containers.load('96-PCR-flat', 'B1') #this is the plate that we are aiming samples to dilutions = containers.load('96-PCR-flat', 'C1')
def setUp(self): self.events = [] self.robot = Robot()
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')