Documentation

io

Classes

HiddenPrints

Supress package print messages.

Functions

read_metabolic_model(file_name: str) -> Model

Read a metabolic model from sbml format with .xml extension

Parameters:
  • file_name (str) – 'full/path/to/metabolic_model.xml'

Returns:
  • Model – cobrapy metabolic model

load_metabolic_model(model_file: Union[str, cobra.core.model.Model]) -> Model

Reads in metabolic model, checking for appropriate type.

Parameters:
  • model_file (Union[str, cobra.core.model.Model]) – cobrapy model or 'full/path/to/metabolic_model.xml'

Returns:
  • Model – cobrapy metabolic model

read_psim(psim_file: str, h5_key: Optional[str] = None) -> DataFrame

Read the PSIM from .csv or .h5 format.

Parameters:
  • psim_file (str) – 'full/path/to/psim.csv or psim.h5'

  • h5_key (Optional[str]) – key associated with h5 file, by default None

Returns:
  • DataFrame – see PSIM_README.md

load_psim(psim_file: Union[str, pandas.core.frame.DataFrame], **kwargs) -> DataFrame

Reads in PSIM, checking for appropriate type.

Parameters:
  • psim_file (Union[str, pandas.core.frame.DataFrame]) – the PSIM dataframe or 'full/path/to/psim.csv or psim.h5'

Returns:
  • DataFrame – the PSIM dataframe

read_pickled_object(file_name: str)

Read an object as a pickled file.

Parameters:
  • file_name (str) – 'full/path/to/file.pickle'

Returns:
  • pickled_object – the pickled object

read_pickled_me_model(file_name: str)

Loads a pickled me_model. Saved from me_model.pickle.

Parameters:
  • file_name (str) – 'full/path/to/me_model.pickle'

Returns:
  • ME_Model – ME model object

load_ME_model(model_file)

Reads in ME model, checking for appropriate type.

Parameters:
  • model_file (Union[str, ME_Model]) – ME_Model object or 'full/path/to/me_model.pickle'

Returns:
  • ME_Model – ME_Model object

write_metabolic_model(m_model: Model, file_name: str, **kwargs) -> None

Write a metabolic model to smbl format with .xml extension.

Parameters:
  • m_model (Model) – cobrapy metabolic model

  • file_name (str) – 'full/path/to/metabolic_model.xml'

  • *kwargs* (None) – additional parameters to cobra.io.write_sbml_model

write_pickled_object(object: Any, file_name: str) -> None

Save an object as a pickled file.

Parameters:
  • object (Any) – object to save

  • file_name (str) – 'full/path/to/file.pickle'

write_stoichiometric_matrix(me_model, file_name: str, mu_val: Union[int, float])

Writes the ME Model stoichiometric matrix as a scipy sparse array (.npz), replacing growth rate parameters

with a specific value. Column (reaction IDs) and row (metabolite IDs) are separately written to text files.

Parameters:
  • me_model (_type_) – the me model

  • file_name (str) – name of the file (with full path) to save the stoichiometric matrix to

  • mu_val (Union[int, float]) – growth rate value to replace terms dependent on the parameter with

preprocess special

Modules

correct_inputs

Functions
bool_metabolite(m_id: str, compartment: str, m_model: Model) -> Tuple[bool, cobra.core.metabolite.Metabolite]

Checks if a metabolite is in the model.

Parameters:
  • m_id (str) – the metabolite id, without the "_compartment" at the end

  • compartment (str) – one letter compartment code

  • m_model (Model) – a Cobra Metabolic Model

Returns:
  • Tuple[bool, cobra.core.metabolite.Metabolite] – whether the metabolite in that compartment is present in the model

correct_model(model_file: Union[cobra.core.model.Model, str] = '/data3/hratch/me_analyses_1/inputs/recon2_2.xml', biomass_reaction_id: str = 'biomass_reaction', correct_biomass: bool = False) -> Tuple[cobra.core.model.Model]

Makes necessary changes to cobrapy model, largely based on issues encountered with Recon2.2.

Note that because the ME Model will create a new objective function, the input model's biomass objective function is removed. The returned models cm_1 and cm_2 allow the user to compare corrected metabolic models with intact biomass objective functions with the output ME Model from human_me.build.build_me_model.build_me. We recommend using cm_1 for comparisons.

Parameters:
  • model_file (Union[cobra.core.model.Model, str]) – string must be 'full/path/to/input_model.xml', by default input_local_path + 'recon2_2.xml' (full Recon2.2 model)

  • biomass_reaction (str) – the id of the input metabolic model's biomass reaction

  • correct_biomass (bool) – whether to correct biomass function (see core.biomass.correct_m_biomass for details)

    can usually also be run separately before this function, but need to ensure all biomass objective metabolites are present in the model

Returns:
  • Tuple[cobra.core.model.Model] – Cobra model with GPRs corrected (according to observed problems with Recon2.2 GPRs) and biomass objective intact

check_non_machinery(non_machinery: Optional[Dict[str, List[str]]] = None) -> Dict[str, List[str]]

Runs checks on non-machinery input list. Non-machinery are categorized as any proteins to express in the ME-Model that are not catalyzed in the reaction.

Parameters:
  • non_machinery (Optional[Dict[str, List[str]]]) – keys are HGNC IDs, values are a list of strings, each element of which represents a compartment within the metabolic model for the gene to be expressed, by default None We define machinery as proteins that are utilized in the reaction GPRs. In its current format, it is not possible for a protein to both be machinery and non-machinery

Returns:
  • Dict[str, List[str]] – removes any non-machinery that would not have worked with model

get_status(psim_me: DataFrame) -> DataFrame

Checks sequence columns for validity.

correct_psim(me_input_model: Union[cobra.core.model.Model, str], psim_df: Union[pandas.core.frame.DataFrame, str] = '/data3/hratch/me_analyses_1/build/psim_gold.h5', fill_na: str = 'default', non_machinery: Optional[Dict[str, List[str]]] = None)

Makes sure PSIM has all necessary correct information to build ME Model.

Note, the default psim_file, build/psim_gold.h5, is a PSIM generated from MANE/RefSeq Select isoforms. We refer to this as the gold standard "psim_gold".

Parameters:
  • me_input_model (Union[cobra.core.model.Model, str]) – Cobra model with GPRs corrected, metabolite transport reactions needed for ME Model incorporated, and removed biomass objective. Used as input to building the ME Model. Output of correct_model function. Can be 'full/path/to/corrected_model.xml'

  • psim_df (Union[pandas.core.frame.DataFrame, str]) – See PSIM_README for details on format of psim, by default build_local_path +'psim_gold.h5' (gold-standard PSIM)

  • fill_na (str) – options ['default', 'select'], by default 'default' if default: will fill incomplete values with default values (see PSIM_README for details) if select: will fill incomplete values with the gold standard PSIM when available, otherwise with default

    Note: this will not deal with user-provided incorrect values for optional columns, those will revert to default in the GeneInformation class

    Exceptions: for required columns, if incorrect in input psim, will fill with the gold standard PSIM. required columns include *_SEQ and LOCATION for non-machinery if PTR is present in input PSIM and a tissue is specified most often in that column (ignoring NaN), all nan values in that column will default to that tissue if non-machinery do not specify an appropriate LOCATION, will fill with the gold standard PSIM

  • non_machinery (Optional[Dict[str, List[str]]]) – keys are HGNC IDs, values are a list of strings, each element of which represents a compartment within the metabolic model for the gene to be expressed, by default None We define machinery as proteins that are utilized in the reaction GPRs. In its current format, it is not possible for a protein to both be machinery and non-machinery

Returns:
  • pd.DataFrame – corrected version of input PSIM

format_exchanges(m_model)

Formats typical exchange reactions (transport across ECM) as those in recon2.2 (LPAREN_e_RPAREN_, transport across boundary)

for the input metabolic model.

Parameters:
  • m_model (cobra Model) – model to format

parse_complex

Functions
eval_complex_recur_full(expr)

Recursive parsing of gprs into lists of complexes. Input expr is a cobra.parse_gpr(gpr_string),

output is a list of lists, each entry of which is a complex joined by 'AND'; netsted lists are joined with each other by 'OR'.

Inspired by corda source code.

eval_complex(expr: str) -> List[Union[str, List[str]]]

Parse reaction GPRs into separate complexes.

