Exemple #1
0
def create_transcribed_gene(me_model,
                            locus_id,
                            rna_type,
                            seq,
                            left_pos=None,
                            right_pos=None,
                            strand=None):
    """
     Creates a `TranscribedGene` metabolite object and adds it to the ME-model

    Parameters
    ----------
    me_model : :class:`cobrame.core.model.MEModel`
        The MEModel object to which the reaction will be added

    locus_id : str
        Locus ID of RNA product.
        The TranscribedGene will be added as "RNA + _ + locus_id"

    left_pos : int or None
        Left position of gene on the sequence of the (+) strain

    right_pos : int or None
        Right position of gene on the sequence of the (+) strain

    seq : str
        Nucleotide sequence of RNA product.
        Amino acid sequence, codon counts, etc. will be calculated based on
        this string.

    strand : str or None
        - (+) if the RNA product is on the leading strand
        - (-) if the RNA product is on the complementary strand

    rna_type : str
        Type of RNA of the product.
        tRNA, rRNA, or mRNA
        Used for determining how RNA product will be processed.

    Returns
    -------
        :class:`cobrame.core.component.TranscribedGene`
            Metabolite object for the RNA product
    """
    gene = cobrame.TranscribedGene('RNA_' + locus_id, rna_type, seq)
    gene.left_pos = left_pos
    gene.right_pos = right_pos
    gene.strand = strand

    me_model.add_metabolites([gene])
    return gene
Exemple #2
0
def add_translation_reaction(me_model, locus_id, dna_sequence,
                             update=False):
    """
    Creates and adds a TranslationReaction to the ME-model as well as the
    associated TranslationData

    A dna_sequence is required in order to add a TranslationReaction to the
    ME-model

    Parameters
    ----------
    me_model : :class:`cobra.core.model.MEModel`
        The MEModel object to which the reaction will be added

    locus_id : str
        Locus ID of RNA product.
        The TranslationReaction will be added as "translation + _ + locus_id"
        The TranslationData will be added as "locus_id"

    dna_sequence : str
        DNA sequence of the RNA product. This string should be reverse
        transcribed if it originates on the complement strand.

    update : bool
        If True, use TranslationReaction's update function to update and
        add reaction stoichiometry

    """

    # Create TranslationData
    translation_data = \
        cobrame.TranslationData(locus_id, me_model, "RNA_" + locus_id,
                                "protein_" + locus_id)
    translation_data.nucleotide_sequence = dna_sequence

    # Add RNA to model if it doesn't exist
    if "RNA_" + locus_id not in me_model.metabolites:
        warn('RNA_%s not present in model. Adding it now.')
        rna = cobrame.TranscribedGene('RNA_' + locus_id, 'mRNA', dna_sequence)
        me_model.add_metabolites(rna)

    # Create and add TranslationReaction with TranslationData
    translation_reaction = \
        cobrame.TranslationReaction("translation_" + locus_id)
    me_model.add_reaction(translation_reaction)
    translation_reaction.translation_data = translation_data

    if update:
        translation_reaction.update()
Exemple #3
0
    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)