memote.support.helpers module

Helper functions that are used all over the memote package.

memote.support.helpers.close_boundaries_sensibly(model)[source]

Return a cobra model with all boundaries closed and changed constraints.

In the returned model previously fixed reactions are no longer constrained as such. Instead reactions are constrained according to their reversibility. This is to prevent the FBA from becoming infeasible when trying to solve a model with closed exchanges and one fixed reaction.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Returns:

cobra.Model

A cobra model with all boundary reactions closed and the constraints of each reaction set according to their reversibility.

memote.support.helpers.df2dict(df)[source]

Turn a pandas.DataFrame into a dict of lists.

memote.support.helpers.find_biomass_reaction(model)[source]

Return a list of the biomass reaction(s) of the model.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.helpers.find_converting_reactions(model, pair)[source]

Find reactions which convert a given metabolite pair.

Parameters:

model : cobra.Model

The metabolic model under investigation.

pair: tuple or list

A pair of metabolite identifiers without compartment suffix.

Returns:

frozenset

The set of reactions that have one of the pair on their left-hand side and the other on the right-hand side.

memote.support.helpers.find_demand_reactions(model)[source]

Return a list of demand reactions.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

[1] defines demand reactions as: – ‘unbalanced network reactions that allow the accumulation of a compound’ – reactions that are chiefly added during the gap-filling process – as a means of dealing with ‘compounds that are known to be produced by the organism [..] (i) for which no information is available about their fractional distribution to the biomass or (ii) which may only be produced in some environmental conditions – reactions with a formula such as: ‘met_c -> ‘

Demand reactions differ from exchange reactions in that the metabolites are not removed from the extracellular environment, but from any of the organism’s compartments.

References

[R1315]Thiele, I., & Palsson, B. Ø. (2010, January). A protocol for generating a high-quality genome-scale metabolic reconstruction. Nature protocols. Nature Publishing Group. http://doi.org/10.1038/nprot.2009.203
memote.support.helpers.find_exchange_rxns(model)[source]

Return a list of exchange reactions.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

[1] defines exchange reactions as: – reactions that ‘define the extracellular environment’ – ‘unbalanced, extra-organism reactions that represent the supply to or removal of metabolites from the extra-organism “space”’ – reactions with a formula such as: ‘met_e -> ‘ or ‘ -> met_e’ or ‘met_e <=> ‘

Exchange reactions differ from demand reactions in that the metabolites are removed from or added to the extracellular environment only. With this the uptake or secretion of a metabolite is modeled, respectively.

References

[R1416]Thiele, I., & Palsson, B. Ø. (2010, January). A protocol for generating a high-quality genome-scale metabolic reconstruction. Nature protocols. Nature Publishing Group. http://doi.org/10.1038/nprot.2009.203
memote.support.helpers.find_functional_units(gpr_str)[source]

Return an iterator of gene IDs grouped by boolean rules from the gpr_str.

The gpr_str is first transformed into an algebraic expression, replacing the boolean operators ‘or’ with ‘+’ and ‘and’ with ‘*’. Treating the gene IDs as sympy.symbols this allows a mathematical expansion of the algebraic expression. The expanded form is then split again producing sets of gene IDs that in the gpr_str had an ‘and’ relationship.

Parameters:

gpr_str : string

A string consisting of gene ids and the boolean expressions ‘and’ and ‘or’

memote.support.helpers.find_sink_reactions(model)[source]

Return a list of sink reactions.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

[1] defines sink reactions as: – ‘similar to demand reactions’ but reversible, thus able to supply the model with metabolites – reactions that are chiefly added during the gap-filling process – as a means of dealing with ‘compounds that are produced by nonmetabolic cellular processes but that need to be metabolized’ – reactions with a formula such as: ‘met_c <-> ‘

Sink reactions differ from exchange reactions in that the metabolites are not removed from the extracellular environment, but from any of the organism’s compartments.

References

[R1517]Thiele, I., & Palsson, B. Ø. (2010, January). A protocol for generating a high-quality genome-scale metabolic reconstruction. Nature protocols. Nature Publishing Group. http://doi.org/10.1038/nprot.2009.203
memote.support.helpers.find_transport_reactions(model)[source]

Return a list of all transport reactions.

Parameters:

model : cobra.Model

The metabolic model under investigation.

Notes

A transport reaction is defined as follows: 1. It contains metabolites from at least 2 compartments and 2. at least 1 metabolite undergoes no chemical reaction, i.e., the formula stays the same on both sides of the equation.

This function will not identify transport via the PTS System.

memote.support.helpers.find_transported_elements(rxn)[source]

Return a dictionary showing the amount of transported elements of a rxn.

Collects the elements for each metabolite participating in a reaction, multiplies the amount by the metabolite’s stoichiometry in the reaction and bins the result according to the compartment that metabolite is in. This produces a dictionary of dictionaries such as this {'p': {'C': -1, 'H': -4}, c: {'C': 1, 'H': 4}} which shows the transported entities. This dictionary is then simplified to only include the non-zero elements of one single compartment i.e. showing the precise elements that are transported.

Parameters:

rxn : cobra.Reaction

Any cobra.Reaction containing metabolites.

memote.support.helpers.run_fba(model, rxn_id, direction='max', single_value=True)[source]

Return the solution of an FBA to a set objective function.

Parameters:

model : cobra.Model

A cobrapy metabolic model

rxn_id : string

A string containing the reaction ID of the desired FBA objective

direction: string

A string containing either “max” or “min” to specify the direction of the desired FBA objective function

single_value: boolean

Indicates whether the results for all reactions are gathered from the solver, or only the result for the objective value.

Returns:

cobra.solution

The cobra solution object for the corresponding FBA problem