Parameters:
  • expr (str) – a reaction GPR

Returns:
  • List[Union[str, List[str]]] – list of complexes according to GPR, separate lists are due to OR

core special

Modules

biomass

Classes
Biomass (Metabolite)

An object of type Biomass inherited from cobra.Metabolite

Functions
create_total_protein_formation(unmodeled_protein_fraction: float = 0) -> BiomassReaction

Total protein biomass formed from the modeled and unmodeled protein biomass in proportional amounts.

Parameters:
  • unmodeled_protein_fraction (float) – the fraction of the total proteome that is not accounted for by the ME Model, by default 0 value must lie [0,1] Note: default value of 0 is for current version, making the unmodeled protein fraction unimplemented. in future iterations we expect to set to some real value

Returns:
  • BiomassReaction – the reaction object for formation of total protein

create_constant_component_formation(model_metabolites, mass_fraction: Dict[str, float] = {'DNA': 0.014, 'carbohydrate': 0.071, 'lipid': 0.097, 'other': 0.054}, biomass_coefficients: Dict = {'DNA': {'datp_n': -0.941642857142857, 'dctp_n': -0.674428571428572, 'dgtp_n': -0.707, 'dttp_n': -0.935071428571429, 'ppi_n': 3.2581428571428583}, 'carbohydrate': {'g6p_c': -3.87591549295775}, 'lipid': {'chsterol_c': -0.09580101814936463, 'clpn_hs_c': -0.05474478062767954, 'pail_hs_c': -0.10948486535720975, 'pchol_hs_c': -0.7253284281824849, 'pe_hs_c': -0.26003066413425396, 'pglyc_hs_c': -0.01368384720784515, 'sphmyln_hs_c': -0.08211247504336976, 'ps_hs_c': -0.02737239031383982}, 'other': None})

Generations formation of biomass components for components that have constant mass (i.e., DNA, lipids, carbohydrates, and other, but not RNA/protein).

Parameters:
  • model_metabolites (_type_) – description

  • mass_fraction (Dict[str, float]) – the mass fraction of the constant biomass components, by default see utils.parameters.biomass_parameters.mass_fraction

  • biomass_coefficients (Dict) – the biomass component formation metabolite coefficients from the metabolic model that will be scaled by the mass fraction, by default see utils.parameters.biomass_parameters.coefficients

Returns:
  • List[BiomassReaction] – all biomass reactions

add_biomass_change(reaction: Reaction, inplace: bool = True) -> Union[NoneType, Dict[str, float]]

Calculate net biomass change in a reaction.

Parameters:
  • reaction (Reaction) – reaction uponw which to calculate biomass change

  • inplace (bool) – whether to modify the reaction (True) or return a dictionary representation of th new reaction.metabolites, by default True

Returns:
  • Union[NoneType, Dict[str, float]] – if inplace is True, updates the input reaction

check_m_biomass(m_model: Model, biomass_reaction_id: str = 'biomass_reaction', tol: float = 10, *args, **kwargs)

Performs sanity checks on biomass objective of metabolic model.

If using Recon2.2 biomass formulation, this will give warnings. If warnings are given, we recommend using our correct_m_biomass function.

Parameters:
  • m_model (Model) – the metabolic model to check. *Expect biomass formatting to be consistent with Recon2.2 (especially with regards to reaction and metabolite IDs). This means that the final biomass reaction must not consist of different biomass types, and each biomass type must have its own formation reaction consisting of specific metabolic substrates.

  • biomass_reaction_id (str) – character ID for biomass reaction

  • tol (float) – tolerance with which to check biomass component reaction mass balance

  • *args** (list) – passed to numpy.isclose

  • *kwargs* (dict) – passed to numpy.isclose

correct_m_biomass(m_model: Model)

Sets biomass objective to the default one that is used by ME Model.

Will correct any mass balance issues in the biomass objective (these mass balance issues are present in Recon2.2).

Parameters:
  • m_model (Model) – the metabolic model to correct

Returns:
  • cobra.Model – the corrected metabolic model

check_me_biomass(me_model) -> Dict[str, float]

Sanity chack that the ME Model biomass component formation reactions for DNA, lipid, and carbohydrate are formulated correctly.

This is done by checking mass balance -- that the metabolites sum(stoichiometric coefficient * metabolic weight) = mass fraction

Parameters:
  • me_model (None) – the generated ME Model

Returns:
  • Dict[str, float] – expected mass fractions based on the implemented biomass formation reactions in the ME Model

gene

Classes
ExpressedGene

Tracks all reactions and macromolecules associated with a ME Model gene.Designed to be used after building the full ME_Model.

Methods
add_reaction(self, r: Union[human_me.core.reaction.MetabolicReaction, human_me.core.reaction.ExpressionReaction])

Organizes ME_Model reaction into self.reactions attribute.

Parameters:
  • r (Union[human_me.core.reaction.MetabolicReaction, human_me.core.reaction.ExpressionReaction]) – the reaction to add

is_catalyzing(self, r) -> bool

Determines whether the gene is involved in catalysis of the reaction.

Parameters:
  • r (ME_Reaction) – [description]

Returns:
  • bool – True if the gene is involved in catalyzing the reaction, False otherwise

add_macromolecule(self, m)

Updates self.macromolecules with m.

Parameters:
  • m (Macromolecule) – the macromolecule to add

check(self)

Checks for completeness of self.reactions and self.macromolecules after adding all associated objects.

macromolecules special

Modules
RNA
Classes
RNA (Macromolecule)
Methods
get_base_counts_and_elements(self)

Updates RNA metabolite to have appropriate formula according to sequence.

synthesize(self, id_: str) -> ExpressionReaction

Generates a reaction for transcription of an RNA molecule (NTPs-->RNA).

Parameters:
  • id_ (str) – reaction id

Returns:
  • ExpressionReaction – a transcription reaction

exonucleolytic_degradation(self, reaction_name: str, balanced: bool = True, update: bool = False) -> ExpressionReaction

Generates a reaction for exonucleolytic cleavage of an RNA molecule (RNA-->NMPs).

Parameters:
  • reaction_name (str) – the reaction name

  • balanced (bool) – check reaction mass balance (True) or not (False), by default True

  • update (bool) – update degradation reaction with subsystem and machinery (True), by default False

Returns:
  • ExpressionReaction – RNA degradation reaction (no GPRs or subsystems added to reaction)

update_metabolite(self, seq: str, append: bool = False, append_to: Optional[str] = None)

Updates the RNA metabolite information according to an input sequence string.

Parameters:
  • seq (str) – rna sequence to update RNA with

  • append (bool) – whether seq is being added (True) or removed (False) from RNA, by default False

  • append_to (Optional[str]) – whether to update 5' or 3' end of sequence, by default None

copy(self)

Overwrite cobra.Species.copy.

pre_mRNA (RNA)

premRNA macromolecule object representation.

mRNA (RNA)

mRNA macromolecule object representation.

Methods
make_proxy(self)

Makes a proxy metabolite for coupling mRNA degradation to protein synthesis.

tRNA (RNA)

tRNA macromolecule object representation.

rRNA (RNA)

rRNA macromolecule object representation.

RNA_fragment (RNA)

object representation of fragmented RNA such as lariats and other excised sequences.

complex
Classes
Complex (Macromolecule)

Complexes formed by non-covalent interactions between macromolecules.

Methods
update_id(self, new_id: Optional[str] = None)

In cases where complex id is too long (see build_me_model generate_complex_reactions method).

form_complex(self, reaction_id: Optional[str] = None, reversible: bool = False, synthesis: bool = True, synthesis_type: str = 'complex') -> ExpressionReaction

The reaction to generate the Complex object.

Note: assumes non-covalent complex formation (in terms of elemental balance)

Parameters:
  • reaction_id (Optional[str]) – reaction identifier, by default None

  • reversible (bool) – Whether the reaction is reversible, by default False Setting to True may make model more efficient (allows reuse of self.components if involved in other reactions)

  • synthesis (bool) – whether the reaction represents the "main" synthesis/production for the macromolecule (used for appropriate mapping of coupling) intended for use with genes (reactions with an associated hgnc id, and complexes), by default True

  • synthesis_type (str) – [description], by default 'complex'

Returns:
  • ExpressionReaction – the complex formation between metabolites stored in self.components

decompose_complex(self, decomposed_complex = None) -> OrderedDict

