def __get_translation_map(self, sector_index): """ Returns the 96-well position corresponding to the position in a particular 384-well sector. """ positions = dict() translator = RackSectorTranslator(number_sectors=NUMBER_SECTORS, source_sector_index=sector_index, target_sector_index=0, enforce_type=RackSectorTranslator.MANY_TO_ONE) for rack_pos_96 in get_positions_for_shape(self.stock_rack_shape): rack_pos_384 = translator.translate(rack_pos_96) positions[rack_pos_96] = rack_pos_384 return positions
def __get_translation_map(self, sector_index): """ Returns the 96-well position corresponding to the position in a particular 384-well sector. """ positions = dict() translator = RackSectorTranslator( number_sectors=NUMBER_SECTORS, source_sector_index=sector_index, target_sector_index=0, enforce_type=RackSectorTranslator.MANY_TO_ONE) for rack_pos_96 in get_positions_for_shape(self.stock_rack_shape): rack_pos_384 = translator.translate(rack_pos_96) positions[rack_pos_96] = rack_pos_384 return positions
def __check_pool_stock_racks(self): # Ensures that the new pool tube racks have tubes in the expected # positions using the layout of the sector preparation plates. Also # builds a map sector index -> pool stock rack barcode. self.add_debug('Checking new pool tube racks.') pool_stock_rack_map = {} for ispp in self.iso.iso_sector_preparation_plates: trl = RackSectorTranslator( 4, ispp.sector_index, 0, behaviour=RackSectorTranslator.MANY_TO_ONE) exp_poss = ispp.rack_layout.get_positions() pool_stock_rack_bc = self.pool_stock_racks[ispp.sector_index] pool_stock_rack_map[ispp.sector_index] = pool_stock_rack_bc new_tube_rack = self.__tube_rack_map[pool_stock_rack_bc] tube_map = dict([(trl.translate(t.location.position), t) for t in new_tube_rack.containers]) missing_poss = set(exp_poss).difference(tube_map.keys()) if len(missing_poss) > 0: msg = 'There are some tubes missing in the new stock rack ' \ 'for sector %i (%s): %s.' \ % (ispp.sector_index, new_tube_rack.barcode, ', '.join(sorted([p.label for p in missing_poss]))) self.add_error(msg) extra_poss = set(tube_map.keys()).difference(exp_poss) if len(extra_poss) > 0: msg = 'There are some empty tubes in the new stock rack ' \ 'for sector %i in positions which should be empty: ' \ ' %s. ' \ % (ispp.sector_index, ', '.join(sorted([p.label for p in extra_poss]))) self.add_warning(msg) not_empty = [ t.location.position for t in tube_map.values() if not t.sample is None and t.sample.volume > 0 ] if len(not_empty) > 0: msg = 'Some tubes in the new stock rack for sector %i are ' \ 'not empty: %s.' \ % (ispp.sector_index, ', '.join([p.label for p in not_empty])) self.add_error(msg) return pool_stock_rack_map
def __check_pool_stock_racks(self): # Ensures that the new pool tube racks have tubes in the expected # positions using the layout of the sector preparation plates. Also # builds a map sector index -> pool stock rack barcode. self.add_debug('Checking new pool tube racks.') pool_stock_rack_map = {} for ispp in self.iso.iso_sector_preparation_plates: trl = RackSectorTranslator(4, ispp.sector_index, 0, behaviour= RackSectorTranslator.MANY_TO_ONE) exp_poss = ispp.rack_layout.get_positions() pool_stock_rack_bc = self.pool_stock_racks[ispp.sector_index] pool_stock_rack_map[ispp.sector_index] = pool_stock_rack_bc new_tube_rack = self.__tube_rack_map[pool_stock_rack_bc] tube_map = dict([(trl.translate(t.location.position), t) for t in new_tube_rack.containers]) missing_poss = set(exp_poss).difference(tube_map.keys()) if len(missing_poss) > 0: msg = 'There are some tubes missing in the new stock rack ' \ 'for sector %i (%s): %s.' \ % (ispp.sector_index, new_tube_rack.barcode, ', '.join(sorted([p.label for p in missing_poss]))) self.add_error(msg) extra_poss = set(tube_map.keys()).difference(exp_poss) if len(extra_poss) > 0: msg = 'There are some empty tubes in the new stock rack ' \ 'for sector %i in positions which should be empty: ' \ ' %s. ' \ % (ispp.sector_index, ', '.join(sorted([p.label for p in extra_poss]))) self.add_warning(msg) not_empty = [t.location.position for t in tube_map.values() if not t.sample is None and t.sample.volume > 0] if len(not_empty) > 0: msg = 'Some tubes in the new stock rack for sector %i are ' \ 'not empty: %s.' \ % (ispp.sector_index, ', '.join([p.label for p in not_empty])) self.add_error(msg) return pool_stock_rack_map
def __find_ignored_sector_positions(self, ignore_positions_384): """ Converts the position in the ignored position list for the 384-well layout into 96-well position. Positions for sectors that are not required (might be the case on the last plate) are not checked. """ for sector_index in range(NUMBER_SECTORS): if not self.__library_sectors.has_key(sector_index): continue sector_positions = get_sector_positions(sector_index=sector_index, rack_shape=get_384_rack_shape(), number_sectors=NUMBER_SECTORS) translator = RackSectorTranslator(number_sectors=NUMBER_SECTORS, source_sector_index=sector_index, target_sector_index=0, enforce_type=RackSectorTranslator.ONE_TO_MANY) for sector_pos in sector_positions: if sector_pos in ignore_positions_384: rack_pos_96 = translator.translate(sector_pos) self.__ignore_positions_96[sector_index].append(rack_pos_96)
def __create_buffer_worklist(self, quadrant_layout, buffer_volume, label, sector_index): # Creates buffer dilutions worklist for a particular quadrant # and adds it to the worklist series. volume = buffer_volume / VOLUME_CONVERSION_FACTOR planned_transfers = [] translator = RackSectorTranslator( number_sectors=NUMBER_SECTORS, source_sector_index=sector_index, target_sector_index=0, enforce_type=RackSectorTranslator.ONE_TO_MANY) for rack_pos_384 in quadrant_layout.get_positions(): rack_pos_96 = translator.translate(rack_pos_384) planned_transfer = PlannedSampleDilution.get_entity( volume, self.DILUTION_INFO, rack_pos_96) planned_transfers.append(planned_transfer) worklist = PlannedWorklist(label=label, planned_transfers=planned_transfers) self.__last_worklist_index += 1 self.__worklist_series.add_worklist(self.__last_worklist_index, worklist)
def __find_ignored_sector_positions(self, ignore_positions_384): """ Converts the position in the ignored position list for the 384-well layout into 96-well position. Positions for sectors that are not required (might be the case on the last plate) are not checked. """ for sector_index in range(NUMBER_SECTORS): if not self.__library_sectors.has_key(sector_index): continue sector_positions = get_sector_positions( sector_index=sector_index, rack_shape=get_384_rack_shape(), number_sectors=NUMBER_SECTORS) translator = RackSectorTranslator( number_sectors=NUMBER_SECTORS, source_sector_index=sector_index, target_sector_index=0, enforce_type=RackSectorTranslator.ONE_TO_MANY) for sector_pos in sector_positions: if sector_pos in ignore_positions_384: rack_pos_96 = translator.translate(sector_pos) self.__ignore_positions_96[sector_index].append( rack_pos_96)