Exemple #1
0
    def pushButtonAdd_clicked(self):
        reactants = self.lineEditReactants.text()
        products = self.lineEditProducts.text()
        inhibitors = self.lineEditInhibitors.text()

        try:
            reaction = Reaction(
                R=reaction_adapter(reactants),
                P=reaction_adapter(products),
                I=reaction_adapter(inhibitors))
        except Exception as e:
            self._manageExceptionReactionSystem(e)
            return

        if reaction in self.reaction_list:
            self.notify('Error: this reaction is already present')
            return
        
        self.reaction_list.append(reaction)

        self.listWidgetReactions_addReaction(reaction)
        self.notify('Added ' + str(reaction).replace('->', '⟶'))

        self.pushButtonCalculate_enable()
        self.actionSave.setEnabled(True)
Exemple #2
0
 def text2reaction_list(text):
     reaction_list = []
     text.replace('\r', ' ')
     reactions = text.split('\n')
     for reaction in reactions:
         if (re.match('^\s*#', reaction) or re.match('^\s*$', reaction)): # pylint: disable=W1401
             continue
         reaction_list.append(Reaction(reaction_adapter(reaction)))
     return reaction_list
Exemple #3
0
    def pushButtonCalculate_clicked(self):
        if not self.pushButtonCalculate_generateContextPropertieSet():
            return

        DialogFBP(self,
            deepcopy(reaction_adapter(self.lineEditCalculatorSymbols.text())),
            deepcopy(self.spinBoxCalculatorSteps.value()),
            ReactionSet(deepcopy(self.reaction_list)),
            deepcopy(self.context_given_set[0]),
            deepcopy(self.context_given_set[1])
        ).show()
Exemple #4
0
    def pushButtonDelete_clicked(self):
        i = 0
        while self.listWidgetReactions._checked_item_number:
            if self.listWidgetReactions.item(i).checkState():
                item = self.listWidgetReactions.takeItem(i)
                self.reaction_list.remove(Reaction(reaction_adapter(item.text()).replace('⟶', '->')))
                self.listWidgetReactions._checked_item_number -= 1
            else: i += 1
        self.pushButtonDelete.setEnabled(False)

        self.pushButtonCalculate_enable()
        self.actionSave.setEnabled(True)
Exemple #5
0
    def pushButtonCalculate_generateContextPropertieSet(self):
        self.context_given_set = [set(), set()]
        steps = self.spinBoxCalculatorSteps.value()

        for j in range(0, self.tableWidgetProperties.columnCount()):
            for i in range(0, len(self.context_given_set)):
                cellContent = reaction_adapter(
                    self.tableWidgetProperties.cellWidget(i, j).text())
                symbol_regex = Reaction._get_symbol_regex()

                symbol_list_regex = '^\s*(%?{}\s+)*%?{}\s*$'.format(symbol_regex, symbol_regex) # pylint: disable=W1401
                
                if (len(cellContent) and not cellContent.isspace() and
                        not re.match(symbol_list_regex, cellContent)):
                    self.notify('Error: invalid syntax in step {}'.format(str(j+1)))
                    return False
                
                pattern = '%{}'.format(symbol_regex)
                context_given_from = re.findall(pattern, cellContent)
                context_given = re.sub(pattern, '', cellContent)
                context_given = re.findall(symbol_regex, context_given)
                
                context_given = set(map(lambda s: (j, s), context_given))
                context_given_from = set(map(lambda s: s[1:], context_given_from))
                
                self.context_given_set[i] = self.context_given_set[i].union(context_given)

                for z in range(j, steps):
                    for symbol in context_given_from:
                        self.context_given_set[i].add((z, symbol))
                

            intersectionSet = self.context_given_set[0].intersection(self.context_given_set[1])
            if len(intersectionSet):
                symbols_set = sorted(list(set(map(lambda t: t[1], intersectionSet))))
                self.notify('Error in context properties step {}: {}'.format(str(j+1), ' '.join(symbols_set)))
                return False
        
        return True