示例#1
0
 def __convert_one_to_many(self, rack_position, row_modifier=None,
                           col_modifier=None):
     # Converts the given rack position of rack into to a rack position in
     # a smaller (or equally sized) rack.
     #  :Note: Row and column modifier can be provided by the
     #    :func:`convert_many_to_many` method.
     if row_modifier is None:
         row_modifier = self.__row_modifier
     if col_modifier is None:
         col_modifier = self.__col_modifier
     row_index = (float(rack_position.row_index - row_modifier) \
                       / self.__row_count)
     col_index = (float(rack_position.column_index - col_modifier) \
                       / self.__col_count)
     if not row_index.is_integer() or not col_index.is_integer():
         msg = 'Invalid rack position for translation. Given rack ' \
               'position: %s, resulting row index: %.1f, resulting column ' \
               'index: %.1f, sector number: %i, row number: %i, column ' \
               'number: %i, row modifier: %i, column modifier: %i, ' \
               'translation type: %s.' \
               % (rack_position, row_index, col_index, self.__number_sectors,
                  self.__row_count, self.__col_count, row_modifier,
                  col_modifier, self.behaviour)
         raise ValueError(msg)
     return get_rack_position_from_indices(int(row_index), int(col_index))
示例#2
0
    def _create_candidate_from_query_result(self, result_record):
        """
        Converts a query result record into a candidate. By default all
        column names are used as keyword.

        If there \'row_index\' and \'column_index\' columns the two columns
        are converted into a rack position value (keyword \'rack_position\').
        """
        row_index = None
        column_index = None
        kw = dict()

        for i in range(len(self.COLUMN_NAMES)):
            col_name = self.COLUMN_NAMES[i]
            if col_name in self.IGNORE_COLUMNS: continue
            value = result_record[i]
            if self.CONVERT_RACK_POSITION and col_name == 'row_index':
                row_index = value
            elif self.CONVERT_RACK_POSITION and col_name == 'column_index':
                column_index = value
            else:
                kw[col_name] = value

        if row_index is not None and column_index is not None:
            rack_pos = get_rack_position_from_indices(row_index=row_index,
                                                      column_index=column_index)
            kw['rack_position'] = rack_pos

        return self.CANDIDATE_CLS(**kw) #pylint: disable=E1102
示例#3
0
 def _create_iso_candidates(self, tube_rack_fac, tube_rack_specs_matrix,
                            tube_fac, item_status_managed,
                            organization_cenix, stock_sample_fac):
     ss_agg = get_root_aggregate(IStockSample)
     rack_agg = get_root_aggregate(IRack)
     tube_bc = 9000000000
     vol = 1e-4
     row_idx = 0
     col_idx = 0
     tube_rack = tube_rack_fac(label='test_iso_candidates',
                               specs=tube_rack_specs_matrix,
                               status=get_item_status_managed())
     rack_agg.add(tube_rack)
     mdp_agg = get_root_aggregate(IMoleculeDesignPool)
     for mdp_id in [288282, 3349397, 3430173, 1139866, 199937]:
         tube = tube_fac(barcode=str(tube_bc), status=item_status_managed)
         col_idx += 1
         tube_bc += 1
         tube_rack.add_tube(
             tube, get_rack_position_from_indices(row_idx, col_idx))
         mdp = mdp_agg.get_by_id(mdp_id)
         ss = stock_sample_fac(
             volume=vol,
             container=tube,
             molecule_design_pool=mdp,
             supplier=organization_cenix,
             molecule_type=mdp.molecule_type,
             concentration=mdp.default_stock_concentration)
         ss_agg.add(ss)