Recursive method to get the complex by its individual components, including nested complexes.

get_complex_biomass(self) -> Dict[str, float]

Returns a dictionary of the complex biomass by its individual component types.

change_compartment(self, new_compartment: str)

Returns a copy of the complex metabolite, but in new compartment.

make_proxy(self)

Make a proxy metabolite for coupling enzyme degradation to reaction catalysis.

copy(self, copy_metabolites = False)

Overwrite cobra.Species.copy.

Parameters:
  • copy_metabolites (bool) – whether to copy the individual complex subunits, or retain the same pointer, by default False set to True if will be modifying the individual complex subunits in just this complex, but not others

Returns:
  • _type_description

RibosomalComplex (Complex)

Complexes specifically associated with ribosome biogenesis, which has RNA-protein complexes and multiple compartments.

Methods
decompose_complex(self, decomposed_complex = None)

Recursive method to get the complex by its individual components, including nested complexes.

form_complex(self, reaction_id: Optional[str] = None, reversible: bool = False, synthesis: bool = False, synthesis_type: Optional[str] = None) -> ExpressionReaction

The reaction to generate the Complex object.

Note: assumes non-covalent complex formation (in terms of elemental balance)

Parameters:
  • reaction_id (Optional[str]) – reaction identifier, by default None

  • reversible (bool) – Whether the reaction is reversible, by default False Setting to True may make model more efficient (allows reuse of self.components if involved in other reactions)

  • synthesis (bool) – whether the reaction represents the "main" synthesis/production for the macromolecule (used for appropriate mapping of coupling) intended for use with genes (reactions with an associated hgnc id, and complexes), by default False

  • synthesis_type (Optional[str]) – [description], by default None

Returns:
  • ExpressionReaction – the complex formation between metabolites stored in self.components

Functions
add_complex_metabolites(cplx: Complex, met_to_add: Dict[human_me.core.macromolecules.macromolecule.Macromolecule, int], complex_id: str) -> Complex

Add a metabolite to an existing complex object, returning it as a new complex.

Parameters:
  • cplx (Complex) – The Complex object to be appended

  • met_to_add (Dict[human_me.core.macromolecules.macromolecule.Macromolecule, int]) – The metabolites to add to the complex. Keys are the macromolecules and values are the number of copies to add.

  • complex_id (str) – The new id for the new complex

Returns:
  • Complex – The new Complex object with the added metabolites

macromolecule
Classes
Macromolecule (Metabolite)
Methods
change_compartment(self, new_compartment: str)

Create a macromolecule the same as self, but in a different compartment.

Parameters:
  • new_compartment (str) – one-letter code of compartment to change to

Returns:
  • Macromolecule – a copy of the macromolecule in the new compartment

couple(self, type: str, value: SupportsFloat)

Stores coupling information for macromolecule.

Parameters:
  • type (str) – the type of reaction this macromolecule is coupled to

  • value (SupportsFloat) – the coupling coefficient value

Returns:
  • Dict[str, Union[SupportsFloat, sympy.Expr]] – dictionary of length one, key is the type, value is the coupling coefficient

Proxy (Macromolecule)

Proxy macromolecules for c2/c4 coupling of degradation.

Methods
couple(self, value: SupportsFloat)

Stores coupling information for proxy.

Parameters:
  • value (SupportsFloat) – the coupling coefficient value

Returns:
  • Dict[str, Union[SupportsFloat, sympy.Expr]] – dictionary of length one, key is the type, value is the coupling coefficient

protein
Classes
Protein (Macromolecule)

Protein macromolecule object representation.

Methods
make_proxy(self)

Make a proxy metabolite for coupling enzyme degradation to reaction catalysis.

copy(self)

Overwrite cobra.Species.copy.

model

Classes
ME_Model (Model)

ME_Model class analogous to cobrapy.model class

Methods
add_reactions(self, reaction_list: List[cobra.core.reaction.Reaction])

Add reactions to the model

Parameters:
  • reaction_list (List[cobra.core.reaction.Reaction]) – List of reactions to add

remove_reactions(self, reactions: List[Union[cobra.core.reaction.Reaction, str]], remove_orphans: bool = True)

Remove reactions from the model.

Parameters:
  • reactions (List[Union[cobra.core.reaction.Reaction, str]]) – A list with reactions (cobra.Reaction), or their id's, to remove

  • remove_orphans (bool) – Remove orphaned genes and metabolites from the model as well, , by default True

create_stoichiometric_matrix(self, array_type: str = 'numpy', mu_val: Optional[SupportsFloat] = None, inplace: bool = True)

Generate a stoichiometric array representation of the model.

Adapted from cobra.util.array.create_stoichiometric_matrix to handle sympy.Expr objects.

Parameters:
  • array_type (str) – Specifies the type of the stoichiometric matrix to be return (options ['numpy', 'pandas', 'sympy']), by default 'numpy'

  • mu_val (Optional[SupportsFloat]) – A value for mu to replace in generating stoichiometric matrix. If None, will use sympy expressions, by default None

  • inplace (bool) – whether to update self.S (True) or return a new array (False), by default True

Returns:
  • Union[pd.DataFrame, np.array, sympy.matrices.dense.MutableDenseMatrix] – The the columns represent the reactions and rows represent metabolites. S[i,j] therefore contains the quantity of metabolite i produced (negative for consumed) by reaction j.

replace_mu(self, mu_val)

Replaces reaction bounds and stoichiometric coefficients that are a function of

growth rate with a specific growth rate value. Done inplace.

initialize_solver(self, solver_type: str = 'qminos')

Initialize the ME Model solver.

solver_type : str The solver to use for the linear programs (options ['qminos']), by default "qminos"

solve_lp(self, mu_val: SupportsFloat, objective: Optional[Dict[str, int]] = None, tolerance: SupportsFloat = 0, additional_equality_constraints: List[Dict[SupportsFloat, Dict[str, SupportsFloat]]] = None, **kwargs) -> Tuple[<built-in function array>, int]

Solves the linear program for a specified objective at a specified growth rate.

Parameters:
  • mu_val (SupportsFloat) – The growth value for which to solve the linear program [hr^-1]

  • objective (Optional[Dict[str, int]]) – The objective function to optimize. Dictionary represent a linear combination of reactions to optimize, with reaction ids as keys and the coefficient of the linear combination as the values. Values must either be 1 for maximization or -1 for minimization, by default {'biomass_dilution': 1}

  • tolerance (SupportsFloat) – Threshold below which expected sensitivity of solver is too low to detect infeasibility, by default 0

  • additional_equality_constraints (List[Dict[SupportsFloat, Dict[str, SupportsFloat]]]) – Further linear equality constraints to add to the LP, by default None For example, if we set additional_equality_constraints = [{4: {'A': 3, 'B': 5}}, {10: {'C': 1}}], this tells the LP that the flux through reaction A and B must meet the following: 3v_A + 5v_B = 4 and that the flux through reaction C must be the following: 1*v_C = 10

  • *kwargs* – keyword arguments for QMINOS.solvelp method

Returns:
  • Tuple[<built-in function array>, int] – 1D vector of fluxes in the optimal solution

maximize_growth(self, min_mu: SupportsFloat = 0, max_mu: SupportsFloat = 0.05, mu_accuracy: SupportsFloat = 1e-10, increment: SupportsFloat = 0.02, tolerance: SupportsFloat = 0, verbose: bool = True, additional_equality_constraints: List[Dict[SupportsFloat, Dict[str, SupportsFloat]]] = None, **kwargs)

Binary search to find the maximum feasible growth rate.

Parameters:
  • me_model (human_me.core.model.ME_Model) – ME Model to solve

  • min_mu (SupportsFloat) – Expected minimum feasible growth rate, by default 0

  • max_mu (SupportsFloat) – Expected minimum infeasible growth rate (i.e., just above expected maximum feasible growth rate), by default 0.05

  • mu_accuracy (SupportsFloat) – The maximum error in mu after the binary search, by default 1e-10

  • increment (SupportsFloat) – The amount to increase growth by when searching for maximum infeasible growth rate from max_mu, by default 0.02

  • tolerance (SupportsFloat) – Threshold below which expected sensitivity of solver is too low to detect infeasibility, by default 0

  • verbose (bool) – Prints information about each linear program iteration, by default True

  • *kwargs* – keyword arguments for QMINOS.solvelp method

