6.1.2. cobrame.util package

6.1.2.1. Submodules

6.1.2.2. cobrame.util.building module

cobrame.util.building.add_complex_to_model(me_model, complex_id, complex_stoichiometry, complex_modifications=None)[source]

Adds ComplexData to the model for a given complex.

Parameters:
  • me_model (cobrame.core.model.MEModel) –
  • complex_id (str) – ID of the complex and thus the model ComplexData
  • complex_stoichiometry (dict) – {complex_id: {protein_<locus_tag>: stoichiometry}}
  • complex_modifications (dict) – {subreaction_id: stoichiometry}
cobrame.util.building.add_dummy_reactions(me_model, dna_seq, update=True)[source]

Add all reactions necessary to produce a dummy reaction catalyzed by “CPLX_dummy”.

Parameters:
  • me_model (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.
cobrame.util.building.add_m_model_content(me_model, m_model, complex_metabolite_ids=None)[source]

Add metabolite and reaction attributes to me_model from m_model. Also creates StoichiometricData objects for each reaction in m_model, and adds reactions directly to me_model if they are exchanges or demands.

Parameters:
  • me_model (cobrame.core.model.MEModel) – The MEModel object to which the content will be added
  • m_model (cobra.core.model.Model) – The m_model which will act as the source of metabolic content for MEModel
  • complex_metabolite_ids (list) – List of complexes which are ‘metabolites’ in the m-model reaction matrix, but should be treated as complexes
cobrame.util.building.add_metabolic_reaction_to_model(me_model, stoichiometric_data_id, directionality, complex_id=None, spontaneous=False, update=False, keff=65)[source]

Creates and add a MetabolicReaction to a MEModel.

Parameters:
  • me_model (cobrame.core.model.MEModel) – MEModel that the MetabolicReaction will be added to
  • stoichiometric_data_id (str) – ID of the StoichiometricData for the reaction being added
  • directionality (str) –
    • Forward: Add reaction that occurs in the forward direction
    • Reverse: Add reaction that occurs in the reverse direction
  • complex_id (str or None) – ID of the ComplexData for the enzyme that catalyze the reaction being added.
  • spontaneous (bool) –
    • If True and complex_id=’’ add reaction as spontaneous reaction
    • If False and complex_id=’’ add reaction as orphan (CPLX_dummy catalyzed)
cobrame.util.building.add_model_complexes(me_model, complex_stoichiometry_dict, complex_modification_dict, verbose=True)[source]

Construct ComplexData for complexes into MEModel from its subunit stoichiometry, and a dictionary of its modification metabolites.

It is assumed that each modification adds one equivalent of the modification metabolite. Multiple

Intended to be used as a function for large-scale complex addition.

For adding individual ComplexData objects, use add_complex_to_model

Parameters:
  • me_model (cobrame.core.model.MEModel) –
  • complex_stoichiometry_dict (dict) – {unmodified_complex_id: {protein_<locus_tag>: stoichiometry}}
  • complex_modification_dict (dict) –
    {modified_complex_id:{core_enzyme: unmodified_complex_id,
    ’modifications: {mod_metabolite: stoichiometry}}}
cobrame.util.building.add_reactions_from_stoichiometric_data(me_model, rxn_to_cplx_dict, rxn_info_frame, update=False, keff=65)[source]

Creates and adds MetabolicReaction for all StoichiometricData in model.

Intended for use when adding all reactions from stoichiometric data for the first time.

For adding an individual reaction use add_metabolic_reaction_to_model()

Parameters:
  • me_model (cobrame.core.model.MEModel) – MEModel that the MetabolicReaction will be added to
  • rxn_to_cplx_dict (dict) – {StoichiometricData.id: catalytic_enzyme_id}
  • rxn_info_frame (pandas.Dataframe) – Contains the ids, names and reversibility for each reaction in the metabolic reaction matrix as well as whether the reaction is spontaneous
cobrame.util.building.add_subreaction_data(me_model, modification_id, modification_stoichiometry, modification_enzyme=None, verbose=True)[source]

Creates a SubreactionData object for each modification defined by the function inputs.

It’s assumed every complex modification occurs spontaneously, unless a modification_enzyme argument is passed.

If a modification uses an enzyme this can be updated after the SubreactionData object is already created

Parameters:me_model (cobrame.core.model.MEModel) –
cobrame.util.building.add_transcription_reaction(me_model, tu_name, locus_ids, sequence, update=True)[source]

Create TranscriptionReaction object and add it to ME-Model. This includes the necessary transcription data.

Parameters:
  • me_model (cobrame.core.model.MEModel) – The MEModel object to which the reaction will be added
  • tu_name (str) – ID of TU being transcribed. The TranscriptionReaction will be added as “transcription_+TU_name” The TranscriptionData will be added as just “TU_name”
  • locus_ids (set) – Set of locus IDs that the TU transcribes
  • sequence (str) – Nucleotide sequence of the TU.
  • update (bool) – If True, use TranscriptionReaction’s update function to update and add reaction stoichiometry
Returns:

TranscriptionReaction for the TU

Return type:

cobrame.core.reaction.TranscriptionReaction

cobrame.util.building.add_translation_reaction(me_model, locus_id, dna_sequence, update=False)[source]

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 (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
cobrame.util.building.build_reactions_from_genbank(me_model, gb_filename, tu_frame=None, element_types=set(['tRNA', 'ncRNA', 'rRNA', 'CDS']), verbose=True, frameshift_dict=None, trna_to_codon=None, update=True)[source]
Creates and adds transcription and translation reactions using genomic
information from the organism’s genbank file. Adds in the basic requirements for these reactions. Organism specific components are added …
Parameters:
  • me_model (cobrame.core.model.MEModel) – The MEModel object to which the reaction will be added
  • gb_filename (str) – Local name of the genbank file that will be used for ME-model construction
  • tu_frame (pandas.DataFrame) –

    DataFrame with indexes of the transcription unit name and columns containing the transcription unit starting and stopping location on the genome and whether the transcription unit is found on the main (+) strand or complementary (-) strand.

    If no transcription unit DataFrame is passed into the function, transcription units are added corresponding to each transcribed gene in the genbank file.

  • element_types (set) – Transcription reactions will be added to the ME-model for all RNA feature.types in this set. This uses the nomenclature of the genbank file (gb_filename)
  • verbose (bool) – If True, display metabolites that were not previously added to the model and were thus added when creating charging reactions
  • frameshift_dict (dict) –

    {locus_id: genome_position_of_TU}

    If a locus_id is in the frameshift_dict, update it’s nucleotide sequence to account of the frameshift

cobrame.util.building.convert_aa_codes_and_add_charging(me_model, trna_aa, trna_to_codon, verbose=True)[source]

Adds tRNA charging reactions for all tRNAs in ME-model

Parameters:
  • me_model (cobra.core.model.MEModel) – The MEModel object to which the reaction will be added
  • trna_aa (dict) –

    Dictionary of tRNA locus ID to 3 letter codes of the amino acid that the tRNA contributes

    {tRNA identifier (locus_id): amino_acid_3_letter_code}

  • trna_to_codon (dict) –

    Dictionary of tRNA identifier to the codon which it associates

    {tRNA identifier (locus_id): codon_sequence}

  • verbose (bool) – If True, display metabolites that were not previously added to the model and were thus added when creating charging reactions
cobrame.util.building.create_transcribed_gene(me_model, locus_id, rna_type, seq, left_pos=None, right_pos=None, strand=None)[source]
Creates a TranscribedGene metabolite object and adds it to the ME-model
Parameters:
  • me_model (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:

Metabolite object for the RNA product

Return type:

cobrame.core.component.TranscribedGene

6.1.2.3. cobrame.util.dogma module

cobrame.util.dogma.extract_sequence(full_seq, left_pos, right_pos, strand)[source]
cobrame.util.dogma.get_amino_acid_sequence_from_dna(dna_seq)[source]
cobrame.util.dogma.return_frameshift_sequence(full_seq, frameshift_string)[source]
cobrame.util.dogma.reverse_transcribe(seq)[source]

6.1.2.4. cobrame.util.mass module

cobrame.util.mass.compute_protein_mass(amino_acid_count)[source]

compute protein mass in kDa from amino acid count

amino_acid_count: {amino_acid: number}

cobrame.util.mass.compute_rna_mass(dna_sequence, excised_bases=None)[source]

compute RNA mass in kDA from nucleotide count

nucleotide_count: {nucleotide: number}

6.1.2.5. cobra.core.massbalance module

cobrame.util.massbalance.check_me_model_mass_balance(model0)[source]
cobrame.util.massbalance.check_transcription_mass_balance(reaction)[source]
cobrame.util.massbalance.elements_to_formula(obj, elements)[source]
cobrame.util.massbalance.eval_reaction_at_growth_rate(reaction, growth_rate)[source]
cobrame.util.massbalance.get_elements_from_process_data(reaction, process_data, elements)[source]

If a modification is required to form a functioning macromolecule, update the element dictionary accordingly.

cobrame.util.massbalance.stringify(element, number)[source]

6.1.2.6. Module contents