示例#4
0
    def _create_candidate_from_query_result(self, result_record):
        """
        Converts a query result record into a candidate. By default all
        column names are used as keyword.

        If there \'row_index\' and \'column_index\' columns the two columns
        are converted into a rack position value (keyword \'rack_position\').
        """
        row_index = None
        column_index = None
        kw = dict()

        for i in range(len(self.COLUMN_NAMES)):
            col_name = self.COLUMN_NAMES[i]
            if col_name in self.IGNORE_COLUMNS: continue
            value = result_record[i]
            if self.CONVERT_RACK_POSITION and col_name == 'row_index':
                row_index = value
            elif self.CONVERT_RACK_POSITION and col_name == 'column_index':
                column_index = value
            else:
                kw[col_name] = value

        if row_index is not None and column_index is not None:
            rack_pos = get_rack_position_from_indices(
                row_index=row_index, column_index=column_index)
            kw['rack_position'] = rack_pos

        return self.CANDIDATE_CLS(**kw)  #pylint: disable=E1102
示例#5
0
 def _create_iso_candidates(self, tube_rack_fac, tube_rack_specs_matrix,
                            tube_fac, item_status_managed,
                            organization_cenix, stock_sample_fac):
     ss_agg = get_root_aggregate(IStockSample)
     rack_agg = get_root_aggregate(IRack)
     tube_bc = 9000000000
     vol = 1e-4
     row_idx = 0
     col_idx = 0
     tube_rack = tube_rack_fac(label='test_iso_candidates',
                               specs=tube_rack_specs_matrix,
                               status=get_item_status_managed())
     rack_agg.add(tube_rack)
     mdp_agg = get_root_aggregate(IMoleculeDesignPool)
     for mdp_id in [288282, 3349397, 3430173, 1139866, 199937]:
         tube = tube_fac(barcode=str(tube_bc),
                         status=item_status_managed)
         col_idx += 1
         tube_bc += 1
         tube_rack.add_tube(
                     tube,
                     get_rack_position_from_indices(row_idx, col_idx))
         mdp = mdp_agg.get_by_id(mdp_id)
         ss = stock_sample_fac(
                         volume=vol,
                         container=tube,
                         molecule_design_pool=mdp,
                         supplier=organization_cenix,
                         molecule_type=mdp.molecule_type,
                         concentration=mdp.default_stock_concentration)
         ss_agg.add(ss)
示例#6
0
 def __prepare_pool_stock_rack(self, empty_rack, sector_idx):
     tube_specs_agg = get_root_aggregate(ITubeSpecs)
     ts_matrix = tube_specs_agg.get_by_slug('matrix0500')
     is_managed = get_item_status_managed()
     pos_idxs_96 = zip([1, 1, 0, 0], [1, 1, 1, 1])
     (row_idx, col_idx) = pos_idxs_96[sector_idx]
     tube = Tube.create_from_data(
         dict(barcode=str(9999999990 + tube_counter.next()),
              status=is_managed,
              specs=ts_matrix))
     pos = get_rack_position_from_indices(row_idx, col_idx)
     empty_rack.add_tube(tube, pos)
示例#7
0
 def __convert_many_to_one(self, rack_position, row_modifier=None,
                           col_modifier=None):
     # Converts the given rack position of rack into to a rack position in
     # a larger (or equally sized) rack.
     # :Note: Row and column modifier can be provided by the
     #      :func:`convert_many_to_many` method.
     if row_modifier is None:
         row_modifier = self.__row_modifier
     if col_modifier is None:
         col_modifier = self.__col_modifier
     row_index = (rack_position.row_index * self.__row_count) \
                 + row_modifier
     col_index = (rack_position.column_index * self.__col_count) \
                 + col_modifier
     return get_rack_position_from_indices(row_index, col_index)
示例#8
0
文件: condense.py 项目: papagr/TheLMA
 def _store_result(self, result_record):
     rack_barcode = result_record[self.RACK_BARCODE_INDEX]
     scr = self.rack_map[rack_barcode]
     rack_pos = get_rack_position_from_indices(
         row_index=result_record[self.ROW_INDEX_INDEX],
         column_index=result_record[self.COLUMN_INDEX_INDEX])
     tube_barcode = result_record[self.TUBE_BARCODE_INDEX]
     tube_status = result_record[self.TUBE_STATUS_INDEX]
     if not tube_status == STOCK_ITEM_STATUS:
         info = '%s (status: %s, rack: %s)' \
                 % (str(tube_barcode), tube_status, rack_barcode)
         self.mismatching_tubes.append(info)
         return None
     tube_specs_name = result_record[self.TUBE_SPECS_NAME_INDEX]
     if not tube_specs_name in STOCK_TUBE_SPECS:
         info = '%s (tube specs: %s, rack: %s)' \
                 % (str(tube_barcode), tube_specs_name, rack_barcode)
         self.mismatching_tubes.append(info)
         return None
     scr.add_tube(rack_pos, tube_barcode)