Returns:
  • int – the maximum feasible growth value (in hours)

optimize(self, objective: Dict[str, int], mu_max: SupportsFloat, n_points: Union[int, list] = 10, tolerance: SupportsFloat = 0, visualize: bool = True, fig_name: str = None, additional_equality_constraints: List[Dict[SupportsFloat, Dict[str, SupportsFloat]]] = None, **kwargs)

General optimization of any non-growth objective.

Parameters:
  • objective (Dict[str, int]) – The objective function to optimize. Dictionary represent a linear combination of reactions to optimize, with reaction ids as keys and the coefficient of the linear combination as the values. Values must either be 1 for maximization or -1 for minimization.

  • mu_max (SupportsFloat) – the maximum growth value at which the model is feasible [hr^-1]; use .maximize_growth() method to identify (should be <= mu_max output) if using an experimental value, make sure it is feasible using the .solve_lp() method

  • n_points (Union[int, list]) – # of growth values to consider between 0 and mu_max, by default 10 if a list, just uses those values as the growth values (doesn't need mu_max)

  • tolerance (SupportsFloat) – Threshold below which expected sensitivity of solver is too low to detect infeasibility, by default 0

  • visualize (bool) – plot the relationship between growth and the objective function of interest, by default True

  • fig_name (str) – save the plotted figure to 'path/to/filename.ext', by default None

  • *kwargs* – keyword arguments for QMINOS.solvelp method

Returns:
  • Tuple[float] – first element is the growth value at which the non-growth objective is optimized second element is the optimized non-growth objective value

format_solution(self, sln: List[float]) -> DataFrame

Fromats the LP output into a pandas DataFrame to map reaction IDs

Parameters:
  • sln (List[float]) – output of "solve_lp" method

Returns:
  • DataFrame – fluxes output by "solve_lp" method and their corresponding reaction IDs

check_me_mass_balance(self)

Check that all reactions in ME Model are mass balance. Use after self.add_reactions.

check(self)

Check ME Model built correctly.

create_expressed_gene(hgnc_id: str, relat_objects) -> ExpressedGene staticmethod

Create the ExpressedGene objects associated with the reaction.

knock_out_gene(self, hgnc_id: str, inplace: bool = False)

Knocks out a gene by blocking flux through synthesis of the associated mRNA molecule

Parameters:
  • hgnc_id (str) – gene id in HGNC format (HGNC:####); must be present in the model

  • inplace (bool) – whether to return a separate model object with the knocked out reaction (False) or to change the reaction bounds in change, by default False

pickle(self, file_name: str = '/home/hratch/Projects/human_me/me_model.pickle')

Save ME_Model as a pickled object

Parameters:
  • file_name (str) – will save to file = "full/path/to/filename.pickle", default './me_model.pickle'

load_pickled_model(file_name: str) staticmethod

Loads a pickled me_model. Saved from me_model.pickle.

Parameters:
  • file_name (str) – 'full/path/to/me_model.pickle'

Returns:
  • ME_Model – ME model object

copy(self)

Provides a partial 'deepcopy' of the Model. All of the Metabolite,

Gene, and Reaction objects are created anew but in a faster fashion than deepcopy

reaction

Classes
ME_Reaction (Reaction)

Allows stochiometric coefficient to be a function of mu.

Attributes
reactants property readonly

Return a list of reactants for the reaction.

products property readonly

Return a list of products for the reaction.

Methods
copy(self)

Overwrite cobra.Species copy method.

Returns:
  • ME_Reaction – a copy of the reaction

couple(self, metabolites, types: Union[List[str], str])

Add coupling coefficient and associated metadata to reaction for a coupled metabolite.

Parameters:
  • metabolites (Union[List[Macromolecule], Macromolecule]) – macromolecules with an associated coupling coefficient

  • types (Union[List[str], str]) – the type of reactions that are being coupled (one of ['mrna_degradation', 'mrna_formation', 'catalysis', 'enzyme_degradation'])

build_reaction_string(self, use_metabolite_names: bool = False)

Generate a human readable reaction string.

check_mass_balance(self, tol: SupportsFloat = 0, sympy_tol: SupportsFloat = 1e-15) -> Dict[str, float]

Compute mass and charge balance for the reaction.

Parameters:
  • tol (SupportsFloat) – precision tolerance for categorizing an element as unbalanced, by default 0

  • sympy_tol (SupportsFloat) – sympy.Expr conversions may result in some error, account for this when getting rid of the coupling coefficient value, by default 1e-15

Returns:
  • Dict[str, float] – dict of {element: amount} for unbalanced elements. "charge" is treated as an element in this dict. This should be empty for balanced reactions.

replace_coefficient_mu(self, mu_val: SupportsFloat, inplace: bool = True)

Replace mu coefficients with an actual value.

Parameters:
  • mu_val (SupportsFloat) – value to replace mu with

  • inplace (bool) – whether to update value in place or return a copy of the reaction with updated value (False), by default True

MetabolicReaction (ME_Reaction)

Inherited from ME_Reaction, specifies the metabolic reactions in the model.

ExpressionReaction (ME_Reaction)

Inherited from ME_Reaction, specifies the expression reactions in the model.

ProteinExpressionReaction (ExpressionReaction)

Inherited from ExpressionReaction, specifies the protein expression reactions in the model.

ProteinDegradationReaction (ExpressionReaction)
Methods
copy(self)

Also couple ._macromolecules.

ComplexDegradationReaction (ExpressionReaction)
Methods
copy(self)

Also couple ._macromolecules.

BiomassReaction (Reaction)

Specifies biomass reactions in the model, allowing reaction bounds to be a function of mu.

Attributes
reversibility: bool property readonly

Whether the reaction can proceed in both directions (reversible). This is computed from the current upper and lower bounds.

Methods
replace_bound_mu(self, mu_val: SupportsFloat = 1, values: Optional[List[sympy.core.expr.Expr]] = None, inplace: bool = False, _ub: bool = True)

Gives numeric values to bounds. Assums growth is always > 0.

Parameters:
  • mu_val (SupportsFloat) – The value for mu to replace the bounds that contain a mu expression with, by default 1

  • values (Optional[List[sympy.core.expr.Expr]]) – Each entry is an expression containing mu to be replaced by mu_val; inplace must be False, by default None

  • inplace (bool) – Whether to replace the bounds inplace on the reaction object (True), or return the bounds, by default False

  • _ub (bool) – internal use, whether to use cobra.Reaction._upper_bound or cobra.Reaction.upper_bound, by default True

build_reaction_string(self, use_metabolite_names: bool = False)

Generate a human readable reaction string.

Functions
to_metabolic_reaction(model_metabolites, reaction: Reaction, id: Optional[str] = None) -> MetabolicReaction

Convert a cobrapy Reaction to a ME_Model MetabolicReaction.

Parameters:
  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • reaction (Reaction) – cobra reaction to be converted

  • id (Optional[str]) – reaction id (defaults to reaction.id), by default None

Returns:
  • MetabolicReaction – Converted reaction

expression special

Modules

build_ribosome_biogenesis_reactions

Functions
set_ribosomal_psim(psim_me: DataFrame) -> DataFrame

Format psim information specifically for ribosomal biogenesis.

Parameters:
  • psim_me (DataFrame) – see PSIM_README.md for details

Returns:
  • DataFrame – formatted dataframe

cleave_ub(hgnc_id: str, model_metabolites, psim_rib, ub_args: Dict[str, Any], compress_mrna: bool, charged_trna_map, modified_trna_transcript_c, stochastic: bool, seeds: List[int])

Generates reactions specific for ubiquitin-protein fusions. RPL40 and RPS27A have ubiquitin fusions.

Parameters:
  • hgnc_id (str) – Gene HGNC ID

  • me_input_model (cobra.Model) – 'the corrected input metabolic model (as provided in preprocess.correct_inputs.correct_model)'

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • psim_rib (pd.DataFrame) – formatted PSIM for ribosomal biogenesis

  • ub_args (Dict[str, Any]) – set of variables generated by this ubiquitin.express_ubiquitin to be used throughout model building

  • compress_mrna (bool) – whether to condense elongation, processing, and nuclear export reactions into a single reaction

  • charged_trna_map (Dict[str, macromolecules.RNA.tRNA]) – output of creat_trna()

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • stochastic (bool) – Whether a potentially stochastic output should be stochastic, or choose a default behavior instead

  • seeds (List[int]) – A list of seeds for if stochastic is set to True

build_ribosome_protein_expression_reactions(model_metabolites, psim_rib, modified_trna_transcript_c, charged_trna_map, ub_args: Dict[str, Any], compress_mrna: bool, stochastic: bool, seeds: List[int])

Reactions associated with transcription and translation of ribosomal proteins.

Parameters:
  • me_input_model (cobra.Model) – the corrected input metabolic model (as provided in preprocess.correct_inputs.correct_model)

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • psim_rib (pd.DataFrame) – formatted PSIM for ribosomal biogenesis

  • modified_trna_transcript_c (macromolecules.RNA.tRNA) – output of create_trna()

  • charged_trna_map (Dict[str, macromolecules.RNA.tRNA]) – output of creat_trna()

  • ub_args (Dict[str, Any]) – set of variables generated by this ubiquitin.express_ubiquitin to be used throughout model building

  • compress_mrna (bool) – whether to condense elongation, processing, and nuclear export reactions into a single reaction

  • stochastic (bool) – Whether a potentially stochastic output should be stochastic, or choose a default behavior instead

  • seeds (List[int]) – A list of seeds for if stochastic is set to True

build_ribosome(model_metabolites, psim_rib, modified_trna_transcript_c, charged_trna_map, ub_args: Dict[str, Any], compress_mrna: bool, reversible_complex_formation: bool, stochastic: bool, seed: int)

Generate all ribosome biogenesis reactions.

Parameters:
  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • psim_rib (pd.DataFrame) – formatted PSIM for ribosomal biogenesis

  • modified_trna_transcript_c (macromolecules.RNA.tRNA) – output of create_trna()

  • charged_trna_map (Dict[str, macromolecules.RNA.tRNA]) – output of creat_trna()

  • ub_args (Dict[str, Any]) – set of variables generated by this ubiquitin.express_ubiquitin to be used throughout model building

  • compress_mrna (bool) – whether to condense elongation, processing, and nuclear export reactions into a single reaction

  • reversible_complex_formation (bool) – whether complex formation reactions are reversible

  • stochastic (bool) – Whether a potentially stochastic output should be stochastic, or choose a default behavior instead

  • seed (int) – A seed for if stochastic is set to True

build_trna_expression_reactions

Classes
ExpressTrna
Methods
process_trna(self)

This reaction processes pre-tRNA into mature tRNA in the nucleus.

This includes: CCA synthesis, 5' leader and 3' trailer cleavage (and degradation as separate reactions), and splicing (and intron degradation as a separate reactions for each intron).

modify_trna_cytosolic(self)

This is for cytosolic modifications.

charge_trna(self)

tRNA charging reaction combines the activation and charging steps into one reaction.

Functions
trna_biogenesis(trna_info: TrnaInformation) -> Tuple[List[human_me.core.reaction.ExpressionReaction], List[human_me.core.macromolecules.RNA.tRNA]]

trna biogenesis reactions.

Parameters:
  • trna_info (TrnaInformation) – Associated sequence information for trna

Returns:
  • Tuple[List[human_me.core.reaction.ExpressionReaction], List[human_me.core.macromolecules.RNA.tRNA]] – Resultant reactions and tRNA products

gene_expression special

Modules
build_mrna_expression_reactions
Classes
ExpressMrna

Gene-specific mRNA expression.

Methods
transcribe_premrna(self) -> None

Elongation reaction.

process_mrna(self) -> None

Processing includes capping, splicing, and polyA tail.

export_mrna(self) -> None

Nuclear export of mRNA.

degrade_mrna(self, decapping: bool = True, three_to_five: bool = False) -> None

Currently, only one of the two degradation pathways is included. We assume the 5' to 3' pathway is present. This is simply to limit the total number of reactions

Parameters:
  • decapping (bool) – whether mRNA needs to have a decapping reaction prior to degradation, by default True

  • three_to_five (bool) – whether the 5' to 3' (False) or 3' to 5' (True) mRNA degradation pathway is used, by default False

compress_mrna_module(self)

Condense elongation, processing, and nuclear export reactions into a single reaction.

Functions
get_mrna_expression_reactions(gene_info, model_metabolites, compress_mrna: bool = False)

Generates reactions and macromolecules associated with transcription of a gene.

Parameters:
  • gene_info (GeneInformation) – representation of gene to be expressed

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • compress_mrna (bool) – whether to condense elongation, processing, and nuclear export reactions into a single reaction, by default False

Returns:
  • List[ExpressionReaction] – the reactions to express em.mrna_c

gene_information
Classes
GeneInformation

This class compiles all the necessary information for a given transcript/protein to be expressed in the

ME model.

Notes: 1) As of right now, machinery PTMs are not considered. Only non-machinery proteins processed via the secretory pathway can have PTMs.

