def add_dummy_reactions(me_model, dna_seq, update=True): """ Add all reactions necessary to produce a dummy reaction catalyzed by "CPLX_dummy". Parameters ---------- me_model : :class:`cobrame.core.model.MEModel` The MEModel object to which the content will be added dna_seq : str DNA sequence of dummy gene. Should be representative of the average codon composition, amino acid composition, length of a gene in the organism being modeled update : bool If True, run update functions on all transcription, translation, complex formation, and metabolic reactions added when constructing dummy reactions. """ dummy = cobrame.StoichiometricData("dummy_reaction", me_model) dummy.lower_bound = 0 dummy.upper_bound = 1000 dummy._stoichiometry = {'CPLX_dummy': -1} create_transcribed_gene(me_model, 'dummy', 'mRNA', dna_seq) add_transcription_reaction(me_model, "RNA_dummy", {"dummy"}, dna_seq) me_model.add_metabolites(cobrame.TranslatedGene("protein_" + "dummy")) add_translation_reaction(me_model, "dummy", dna_sequence=dna_seq, update=update) try: complex_data = cobrame.ComplexData("CPLX_dummy", me_model) except ValueError: warn('CPLX_dummy already in model') complex_data = me_model.process_data.get_by_id('CPLX_dummy') complex_data.stoichiometry = {"protein_dummy": 1} if update: complex_data.create_complex_formation()
def update(self, verbose=True): """ Creates reaction using the associated translation data and adds chemical formula to protein product This function adds the following components to the reaction stoichiometry (using 'data' as shorthand for :class:`cobrame.core.processdata.TranslationData`): 1) Amino acids defined in data.amino_acid_sequence. Subtracting water to account for condensation reactions during polymerization 2) Ribosome w/ translation coupling coefficient (if present) 3) mRNA defined in data.mRNA w/ translation coupling coefficient 4) mRNA + nucleotides + hydrolysis ATP cost w/ degradation coupling coefficient (if kdeg (defined in model.global_info) > 0) 5) RNA_degradosome w/ degradation coupling coefficient (if present and kdeg > 0) 6) Protein product defined in data.protein 7) Subreactions defined in data.subreactions 8) protein_biomass :class:`cobrame.core.component.Constraint` corresponding to the protein product's mass 9) Subtract mRNA_biomass :class:`cobrame.core.component.Constraint` defined by mRNA degradation coupling coefficinet (if kdeg > 0) Parameters ---------- verbose : bool Prints when new metabolites are added to the model when executing update() """ self.clear_metabolites() translation_data = self.translation_data protein_id = translation_data.protein mrna_id = translation_data.mRNA protein_length = len(translation_data.amino_acid_sequence) nucleotide_sequence = translation_data.nucleotide_sequence model = self._model metabolites = self._model.metabolites new_stoichiometry = defaultdict(int) # Set Parameters kt = self._model.global_info['kt'] k_deg = self._model.global_info['k_deg'] r0 = self._model.global_info['r0'] m_rr = self._model.global_info['m_rr'] f_rrna = self._model.global_info['f_rRNA'] m_aa = self._model.global_info['m_aa'] m_nt = self._model.global_info['m_nt'] f_mrna = self._model.global_info['f_mRNA'] c_ribo = m_rr / f_rrna / m_aa c_mrna = m_nt / f_mrna / m_aa # -----------------Add Amino Acids---------------------------------- for aa, value in iteritems(translation_data.amino_acid_count): new_stoichiometry[aa] = -value new_stoichiometry['h2o_c'] += value # Length protein - 1 dehydration reactions new_stoichiometry['h2o_c'] -= 1. # -----------------Add Ribosome Coupling---------------------------- try: ribosome = metabolites.get_by_id("ribosome") except KeyError: warn("ribosome not found") else: k_ribo = mu * c_ribo * kt / (mu + kt * r0) # in hr-1 coupling = -protein_length * mu / k_ribo new_stoichiometry[ribosome.id] = coupling # -------------------Add mRNA Coupling------------------------------ try: transcript = metabolites.get_by_id(mrna_id) except KeyError: # If transcript not found add to the model as the mRNA_id warn("transcript ('%s') not found" % mrna_id) transcript = \ cobrame.TranscribedGene(mrna_id, mrna_id, nucleotide_sequence) model.add_metabolites(transcript) # Calculate coupling constraints for mRNA and degradation k_mrna = mu * c_mrna * kt / (mu + kt * r0) * 3. # 3 nucleotides per AA rna_amount = mu / k_mrna deg_amount = k_deg / k_mrna # Add mRNA coupling to stoichiometry new_stoichiometry[transcript.id] = -(rna_amount + deg_amount) # ---------------Add Degradation Requirements ------------------------- # Add degraded nucleotides to stoichiometry for nucleotide, count in iteritems(transcript.nucleotide_count): new_stoichiometry[nucleotide] += count * deg_amount # ATP hydrolysis required for cleaving nucleotide_length = len(transcript.nucleotide_sequence) # .25 ATP required per nucleotide hydrolysis hydrolysis_amount = (nucleotide_length - 1) / 4. * deg_amount atp_hydrolysis = {'atp_c': -1, 'h2o_c': -1, 'adp_c': 1, 'pi_c': 1, 'h_c': 1} for metabolite, value in iteritems(atp_hydrolysis): new_stoichiometry[metabolite] += hydrolysis_amount * value # Add degradosome coupling, if known try: rna_degradosome = metabolites.get_by_id("RNA_degradosome") except KeyError: warn("RNA_degradosome not found") else: deg_coupling = -deg_amount * mu / 65. / 3600 # keff of degradosome new_stoichiometry[rna_degradosome.id] = deg_coupling # --------------- Add Protein to Stoichiometry ------------------------ # Added protein to model if not already included try: protein = metabolites.get_by_id(protein_id) except KeyError: protein = cobrame.TranslatedGene(protein_id) model.add_metabolites(protein) new_stoichiometry[protein.id] = 1 # ------- Convert ids to metabolites and add to model ----------------- # add subreactions to stoichiometry new_stoichiometry = self.add_subreactions(self.translation_data.id, new_stoichiometry) # convert metabolite ids to cobra metabolites object_stoichiometry = self.get_components_from_ids(new_stoichiometry, verbose=verbose) # add metabolites to reaction self.add_metabolites(object_stoichiometry, combine=False) # -------------Update Element Dictionary and Formula------------------- self._add_formula_to_protein(translation_data, protein) # ------------------ Add biomass constraints -------------------------- # add biomass constraint for protein translated protein_mass = protein.mass # kDa self.add_metabolites({metabolites.protein_biomass: protein_mass}, combine=False) # RNA biomass consumed due to degradation mrna_mass = transcript.mass # kDa self.add_metabolites( {metabolites.mRNA_biomass: (-mrna_mass * deg_amount)}, combine=False)