Ejemplo n.º 1
0
    def apply_rule(self, task_rules):
        head_substance = dict()

        if type(task_rules) is not list:
            task_rules = [task_rules]

        for rule in task_rules:
            free_heads = ps._heads_to_list(ps._interprete_heads(rule['head']))
            head_choice = 0
            for task in self.tasks:

                if re.match(rule['source'], task.source.label):
                    pos = task.target._p
                    target_row = pos[0]
                    target_col = pos[1]

                    t = rule['assignment']
                    if t == 'row':
                        head = target_row
                    if t == 'col':
                        head = target_col
                    if t == 'free':
                        if task.source.label in head_substance:
                            head = head_substance[task.source.label]
                        else:
                            head = free_heads[head_choice]
                            head_substance[task.source.label] = head
                            head_choice += 1
                            if head_choice == len(free_heads):
                                head_choice = 0

                    task.head = head
Ejemplo n.º 2
0
    def replaceWell(self, well, pos=None):
        if pos is None:
            pos = well._p

        pos = ps._interprete_well(pos)

        well.plate = self
        well._p = pos
        self.wells[ps.PositionToName(pos)] = well
Ejemplo n.º 3
0
    def __init__(self, *initial_data, **kwargs):

        self.is_source = False

        for dictionary in initial_data:
            for key in dictionary:
                setattr(self, key, dictionary[key])
        for key in kwargs:
            setattr(self, key, kwargs[key])

        if not hasattr(self, '_p'):
            self._p = [1, 1]

        self._p = ps._interprete_well(self._p)

        if hasattr(self, 'plate'):
            self.plate.replaceWell(self)
Ejemplo n.º 4
0
    def __init__(self, *initial_data, **kwargs):
        for dictionary in initial_data:
            for key in dictionary:
                setattr(self, key, dictionary[key])
        for key in kwargs:
            setattr(self, key, kwargs[key])

        # for key in self.REQUIREDMEMBERS:
        # if not hasattr(self, key):
        # print 'ERROR: Missing information for plate: ' + key

        #        if self.racktype not in self.ALLOWED_RACK_TYPES:
        #            print 'ERROR: plate racktype not allowed/registered: ' + self.racktype

        self.template()

        # create set of wells for the plate

        self.wells = {}
        self.wells = {ps.PositionToName(el): Well(position=el, plate=self) for el in ps.allWells(self.dimensions)}
Ejemplo n.º 5
0
    def apply_rule(self, rule_list):

        if type(rule_list) is not list:
            rule_list = [rule_list]

        for rule in rule_list:
            well_list = []

            plate_okay = True

            if 'target' in rule:
                if re.search(rule['target'], self.label):
                    plate_okay = True
                else:
                    plate_okay = False

            if plate_okay:
                if 'wells' in rule:
                    well_list = self.well(rule['wells'])
                    cols = []
                    rows = []

                    for well in well_list:
                        cols.append(well._p[1])
                        rows.append(well._p[0])

                    row_min = min(rows)
                    row_max = max(rows)

                    col_min = min(cols)
                    col_max = max(cols)

                if 'mixture' in rule:
                    for well in well_list:
                        col = well._p[1]
                        row = well._p[0]

                        for (substance, conc) in rule['mixture'].iteritems():

                            substance = ps.replace_value(substance, 'row', row, row_min, row_max)
                            substance = ps.replace_value(substance, 'col', col, col_min, col_max)

                            concentration, unit = ps._to_expression(conc)

                            concentration = ps.replace_value(concentration, 'row', row, row_min, row_max)
                            concentration = ps.replace_value(concentration, 'col', col, col_min, col_max)

                            concentration = str(eval(concentration))

                            if not hasattr(well, 'mixture'):
                                well.mixture = Mixture({})

                            well.mixture.contents[substance] = C(str(concentration) + unit)

                if 'volume' in rule:
                    for well in well_list:
                        col = well._p[1]
                        row = well._p[0]

                        volume, unit = ps._to_expression(rule['volume'])

                        volume = ps.replace_value(volume, 'row', row, row_min, row_max)
                        volume = ps.replace_value(volume, 'col', col, col_min, col_max)

                        volume = str(eval(volume))

                        well.volume = volume + unit
Ejemplo n.º 6
0
 def wellID(self):
     return ps.PositionToWell(self.plate.dimensions, self._p)
Ejemplo n.º 7
0
 def wellname(self):
     return ps.PositionToName(self._p)