Methods
get_final_locations(self, reactions: Optional[List[cobra.core.reaction.Reaction]] = None, nonmachinery_locations: Optional[List[str]] = None) -> None

Assigns a set of final compartments for the protein. For machinery, extracts this from the input cobrapy model. This method helps define necessary transport reactions.

Parameters:
  • reactions (Optional[List[cobra.core.reaction.Reaction]]) – reactions associated with gene, by default None

  • nonmachinery_locations (Optional[List[str]]) – one-letter code of final compartments for non-machinery, by default None

Returns:
  • None – keys as the final compartments for enzymes and values as the method of synthesis (Cytosolic Transport, Mitochondrial Expression - unimplemented, Canonical Secretion, Non-Canonical Secretion) depending on Boolean rules.

check(self)

Run checks on GeneInformation methods.

Functions
format_final_locations(final_locations: List[str], sp: bool, hgnc_id: str) -> Dict[str, str]

Map a proteins location to the means of transport.

Parameters:
  • final_locations (List[str]) – each element is one-letter code for a compartment in the model

  • sp (bool) – whether a signal peptide is present

  • hgnc_id (str) – the hgnc id of the associated gene

Returns:
  • Dict[str, str] – keys are elements in final_locations and values are means of translation ('Cytosolic Transport', 'Canonical Secretion', 'Non-Canonical Secretion', or 'Mitochondrial Expression')

generate_from_psim(hgnc_id: str, psim: DataFrame, machinery_list: List[str], reactions: Optional[List[cobra.core.reaction.Reaction]] = None, nonmachinery_locations: Optional[List[str]] = None, stochastic: bool = False, seed: int = None) -> GeneInformation

Generates gene information object from PSIM. Assumes the gene information object being generated is not for a non-machinery protein.

Parameters:
  • hgnc_id (str) – gene HGNC ID in the format HGNC:####

  • psim (DataFrame) – see PSIM_README.md for details

  • machinery_list (List[str]) – each entry is the HGNC ID of a protein that should be considered as catalyzing a reaction

  • reactions (Optional[List[cobra.core.reaction.Reaction]]) – list of cobra reactions, by default None

  • nonmachinery_locations (Optional[List[str]]) – list of nonmachinery compartments, by default None

  • stochastic (bool) – Whether a potentially stochastic output should be stochastic, or choose a default behavior instead, by default False

  • seed (int) – A seed for if stochastic is set to True, by default None

Returns:
  • GeneInformation – An object of the GeneInformation class

protein_expression special
Modules
build_protein_expression_reactions
Functions
fold_protein_cytosolic(gene_info, unfolded_protein_c: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Fold cytosolic proteins.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • unfolded_protein_c (Protein) – the translated, unfolded, cytosolic protein

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Folding reaction and folded protein

transport_nuclear_protein(gene_info, folded_protein_c: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Nucleocytoplasmic transport of proteins.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • folded_protein_c (Protein) – Protein to be transported

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Transport reaction and transported protein

get_nuclear_reactions(gene_info, folded_protein_c: Protein, ub_args: Dict[str, Any], model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

All associated nuclear protein formation reactions.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • folded_protein_c (Protein) – folded, cytosolic protein

  • ub_args (Dict[str, Any]) – set of variables generated by this ubiquitin.express_ubiquitin to be used throughout model building

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated reactions and protein products

transport_mitochondrial_matrix(gene_info, unfolded_protein_c: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Protein transport to mitochondrial matrix.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • unfolded_protein_c (Protein) – Cytosolic, unfolded protein to be transported

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Transport reaction and transported, folded protein

mitochondrial_matrix_protein_processing(gene_info, pre_protein_m: Protein) -> Tuple[Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]], Dict[str, int], int]

Cleavage of MTS - unimplemented.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • pre_protein_m (Protein) – Mitochondrial protein to be processed

Returns:
  • Tuple[Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]], Dict[str, int], int] – Processing reaction and processed protein

