コード例 #1
0
    def __add_positions(self):
        """
        Checks position map of the parser and stores the data.
        """
        self.add_debug('Check and store position data ...')

        for pos_label, tube_barcode in self.parser.position_map.iteritems():

            if not match(RACK_POSITION_REGEXP, pos_label):
                self.__invalid_labels.append(pos_label)
                continue
            rack_pos = get_rack_position_from_label(pos_label)

            valid_values = True
            if rack_pos in self.__rs_layout.get_positions():
                self.__duplicate_positions.add(pos_label)
                valid_values = False
            if tube_barcode in self.__rs_layout.get_tube_barcodes():
                self.__duplicate_tubes.add(tube_barcode)
                valid_values = False

            if not valid_values: continue
            if tube_barcode is None: continue
            try:
                self.__rs_layout.add_position(rack_pos, tube_barcode)
            except IndexError:
                self.__position_out_of_range.append(pos_label)
コード例 #2
0
ファイル: tubehandler.py プロジェクト: helixyte/TheLMA
 def __get_rack_position(self, label):
     """
     Returns the rack position of the given label or records an error.
     """
     try:
         rack_pos = get_rack_position_from_label(label)
     except ValueError:
         self.__invalid_pos_label.append(label)
         return None
     else:
         return rack_pos
コード例 #3
0
ファイル: tubehandler.py プロジェクト: papagr/TheLMA
 def __get_rack_position(self, label):
     """
     Returns the rack position of the given label or records an error.
     """
     try:
         rack_pos = get_rack_position_from_label(label)
     except ValueError:
         self.__invalid_pos_label.append(label)
         return None
     else:
         return rack_pos
コード例 #4
0
 def run(self):
     rack_agg = get_root_aggregate(IRack)
     is_agg = get_root_aggregate(IItemStatus)
     status = is_agg.get_by_slug(self.STATUS)
     cnt_specs_agg = get_root_aggregate(IContainerSpecs)
     cnt_specs = cnt_specs_agg.get_by_slug(self.SPECS)
     tubes = []
     for scan_fn in glob.glob("%s/*.txt" % self.__scanfile_directory):
         strm = open(scan_fn, 'r')
         try:
             prs = RackScanningParser(strm, parent=self)
             prs.run()
         finally:
             strm.close()
         if prs.has_errors():
             raise RuntimeError('Could not parse rack scan file "%s". '
                                'Error messages: %s' %
                                (scan_fn, self.get_messages()))
         rack_agg.filter = eq(barcode=prs.rack_barcode)
         try:
             rack = rack_agg.iterator().next()
         except StopIteration:
             self.add_error('Rack with barcode "%s" does not exist.' %
                            prs.rack_barcode)
             continue
         if not rack.specs.has_tubes:
             self.add_error('Rack with barcode "%s" is not a tube '
                            'rack.' % rack.barcode)
             continue
         for pos_label, barcode in prs.position_map.iteritems():
             if barcode is None:
                 continue
             pos = get_rack_position_from_label(pos_label)
             # FIXME: Enable this test once pulling a tube by barcode is
             #        fast.
             #                if tube_agg.get_by_slug(barcode):
             #                    self.add_error('Tube with barcode "%s" already '
             #                                   'exists.' % barcode)
             #                    continue
             if not rack.is_empty(pos):
                 self.add_error('Trying to place a tube in an occupied '
                                'position (%s on rack %s).' %
                                (pos_label, rack.barcode))
                 continue
             tube = Tube.create_from_rack_and_position(
                 cnt_specs, status, barcode, rack, pos)
             tubes.append(tube)
             self.add_info('Creating tube with barcode %s at '
                           'position %s in rack %s.' %
                           (barcode, pos_label, rack.barcode))
     if not self.has_errors():
         self.return_value = tubes
