class EnzymaticReaction(ExpressionReaction): """ Subclass to describe reactions that are catalyzed by an enzyme. """ def __init__(self, enzymes = None, scaled = False, *args, **kwargs): ExpressionReaction.__init__(self, scaled, *args, **kwargs) self.enzymes = DictList() if enzymes: self.add_enzymes(enzymes) def add_enzymes(self, enzymes): """` Method to add the enzymes to the reaction. :param enzymes: iterable of or single Enzyme object :return: """ if not hasattr(enzymes, '__iter__'): enzymes = [enzymes] for e in enzymes: # Avoid duplicates if e.id in self.enzymes: self.enzymes._replace_on_id(e) else: self.enzymes += [e] @property def scaling_factor(self): return self.enzyme.kcat_max * self.enzyme.scaling_factor
class EnzymaticReaction(ExpressionReaction): """ Subclass to describe reactions that are catalyzed by an enzyme. """ def __init__(self, enzymes = None, scaled = False, *args, **kwargs): ExpressionReaction.__init__(self, scaled, *args, **kwargs) self.enzymes = DictList() if enzymes: self.add_enzymes(enzymes) @classmethod def from_reaction(cls,reaction, gene_id = None, enzymes = None, scaled=False): """ This method clones a cobra.Reaction object into a transcription reaction, and attaches enzymes to it :param reaction: the reaction to reproduce :type reaction: cobra.Reaction :param enzymes: a(n iterable of the) enzyme(s) to be attached to the reaction :return: an EnzymaticReaction object """ if gene_id is not None: # it's a transcription or translation reaction new = cls( id = reaction.id, name= reaction.name, gene_id= gene_id, subsystem= reaction.subsystem, lower_bound= reaction.lower_bound, upper_bound= reaction.upper_bound, enzymes= enzymes, scaled=scaled) else: new = cls( id = reaction.id, name= reaction.name, subsystem= reaction.subsystem, lower_bound= reaction.lower_bound, upper_bound= reaction.upper_bound, enzymes= enzymes, scaled=scaled) new.add_metabolites(reaction.metabolites, rescale = False) new.gene_reaction_rule = reaction.gene_reaction_rule return new def add_enzymes(self, enzymes): """` Method to add the enzymes to the reaction. :param enzymes: iterable of or single Enzyme object :return: """ if not hasattr(enzymes, '__iter__'): enzymes = [enzymes] for e in enzymes: # Avoid duplicates if e.id in self.enzymes: self.enzymes._replace_on_id(e) else: self.enzymes += [e] @property def scaling_factor(self): return self.enzyme.kcat_max * self.enzyme.scaling_factor