transport_mitochondrial_inter(gene_info, processed_protein_m: Protein) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Transport of protein to inter membrane space.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • processed_protein_m (Protein) – Mitochondrial matrix protein

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Transport reaction and transported protein

mitochondrial_inter_protein_processing(gene_info, pre_protein_i: Protein) -> ProteinExpressionReaction

Processing of intermembrane mitochondrial protein.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • pre_protein_i (Protein) – Intermembrane protein to be processed

Returns:
  • ProteinExpressionReaction – Processing reactions and processed protein

get_mitochondrial_reactions(gene_info, unfolded_protein_c: Protein, compartments: List[str], model_metabolites) -> Tuple[List[Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]]]

Generate all mitochondrial transport reactions.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • unfolded_protein_c (Protein) – unfolded, cytosolic protein

  • compartments (List[str]) – one-letter codes of all mitochondrial compartments (options ['m', 'i']) for protein to be transported to

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[List[Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]]] – Associated transport reactions and transported proteins

transport_peroxisome(gene_info, folded_protein_c: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Transport of proteins to peroxisome.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • folded_protein_c (Protein) – Folded, cytosolic protein to be transported

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated transport reactions and transported metabolite

get_peroxisomal_reactions(gene_info, folded_protein_c: Protein, model_metabolites)

All peroxisomal protein expression reactions.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • folded_protein_c (Protein) – Folded, cytosolic protein with a final location of peroxisome

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

post_translational_translocation(gene_info, unfolded_protein_c: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Post translational translocation to ER.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • unfolded_protein_c (Protein) – unfolded, cytosolic protein

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated transport reactions and transported protein

form_disulfide_bond(gene_info, folded_protein_r: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Disulfide bond formation.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • folded_protein_r (Protein) – ER localized protein to receive disulfide bond

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated reactions and proteins from disulfide bond formation

form_gpi(gene_info, modified_protein_r: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

GPI formation.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • modified_protein_r (Protein) – ER protein to receive GPI modification

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated reactions and protein product from GPI formation

modify_protein_er(gene_info, folded_protein_r: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

All ER associated PTMs.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • folded_protein_r (Protein) – Folded, unmodified ER protein

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – All reactions and protein product from ER modifications

import_golgi(gene_info, modified_protein_r: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Golgi transport.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • modified_protein_r (Protein) – Final ER protein product

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated transport reactions and protein product

glycosylate_o_linked(gene_info, protein_g: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

O-linked glycosylation.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • protein_g (Protein) – Golgi protein

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated reactions and protein product

modify_protein_golgi(gene_info, protein_g: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

All PTM modifications in Golgi.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • protein_g (Protein) – Golgi localized protein

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated reactions and protein product

secrete_protein(gene_info, modified_protein_g: Protein, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Reactions associated with lysosomal, ECM, and plasma membrane transport.

Parameters:
  • gene_info (GeneInformation) – gene_info : GeneInformation

  • modified_protein_g (Protein) – Golgi localized protein

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated reactions and protein products

get_protein_expression_reactions(gene_info, mrna_transcript_c, mrna_deg_proxy, ub_args: Dict[str, Any], modified_trna_transcript_c, charged_trna_map, model_metabolites) -> Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]]

Generate all translation, processing, transport, and degradation reactions for protein monomers.

Parameters:
  • gene_info (GeneInformation) – GeneInformation object of associated gene

  • mrna_transcript_c (mRNA) – the final, cytosolic mRNA transcript

  • mrna_deg_proxy ([type]) – proxy metabolite generated in mRNA degradation reaction for coupling

  • ub_args (Dict[str, Any]) – set of variables generated by this ubiquitin.express_ubiquitin function to be used throughout model building

  • modified_transcript_c (macromolecules.RNA.tRNA) – output of create_trna()

  • charged_trna_map (Dict[str, macromolecules.RNA.tRNA]) – output of creat_trna()

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[List[human_me.core.reaction.ProteinExpressionReaction], human_me.core.reaction.ProteinExpressionReaction, List[human_me.core.reaction.ProteinDegradationReaction], human_me.core.reaction.ProteinDegradationReaction], Union[List[human_me.core.macromolecules.protein.Protein], human_me.core.macromolecules.protein.Protein]] – Associated protein expression reactions and macromolecules

cytosolic_translation
Functions
translate_protein_cytosolic(gene_info, mrna_transcript_c, mrna_deg_proxy: Proxy, modified_trna_transcript_c, charged_trna_map, model_metabolites) -> Tuple[human_me.core.reaction.ProteinExpressionReaction, human_me.core.macromolecules.protein.Protein]

Generate cytosolic translation reaction.

Parameters:
  • gene_info (GeneInformation) – representation of gene to be expressed

  • me_input_model (cobra.Model) – the corrected input metabolic model (as provided in preprocess.correct_inputs.correct_model)

  • mrna_transcript_c (mRNA) – the final, cytosolic mRNA transcript

  • mrna_deg_proxy (Proxy) – proxy metabolite generated in mRNA degradation reaction for coupling

  • modified_transcript_c (macromolecules.RNA.tRNA) – output of create_trna()

  • charged_trna_map (Dict[str, macromolecules.RNA.tRNA]) – output of creat_trna()

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[human_me.core.reaction.ProteinExpressionReaction, human_me.core.macromolecules.protein.Protein] – translation elongation reaction

degradation
Functions
protein_polyubiquitination(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites, **kwargs) -> Tuple[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction], Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]]

Adds 4 ubiquitins to the macromolecule.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – the macromolecule to be polyuibquitinated

Returns:
  • Tuple[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction], Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]] – the polyubiquitination reaction

proteasomal_degradation(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites, **kwargs) -> List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]]

Protoeasomal degradation of macromolecule.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – the macromolecule to be degraded

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]] – the deubiquitination and proteosomal degradation reaction

degrade_cytosolic_nuclear_protein(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites, **kwargs) -> List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]]

Degradation reactions for cytosolic or nuclear proteins.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – The macromolecule to be degraded

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]] – All associated degradation reactions of the macromolecule

degrade_mitochondrial_protein(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites) -> List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]]

Degradation reactions for proteins localized to mitochondria.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – The macromolecule to be degraded

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]] – The degradation reaction

degrade_peroxisomal_protein(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites) -> List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]]

Degradation rof proteins localized to peroxisome.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – The macromolecule to be degraded

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]] – The degradation reactions

unfold_secretory_protein(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites) -> Tuple[Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]]

Remove PTMs and unfold proteins for lysosomal and secretory compartments. For lysosomal degradation, only remove PTMs, there is no unfolding/misfolding as in ERAD.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – The macromolecule to be degraded

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]] – Unfolded and PTM removed version of macromolecule

retrograde_er(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites, retro_protein_r: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex] = None) -> Tuple[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction], Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]]

ER retrograde transport.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – Macromolecule undergoing retrograde transport

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • retro_protein_r (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – If the ER version of this protein exists, provide it here, by default None

Returns:
  • Tuple[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction], Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]] – the retrograde transport reaction

build_erad_reactions(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites, **kwargs)

Generate all ERAD reactions.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – macromolecule to undergo ERAD

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

build_endocytosis_reactions(macromolecule_pm: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites, **kwargs) -> Tuple[List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]], Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]]

Create the endocytosis reactions.

Parameters:
  • macromolecule_pm (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – macromolecule to undergo endocytosis

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Tuple[List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]], Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]] – Associated reactions and output macromolecule after endocytosis

lysosomal_degradation(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites) -> List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]]

Generate reactions and associated macromolecules for lysosomal degradation.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – macromolecule to undergo lysosomal degradation

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]] – The associated lysosomal degradation reactions

degrade_lysosomal_pm_protein(macromolecule: Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction], model_metabolites, **kwargs) -> List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]]

Lysoomal degradation of membrane proteins.

Parameters:
  • macromolecule (Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]) – macromolecule to undergo degradation

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]] – associated degradation reactions