示例#9
0
 def _store_result(self, result_record):
     rack_barcode = result_record[self.RACK_BARCODE_INDEX]
     scr = self.rack_map[rack_barcode]
     rack_pos = get_rack_position_from_indices(
                         row_index=result_record[self.ROW_INDEX_INDEX],
                         column_index=result_record[self.COLUMN_INDEX_INDEX])
     tube_barcode = result_record[self.TUBE_BARCODE_INDEX]
     tube_status = result_record[self.TUBE_STATUS_INDEX]
     if not tube_status == STOCK_ITEM_STATUS:
         info = '%s (status: %s, rack: %s)' \
                 % (str(tube_barcode), tube_status, rack_barcode)
         self.mismatching_tubes.append(info)
         return None
     tube_specs_name = result_record[self.TUBE_SPECS_NAME_INDEX]
     if not tube_specs_name in STOCK_TUBE_SPECS:
         info = '%s (tube specs: %s, rack: %s)' \
                 % (str(tube_barcode), tube_specs_name, rack_barcode)
         self.mismatching_tubes.append(info)
         return None
     scr.add_tube(rack_pos, tube_barcode)
示例#10
0
 def _convert_results_to_entity(self):
     """
     Converts the parsing results into a :class:`LibraryBaseLayout`
     (no entity class).
     """
     self.add_info('Convert parser results ...')
     if not self.has_errors():
         self.__init_layout()
     if not self.has_errors():
         for rack_pos_container in self.parser.contained_wells:
             rack_pos = get_rack_position_from_indices(
                 row_index=rack_pos_container.row_index,
                 column_index=rack_pos_container.column_index)
             base_pos = LibraryBaseLayoutPosition(rack_pos)
             self.__base_layout.add_position(base_pos)
     if not self.has_errors() and len(self.__base_layout) < 1:
         msg = 'The specified base layout is empty!'
         self.add_error(msg)
     if not self.has_errors():
         self.__base_layout.close()
         self.return_value = self.__base_layout
         self.add_info('Conversion completed.')
示例#11
0
 def _convert_results_to_entity(self):
     """
     Converts the parsing results into a :class:`LibraryBaseLayout`
     (no entity class).
     """
     self.add_info('Convert parser results ...')
     if not self.has_errors():
         self.__init_layout()
     if not self.has_errors():
         for rack_pos_container in self.parser.contained_wells:
             rack_pos = get_rack_position_from_indices(
                             row_index=rack_pos_container.row_index,
                             column_index=rack_pos_container.column_index)
             base_pos = LibraryBaseLayoutPosition(rack_pos)
             self.__base_layout.add_position(base_pos)
     if not self.has_errors() and len(self.__base_layout) < 1:
         msg = 'The specified base layout is empty!'
         self.add_error(msg)
     if not self.has_errors():
         self.__base_layout.close()
         self.return_value = self.__base_layout
         self.add_info('Conversion completed.')
示例#12
0
 def get_position(self):
     """
     Returns a position which is then remove from the pool.
     """
     row_index = self.free_row_indices.pop(0)
     return get_rack_position_from_indices(row_index, self.column_index)
示例#13
0
 def _convert_to_rack_position(self, pos_container):
     """
     Creates a rack position for a rack position container.
     """
     return get_rack_position_from_indices(pos_container.row_index,
                                           pos_container.column_index)
示例#14
0
文件: base.py 项目: helixyte/TheLMA
 def _convert_to_rack_position(self, pos_container):
     """
     Creates a rack position for a rack position container.
     """
     return get_rack_position_from_indices(pos_container.row_index,
                                           pos_container.column_index)