BioSIMI-Python/modules/NewReaction.py
def parseReactionString(self, rStr):
        '''
        Parses the reaction string to return a list of reactants (and products), a list of 
        stoichiometry constants of the reactants (and products)
        '''
        rxn = self.getReaction()
        if '-->' in rStr:
            rReversible = False
        elif '<->' in  rStr:
            rReversible = True

        check(rxn.setReversible(rReversible), 'set r_obj reversible')
        if not rxn.isSetReversible():
           raise SyntaxError('Reaction reversible attribute is not set.')

        rStr = rStr.replace(' ', '')
        if rxn.getReversible():
            s_rxn = rStr.split('<->')
        else:
            s_rxn = rStr.split('-->')

        if len(s_rxn) != 2:
            raise SyntaxError('Reaction string should have one arrow only')

        s_reac = s_rxn[0]
        s_pro = s_rxn[1]

        reactants = s_reac.split('+')
        products = s_pro.split('+')
        reactant_stoichList = []
        reactantList = []
        for reactant in reactants:
            stoich = re.findall(r'\d+',reactant)
            if len(stoich) > 1:
                raise SyntaxError('Reaction string syntax not correct')
            if stoich == []:
                stoich_int = 1
                reactant_stoichList.append(stoich_int)
                reactantList.append(reactant)
            else:
                stoich_int = int(stoich[0])
                reactant_stoichList.append(stoich_int)
                reactantList.append(reactant.replace(stoich[0],''))

        product_stoichList = []
        productList = []
        for product in products:
            stoich = re.findall(r'\d+',product)
            if len(stoich) > 1:
                raise SyntaxError('Reaction string syntax not correct')
            if stoich == []:
                stoich_int = 1
                product_stoichList.append(stoich_int)
                productList.append(product)
            else:
                stoich_int = int(stoich[0])
                product_stoichList.append(stoich_int)
                productList.append(product.replace(stoich[0],''))

        return reactantList, reactant_stoichList, productList, product_stoichList

        Parses the reaction string to return a list of reactants (and products), a list of 
        stoichiometry constants of the reactants (and products)
        
Parses the reaction string to return a list of reactants (and products), a list of
stoichiometry constants of the reactants (and products)
Parses the reaction string to return a list of reactants ( and products ) a list of stoichiometry constants of the reactants ( and products )
def parseReactionString(self, rStr):
        rxn = self.getReaction()
        if '-->' in rStr:
            rReversible = False
        elif '<->' in  rStr:
            rReversible = True
        check(rxn.setReversible(rReversible), 'set r_obj reversible')
        if not rxn.isSetReversible():
           raise SyntaxError('Reaction reversible attribute is not set.')
        rStr = rStr.replace(' ', '')
        if rxn.getReversible():
            s_rxn = rStr.split('<->')
        else:
            s_rxn = rStr.split('-->')
        if len(s_rxn) != 2:
            raise SyntaxError('Reaction string should have one arrow only')
        s_reac = s_rxn[0]
        s_pro = s_rxn[1]
        reactants = s_reac.split('+')
        products = s_pro.split('+')
        reactant_stoichList = []
        reactantList = []
        for reactant in reactants:
            stoich = re.findall(r'\d+',reactant)
            if len(stoich) > 1:
                raise SyntaxError('Reaction string syntax not correct')
            if stoich == []:
                stoich_int = 1
                reactant_stoichList.append(stoich_int)
                reactantList.append(reactant)
            else:
                stoich_int = int(stoich[0])
                reactant_stoichList.append(stoich_int)
                reactantList.append(reactant.replace(stoich[0],''))
        product_stoichList = []
        productList = []
        for product in products:
            stoich = re.findall(r'\d+',product)
            if len(stoich) > 1:
                raise SyntaxError('Reaction string syntax not correct')
            if stoich == []:
                stoich_int = 1
                product_stoichList.append(stoich_int)
                productList.append(product)
            else:
                stoich_int = int(stoich[0])
                product_stoichList.append(stoich_int)
                productList.append(product.replace(stoich[0],''))
        return reactantList, reactant_stoichList, productList, product_stoichList
def parseReactionString ( self , rStr ) : rxn = self . getReaction ( ) if '-->' in rStr : rReversible = False elif '<->' in rStr : rReversible = True check ( rxn . setReversible ( rReversible ) , 'set r_obj reversible' ) if not rxn . isSetReversible ( ) : raise SyntaxError ( 'Reaction reversible attribute is not set.' ) rStr = rStr . replace ( ' ' , '' ) if rxn . getReversible ( ) : s_rxn = rStr . split ( '<->' ) else : s_rxn = rStr . split ( '-->' ) if len ( s_rxn ) != 2 : raise SyntaxError ( 'Reaction string should have one arrow only' ) s_reac = s_rxn [ 0 ] s_pro = s_rxn [ 1 ] reactants = s_reac . split ( '+' ) products = s_pro . split ( '+' ) reactant_stoichList = [ ] reactantList = [ ] for reactant in reactants : stoich = re . findall ( r'\d+' , reactant ) if len ( stoich ) > 1 : raise SyntaxError ( 'Reaction string syntax not correct' ) if stoich == [ ] : stoich_int = 1 reactant_stoichList . append ( stoich_int ) reactantList . append ( reactant ) else : stoich_int = int ( stoich [ 0 ] ) reactant_stoichList . append ( stoich_int ) reactantList . append ( reactant . replace ( stoich [ 0 ] , '' ) ) product_stoichList = [ ] productList = [ ] for product in products : stoich = re . findall ( r'\d+' , product ) if len ( stoich ) > 1 : raise SyntaxError ( 'Reaction string syntax not correct' ) if stoich == [ ] : stoich_int = 1 product_stoichList . append ( stoich_int ) productList . append ( product ) else : stoich_int = int ( stoich [ 0 ] ) product_stoichList . append ( stoich_int ) productList . append ( product . replace ( stoich [ 0 ] , '' ) ) return reactantList , reactant_stoichList , productList , product_stoichList
Parses the reaction string to return a list of reactants (and products), a list of
stoichiometry constants of the reactants (and products)
Parses the reaction string to return a list of reactants ( and products ) a list of stoichiometry constants of the reactants ( and products )
'''
        Parses the reaction string to return a list of reactants (and products), a list of 
        stoichiometry constants of the reactants (and products)
        '''
self
rStr