degrade(macromolecule: Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex], model_metabolites, **kwargs) -> List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]]

Compartment-specific degradation reactions for proteins or protein-protein complexes.

Parameters:
  • macromolecule (Union[human_me.core.macromolecules.protein.Protein, human_me.core.macromolecules.complex.Complex]) – macromolecule to be degraded

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • List[Union[human_me.core.reaction.ProteinDegradationReaction, human_me.core.reaction.ComplexDegradationReaction]] – degradation reactions

ubiquitin
Functions
express_ubiquitin(model_metabolites, psim_me: DataFrame, compress_mrna: bool, charged_trna_map, modified_trna_transcript_c) -> Dict[str, Any]

Reactions for formation of ubiquitin.

Parameters:
  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • psim_me (DataFrame) – the corrected psim matrix (as provided in preprocess.correct_inputs.correct_psim)

  • compress_mrna (bool) – whether to condense elongation, processing, and nuclear export reactions into a single reaction

  • modified_transcript_c (macromolecules.RNA.tRNA) – output of create_trna()

  • charged_trna_map (Dict[str, macromolecules.RNA.tRNA]) – output of creat_trna()

Returns:
  • Dict[str, Any] – set of variables generated by this function to be used throughout model building

utils special

Modules

downstream_analyses

Functions
troubleshoot_me(me_model_file: str, mu_val: float = 1e-09, model_metabolite_ids: Optional[List[str]] = None, out_path: Optional[str] = None, *args, **kwargs)

Helps troubleshoot ME Model if solver finds infeasible solution at growth rate of "mu_val". Basic principle is to

iterate through the metabolites from the input metabolic model, add them as sinks, and see which are required as sinks to make the model feasible.

*Note, this results in identified metabolites required for feasability being dependent on the order they were iterated through. The metabolite list is run through _order_metabolites() to prioritize metabolites of certain types and in certain compartments.

Parameters:
  • me_model (str) – full path to pickled me model

  • mu_val (float) – growth rate to solve lp at, by default 1e-9

  • model_metab_ids (Optional[List[str]]) – a list of metabolite IDs (subset of all) to test whether adding the sinks makes the model feasible, by default all metabolites

  • out_path (Optional[str]) – where to save the output files, by default current working directory

  • *args** – into "_order_metabolites" function

  • *kwargs** – into "_order_metabolites" function

Returns:
  • pd.DataFrame – the sink reactions and simulated fluxes required to make the ME Model feasible at mu

get_limiting_nutrients(me_model_file: str, max_feasible_mu: float, uptake_only: bool = False)

Identifies a list of limiting extracellular nutrients that prevent the ME Model from growing at 2.5% higher growth rate

Parameters:
  • me_model_file (str) – full path to pickled me model

  • max_feasible_mu (float) – the maximum growth rate at which the ME Model is still feasible (see ME_Model.maximize_growth method)

  • uptake_only (bool) – whether to only consider extracellular nutrients that can be taken up (e.g., exclude those that can only be excreted according to exchange reaction bounds), by default False

correct_solution_precision(me_sln, me_model, min_precision_noise: float = 1e-20, use_bound_precision_floor: bool = False, precision_floor_thresh: float = 100, verbose: bool = True)

Correct fluxes that are out of bounds or below noise threshold due to solver feasibility tolerance (which is 1e-20 by default).

1) Resets flux values that violate bounds to the bound. 2) Resets flux values below minimum precision to 0. Either uses the optimizer tolerance value (by defaulte 1e-20) OR the maximum bound discrepancy, which may be > 1e-20.

Parameters:
  • me_model – the ME Model

  • me_sln (pd.DataFrame) – the solution to the ME Model LP (output of ME_Model.format_solution method)

  • min_precision_noise (float) – the solver tolerance, the threshold at which flux values below this will definitely be set to 0, by default 1e-20 set to 0 to not correct any of these

  • use_bound_precision_floor (bool) – whether to further raise the noise floor to the largest discrepancy of bound violations, indicating that values below this are also noise if a bound violation > min_precision_noise, will use that value instead to set fluxes small than it to 0 *Not recommended, as the boundary violation precision error could be different than the solution precision error

  • precision_floor_thresh (float) – only relevant if use_bound_precision_floor is true, will scale the empirical noise threshold by this value (since solution error sources could be different than bound error sources)

Returns:
  • me_sln_corrected – the same dataframe with corrected fluxes

format_reaction_as_metabolic(reaction, expression_module: bool = False) -> Dict[str, Union[str, int]]

Returns a dictionary mapping a MEReaction to its respective metabolic model reaction, if it exists

Parameters:
  • reaction (cobra.core.reaction.ME_Reaction) – the ME Model reaction to format

  • expression_module (bool) – whether to also parse ExpressionReactions, which are not necessary for comparison with the metabolic model, by default False

Returns:
  • Dict[str, Union[str, int]] – a dictionary mapping the MEReaction to its respective metabolic reaction "metabolic_reaction_id": the metabolic model reaction ID "reaction_no": if the reaction has an OR GPR, the ME Model building will have created one reaction for each GPR and separted them out by a number "reaction_direction": if the reaction was reversible and not spontaneous, the ME Model will have separated out the forward and reverse directions

format_sln_as_metabolic(me_model, me_sln: DataFrame, neg_rev_flux = True)

For metabolic reactions, formats and aggregates (e.g. across reversibility or multiple reactions due to "OR" GPRs)

the ME Model solution to be comparable to the metabolic model solution. This should then be readily compared to the output of m_model.optimize().to_frame().

We recommend using the cm_2 output from preprocess.correct_inputs.correct_model as the comparable metabolic model. Though not necessary, a more fair comparison may be to set the growth rates (mu) of the metabolic and me model to be the same. In the cobra.Model metabolic model this can be done by setting the growth reaction bounds to be mu. In the me model, this can be specified with the "mu_val" parameter in the ME_Model.solve_lp method.

If comparing to cm_2, do not set neg_rev_flux to False.

Parameters:
  • me_model (ME_Model) – the constructed ME Model

  • me_sln (DataFrame) – the solution to the ME Model LP (output of ME_Model.format_solution method)

  • neg_rev_flux (bool) – whether to take the negative of the fluxes in reactions representing the reverse direction prior to aggregating, by default True True will give the net flux through the reaction (forward - reverse), False will give the total absolute flux through the reaction (forward + reverse) **Note, if set to False, likely want to then take the absolute value of the fluxes. There are some ME MetabolicReactions that are negative because of the directionality of the original M-Model cobra.Reaction.

Returns:
  • pd.DataFrame – dataframe containing the me model (column name "me_flux") flux solutions with formatted reaction IDs

get_expression_fluxes(me_model, me_sln: DataFrame, molecule_type: str, group_by: str = 'sum', consider_degradation: bool = True, drop_ors: bool = False) -> float

Calculate the flux through gene expression for each gene in ME Model.

Parameters:
  • me_model (ME_Model) – the constructed ME Model

  • me_sln (DataFrame) – the solution to the ME Model LP (output of ME_Model.format_solution method)

  • molecule_type (str) – one of 'mrna' or 'protein' to get transcriptional or translational fluxes

  • group_by (str) – if multiple reactions, aggregate fluxes by group_by as input to the "func" argument of by default 'sum'

  • consider_degradation (bool) – whether to subtract the degradation fluxes from the synthesis fluxes or only consider synthesis fluxes, by default True

  • drop_ors (bool) – If multiple reactions were created due to OR GPR, between those multiple reactions, will only retain the reaction whose catalyzing enzymes' genes have maximal expression flux across the multiple reactions.

Returns:
  • float – the net flux for expression of each gene

get_optimal_val(formatted_sln: DataFrame, objective: Dict[str, SupportsFloat]) -> float

Calculate the optimal value for the objective

Parameters:
  • formatted_sln (DataFrame) – output of model.ME_Model.format_solution

  • objective (Dict[str, SupportsFloat]) – input to model.ME_Model..solve_lp

Returns:
  • floatdescription

flux_variability_analysis(me_model, mu_val: float, reactions: List[str], primary_objective: Optional[Dict[str, SupportsFloat]] = None, optimal_val: float = None, tolerance: SupportsFloat = 0, n_cores: int = 0, **kwargs) -> DataFrame

Runs FVA on reactions of interest at a given growth rate.

