Example #1
0
    def check_reaction(self, reaction):
        """ Validate reaction.

        For documentation, read the comments below. Also see
        IsotopeModel.check_reaction.__doc__ for more details.
        """
        # Create label matcher object
        l = self.labels(reaction)
        # Note that the label matcher object is special Python
        # dictionary object that items can be accessed via attributes.
        # Keys are the names of species and values are labeling
        # indices.

        # First, handle transport reactions. Usage of `transport=True`
        # improves performance but, in general, it is not required.
        if l.match('ADPm <=> ADPs', transport=True): return l.ADPm==l.ADPs
        if l.match('Pm <=> Ps', transport=True): return l.Pm==l.Ps
        if l.match('Wo <=> Ws', transport=True): return l.Wo==l.Ws
        if l.match('ATPs => ATPm', transport=True): return l.ATPs==l.ATPm
        if l.match('ATPo => ATPe', transport=True): return l.ATPo==l.ATPe
        if l.match('Pe <=> Po', transport=True): return l.Pe==l.Po
        if l.match('We <=> Wo', transport=True): return l.We==l.Wo
        if l.match('ADPe <=> ADPo', transport=True): return l.ADPe==l.ADPo
        if l.match('ADPi <=> ADPm', transport=True): return l.ADPi==l.ADPm
        if l.match('ADPo <=> ADPi', transport=True): return l.ADPo==l.ADPi
        if l.match('ATPm <=> ATPi', transport=True): return l.ATPm==l.ATPi
        if l.match('ATPi <=> ATPo', transport=True): return l.ATPi==l.ATPo
        if l.match('CPi <=> CPo', transport=True): return l.CPi==l.CPo
        if l.match('Po => Pm', transport=True): return l.Po==l.Pm

        # All of the enzymatic reactions in the model require their
        # own definitions for the atom mappings. The builder splits
        # ATP into two indices because each phosphoryl group is treated
        # separately in the symbolic calculation to aid in simplifying
        # the system.
        if l.match('Ps + ADPs <=> ATPs + Ws'):
            t1, t2 = l.ATPs.split ('_')
            return t1==l.ADPs and (t2+l.Ws).count('1')==l.Ps.count ('1')
        if l.match('Pe + ADPe <=> ATPe + We'):
            t1, t2 = l.ATPe.split ('_')
            return t1==l.ADPe and (t2+l.We).count('1')==l.Pe.count ('1')
        if l.match('CPo + ADPo <=> ATPo'):
            t1, t2 = l.ATPo.split ('_')
            return t1 == l.ADPo and t2==l.CPo
        if l.match('CPi + ADPi <=> ATPi'):
            t1, t2 = l.ATPi.split ('_')
            return t1 == l.ADPi and t2==l.CPi
        # notice that '2 A <=> B' has to be written as 'A + A <=> B'
        if l.match('ADPi + ADPi <=> ATPi'): 
            t1, t2 = l.ATPi.split ('_')
            return t1==l.ADPi[0] and t2==l.ADPi[1]
        if l.match('ADPo + ADPo <=> ATPo'):
            t1, t2 = l.ATPo.split ('_')
            return t1==l.ADPo[0] and t2==l.ADPo[1]

        # Unknown reaction, raise an exception
        return IsotopeModel.check_reaction(self, reaction)
Example #2
0
    def check_reaction(self, reaction):
        """ Validate reaction.

        For documentation, read the comments below. Also see
        IsotopeModel.check_reaction.__doc__ for more details.
        """
        # Create label matcher object
        l = self.labels(reaction)
        # Note that the label matcher object is special Python
        # dictionary object that items can be accessed via attributes.
        # Keys are the names of species and values are labeling
        # indices.

        # First, handle transport reactions. Usage of `transport=True`
        # improves performance but, in general, it is not required.
        if l.match('ADPm <=> ADPs', transport=True): return l.ADPm == l.ADPs
        if l.match('Pm <=> Ps', transport=True): return l.Pm == l.Ps
        if l.match('Wo <=> Ws', transport=True): return l.Wo == l.Ws
        if l.match('ATPs => ATPm', transport=True): return l.ATPs == l.ATPm
        if l.match('ATPo => ATPe', transport=True): return l.ATPo == l.ATPe
        if l.match('Pe <=> Po', transport=True): return l.Pe == l.Po
        if l.match('We <=> Wo', transport=True): return l.We == l.Wo
        if l.match('ADPe <=> ADPo', transport=True): return l.ADPe == l.ADPo
        if l.match('ADPi <=> ADPm', transport=True): return l.ADPi == l.ADPm
        if l.match('ADPo <=> ADPi', transport=True): return l.ADPo == l.ADPi
        if l.match('ATPm <=> ATPi', transport=True): return l.ATPm == l.ATPi
        if l.match('ATPi <=> ATPo', transport=True): return l.ATPi == l.ATPo
        if l.match('CPi <=> CPo', transport=True): return l.CPi == l.CPo
        if l.match('Po => Pm', transport=True): return l.Po == l.Pm

        # All of the enzymatic reactions in the model require their
        # own definitions for the atom mappings. The builder splits
        # ATP into two indices because each phosphoryl group is treated
        # separately in the symbolic calculation to aid in simplifying
        # the system.
        if l.match('Ps + ADPs <=> ATPs + Ws'):
            t1, t2 = l.ATPs.split('_')
            return t1 == l.ADPs and (t2 + l.Ws).count('1') == l.Ps.count('1')
        if l.match('Pe + ADPe <=> ATPe + We'):
            t1, t2 = l.ATPe.split('_')
            return t1 == l.ADPe and (t2 + l.We).count('1') == l.Pe.count('1')
        if l.match('CPo + ADPo <=> ATPo'):
            t1, t2 = l.ATPo.split('_')
            return t1 == l.ADPo and t2 == l.CPo
        if l.match('CPi + ADPi <=> ATPi'):
            t1, t2 = l.ATPi.split('_')
            return t1 == l.ADPi and t2 == l.CPi
        # notice that '2 A <=> B' has to be written as 'A + A <=> B'
        if l.match('ADPi + ADPi <=> ATPi'):
            t1, t2 = l.ATPi.split('_')
            return t1 == l.ADPi[0] and t2 == l.ADPi[1]
        if l.match('ADPo + ADPo <=> ATPo'):
            t1, t2 = l.ATPo.split('_')
            return t1 == l.ADPo[0] and t2 == l.ADPo[1]

        # Unknown reaction, raise an exception
        return IsotopeModel.check_reaction(self, reaction)
Example #3
0
    def check_reaction(self, reaction):
        """ Validate reaction.

        For documentation, read the comments below. Also see
        IsotopeModel.check_reaction.__doc__ for more details.
        """
        # Create label matcher object
        l = self.labels(reaction)

        # Note that the label matcher object is special Python
        # dictionary object that items can be accessed via attributes.
        # Keys are the names of species and values are labeling
        # indices.

        # First, handle transport reactions. Usage of `transport=True`
        # improves performance but, in general, it is not required.
        if l.match('Ai => A', transport=True): return l.Ai==l.A
        if l.match('C => Co', transport=True): return l.C==l.Co
        if l.match('A+B <=> C'): 
            t1,t2 = l.C.split ('_')
            return l.A==t1 and l.B==t2
        # Unknown reaction, raise an exception
        return IsotopeModel.check_reaction(self, reaction)