コード例 #5
0
ファイル: emptytuberegistrar.py プロジェクト: helixyte/TheLMA
    def run(self):
        rack_agg = get_root_aggregate(IRack)
        is_agg = get_root_aggregate(IItemStatus)
        status = is_agg.get_by_slug(self.STATUS)
        cnt_specs_agg = get_root_aggregate(IContainerSpecs)
        cnt_specs = cnt_specs_agg.get_by_slug(self.SPECS)
        tubes = []
        for scan_fn in glob.glob("%s/*.txt" % self.__scanfile_directory):
            strm = open(scan_fn, 'r')
            try:
                prs = RackScanningParser(strm, parent=self)
                prs.run()
            finally:
                strm.close()
            if prs.has_errors():
                raise RuntimeError('Could not parse rack scan file "%s". '
                                   'Error messages: %s'
                                   % (scan_fn, self.get_messages()))
            rack_agg.filter = eq(barcode=prs.rack_barcode)
            try:
                rack = rack_agg.iterator().next()
            except StopIteration:
                self.add_error('Rack with barcode "%s" does not exist.'
                               % prs.rack_barcode)
                continue
            if not rack.specs.has_tubes:
                self.add_error('Rack with barcode "%s" is not a tube '
                               'rack.' % rack.barcode)
                continue
            for pos_label, barcode in prs.position_map.iteritems():
                if barcode is None:
                    continue
                pos = get_rack_position_from_label(pos_label)
                # FIXME: Enable this test once pulling a tube by barcode is
                #        fast.
#                if tube_agg.get_by_slug(barcode):
#                    self.add_error('Tube with barcode "%s" already '
#                                   'exists.' % barcode)
#                    continue
                if not rack.is_empty(pos):
                    self.add_error('Trying to place a tube in an occupied '
                                   'position (%s on rack %s).' %
                                   (pos_label, rack.barcode))
                    continue
                tube = Tube.create_from_rack_and_position(cnt_specs, status,
                                                          barcode, rack, pos)
                tubes.append(tube)
                self.add_info('Creating tube with barcode %s at '
                              'position %s in rack %s.' %
                              (barcode, pos_label, rack.barcode))
        if not self.has_errors():
            self.return_value = tubes
コード例 #6
0
ファイル: base.py プロジェクト: papagr/TheLMA
 def get_planned_sample_transfers(self, plate_marker):
     """
     Converts the all transfer target for the given target plate into
     :class:`PlannedSampleTransfer` objects.
     """
     psts = []
     for tt in self.transfer_targets:
         if not tt.target_rack_marker == plate_marker: continue
         trg_pos = get_rack_position_from_label(tt.position_label)
         pst = PlannedSampleTransfer.get_entity(
             volume=tt.transfer_volume / VOLUME_CONVERSION_FACTOR,
             source_position=self.rack_position,
             target_position=trg_pos)
         psts.append(pst)
     return psts
コード例 #7
0
ファイル: base.py プロジェクト: helixyte/TheLMA
 def get_planned_sample_transfers(self, plate_marker):
     """
     Converts the all transfer target for the given target plate into
     :class:`PlannedSampleTransfer` objects.
     """
     psts = []
     for tt in self.transfer_targets:
         if not tt.target_rack_marker == plate_marker:
             continue
         trg_pos = get_rack_position_from_label(tt.position_label)
         pst = PlannedSampleTransfer.get_entity(
             volume=tt.transfer_volume / VOLUME_CONVERSION_FACTOR,
             source_position=self.rack_position,
             target_position=trg_pos,
         )
         psts.append(pst)
     return psts
コード例 #8
0
ファイル: platecreator.py プロジェクト: papagr/TheLMA
 def run(self):
     layout_map = {}
     for sector, lfn in enumerate((self.__layout_filename_q1,
                                   self.__layout_filename_q2,
                                   self.__layout_filename_q3,
                                   self.__layout_filename_q4)):
         layout_map.update(self.__parse_layout_file(sector, lfn))
     pool_map = self.__get_md_pool_map(set(layout_map.values()))
     stock_conc_map = self.__find_stock_concentrations(pool_map)
     pool_tube_barcode_map = self.__get_tube_barcode_map(pool_map,
                                                         stock_conc_map)
     tube_map = self.__get_tube_map(pool_tube_barcode_map.values())
     tgt_rack = self.__get_target_rack(self.__target_barcode)
     for pos_label, pool_id in layout_map.iteritems():
         pos = get_rack_position_from_label(pos_label)
         cnt = tgt_rack.container_positions[pos]
         smpl = cnt.make_sample(self.__iso_volume)
         tube = tube_map[pool_tube_barcode_map[pool_id]]
         sm_conc = \
             self.__iso_concentration / len(tube.sample.sample_molecules)
         for sm in tube.sample.sample_molecules:
             smpl.make_sample_molecule(sm.molecule, sm_conc)
     tgt_rack.status = get_item_status_managed()