Parameters:
  • me_model – the me model

  • mu_val (float) – the growth rate at which to run the LP (should be <= maximum feasible growth rate)

  • reactions (List[str]) – a list of reaction IDs from the ME Model. Solving the ME Model takes much longer than a standard metabolic model, so we highly recommend limiting this list to a few reactions.

  • primary_objective (Optional[Dict[str, SupportsFloat]]) – The objective function to optimize. Dictionary represent a linear combination of reactions to optimize, with reaction ids as keys and the coefficient of the linear combination as the values. Positive values imply maximization, negative values minimization, by default {'biomass_dilution': 1}

  • optimal_val (float) – The value of the primary objective at the optimal solution, see "get_optimal_val" function

  • tolerance (SupportsFloat) – Threshold below which expected sensitivity of solver is too low to detect infeasibility, by default 0

  • n_cores (int) – number of cores to parallelize with, by default no parallelization. This may take longer than iterating through each one at a time (see use of _fill_by_bounds function when n_cores <= 1).

  • *kwargs* – keyword arguments for QMINOS.solvelp method

Returns:
  • DataFrame – first two columns represent the minimum and maximum possible fluxes at that growth rate

format_fva_as_metabolic(me_model, me_fva_df: DataFrame, concat_type: str = 'lenient')

Format the FVA to be comparable to the metabolic model reactions

Parameters:
  • me_model (ME_Model) – the constructed ME Model

  • me_fva_df (DataFrame) – the output of the "flux_variability_analysis" function

  • concat_type (str) – in the presence of OR GPRs, how to aggregate reaction bounds across the multiple reactions generated, by default 'lenient' options include: "lenient": will take the maximum upper bound and minimum lower bound across the multiple reactions "stringent": will take the minimum upper bound and maximum lower bound across the multiple reactions (note that this may cause situations in which min > max) func: input to pd.DataFrame.aggregate's "func" argument

Returns:
  • pd.DataFrame – A dataframe that should be directly comparable to the output of running cobra.flux_analysis.variability.flux_variability_analysis on the m_model

get_enzyme_synthesis_reaction(reaction_id: str, me_model)

Given an enzyme-catalyzed reaction, identified the final expression reaction that forms the catalyzing enzyme.

Parameters:
  • reaction_id (str) – reaction ID of the enzyme-catalyzed reaction

  • me_model (_type_) – me model containing the reaction

functions

Functions
flatten_list(list1: List[List[Any]]) -> list

Create a single list from a list of lists.

Parameters:
  • list1 (List[List[Any]]) – a list of lists

Returns:
  • list – a single list

create_gene_reaction_map(reactions: List[cobra.core.reaction.Reaction]) -> Dict[str, List[cobra.core.reaction.Reaction]]

Maps each gene to all associated reaction.

Parameters:
  • reactions (List[cobra.core.reaction.Reaction]) – list of cobra reactions

Returns:
  • Dict[str, List[cobra.core.reaction.Reaction]] – keys are HGNC ID strings, values are a list of reactions from the reactions input in which the HGNC ID helps catalyze that reaction

convert_gi(gi, non_machinery: List[str])

[summary]

Parameters:
  • gi (human_me.core.expression.gene_expression.GeneInformation) – [description]

  • non_machinery (List[str]) – list of HGNC IDs

Returns:
  • human_me.core.expression.gene_expression.GeneInformation – updated gene information object

get_reaction_compartment(reaction: Reaction, stochastic: bool = False, seed: Optional[int] = None) -> str

Map reactions to a particular compartment according to some rules, informing the compartment the enzyme catalyzing the reaction should be transported to.

Parameters:
  • reaction (Reaction) – [description]

  • stochastic (bool) – In the presence of multiple compartments for a single reaction, whether one should randomly be chosen, by default False

  • seed (Optional[int]) – A seed for if stochastic is set to True, by default None

Returns:
  • str – a singular compartment representing the location of the enzyme catalyzing the reaction

hydrolyze_atp(metabolites_to_add: Dict[cobra.core.metabolite.Metabolite, Union[float, int]], n_atp: Union[float, int], compartment: str, model_metabolites) -> Dict[cobra.core.metabolite.Metabolite, Union[float, int]]

Create ATP hydrolysis reaction.

Parameters:
  • metabolites_to_add (Dict[cobra.core.metabolite.Metabolite, Union[float, int]]) – dictionary with metabolite objects or metabolite identifiers as keys and reaction coefficients as values

  • n_atp (Union[float, int]) – number of atps to hydrolyze

  • compartment (str) – location of hydrolysis

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

Returns:
  • Dict[cobra.core.metabolite.Metabolite, Union[float, int]] – updated metabolites_to_add dictionary with n_atps hydrolyzed

get_base_counts_and_elements(seq: Union[Bio.Seq.Seq, str], model_metabolites, triphosphate: bool = True) -> Tuple[Dict[str, int], Dict[str, int]]

Count the number of bases and atom elements in an RNA sequence.

Parameters:
  • seq (Union[Bio.Seq.Seq, str]) – a gene's mRNA sequence

  • model_metabolites (utils.metabolites.MetaboliteBin) – the me_input_model metabolites as specified by MetaboliteBin

  • triphosphate (bool) – whether the mRNA has a 5' triphosphate, by default True

Returns:
  • Tuple[Dict[str, int], Dict[str, int]] – the number of each RNA base in the sequence

parse_me_reaction_id(x: str) -> str

Get HGNC ID associated with an expression module reaction.

Parameters:
  • x (str) – cobra.core.reaction.Reaction.id

Returns:
  • str – HGNC ID

SASA(mw: float) -> float

Estimate the protein solvent-accessible surface area from the molecular weight.

Parameters:
  • mw (float) – protein molecular weight (in kDa)

Returns:
  • float – approximate protein solvent accesible surface area

average_protein_features(psim_me: DataFrame, hgnc_id: str, context_specific: bool = False, metabolic_machinery: Optional[List[str]] = None) -> DataFrame

Function to get the average protein features from the proteins used in a specific ME model being generated.

Note, we filter for metabolic enzymes only, because most orphan reactions come from the metabolic sector.

Parameters:
  • psim_me (DataFrame) – protein specific information matrix, same as corrected input file (see preprocessing output)

  • hgnc_id (str) – HGNC ID to assign to the average protein

  • context_specific (bool) – whether the representative dummy protein is calculated for only genes in the user-provided context specific model from the user provided PSIM (True) or for all recon2.2 machinery proteins in the gold-standard PSIM , by default False

  • metabolic_machinery (Optional[List[str]]) – the context-specific metabolic machinery. Output of utils.machinery.get_model_machinery function

Returns:
  • DataFrame – [description]

determine_transport(r: Reaction) -> List[str]

Checks which metabolites are transported in a cobra reaction.

Parameters:
  • r (Reaction) – the reaction to probe

Returns:
  • List[str] – a list of metabolites that are actually transported across compartments each element is a string of the metabolite id without the compartment ('_compartment' ending)

read_fasta_url(file_url: str)

Load a fasta format sequence from url.

Parameters:
  • file_url (str) – url to fast sequence

Returns:
  • SeqRecord – biopython SeqRecord iterator

machinery

Functions
get_model_machinery(me_input_model) -> Tuple[List[str]]

Parse input metabolic model for metabolic machinery.

Parameters:
  • me_input_model (cobra.Model) – the corrected input metabolic model (as provided in preprocess.correct_inputs.correct_model)

Returns:
  • Tuple[List[str]] – HGNC IDs of metabolic genes

metabolites

Classes
MetaboliteBin

Stores all metabolites used in model building

parameters

Classes
BiomassParameters

Stores Biomass reactions' asssociated coefficients and mass fractions in one object.

polyA_statistics

Functions
calculate_polyA_length(polyA_length: Union[int, float] = None, stochastic: bool = False, seed: Optional[int] = None) -> int

Calculates expected length of polyA tail based on input float and data distribution.

Parameters:
  • polyA_length (Union[int, float]) – nt length of the polyA tail, by default None

  • stochastic (bool) – whether to estimate the polyA tail length from a regression model based on length input if length is provided or draw from a distribution if length is not provided, by default False

  • seed (Optional[int]) – ensures the same polyA length on separate runs if polyA_length is not provided and stochastic is True, by default None

Returns:
  • int – nt length of the polyA tail