cobra modeling¶
-
class
ProductionNetworkDebugger
(production_network)¶ A simple class to figure out issues with production pathways
Notes
- Even if the key products in a pathway are connected, the presence
- of intermediates in the pathway that cannot be consumed or secreted by the model will block the entire pathway
-
check_mets_in_rxn
(rxn_id)¶ Checks if the metabolites in rxn_id can be made
-
flux_tol
= '1e-4'¶ None
-
het_rxn_id
= None¶ cell of the reactions in the production pathway’
-
inspect
()¶ starts the wonderful surfNet function from cobra tolbox
-
pn
= None¶ cobra model of the problematic production network
-
add_modcell_fields
(model, biomass_reaction_id, varargin)¶ Add modcell fields to a cobra model.
Notes
- Replaces field name metCharge by metCharges.
- Deletes csense field, since it is not updated with the model (i.e.
- (when reactions ae added).
Warning
- The scope of this function is to include additional fields used by
modcell which are not commonly used. However, modcell may use other fields which may not be present in the current model due to lack of standards and parsing errors. func:src.support.cobra_modeling.check_parent_fields addresses model compliance.
-
change_unknown_bounds
(model, box_constraint_value)¶ Change box constraints to +- Inf, this makes LP considerably faster to solve. However, not all box constraints can be changed. As of August 2017 the cobra toolbox leads to errors (at least in fluxVariability and derived functions) when the reactions are truly unbounded. So in those cases they must be left with big M/box constraint:
Parameters: - model (cobra model) –
- box_contraint_value (int, optional) – (a.k.a. as big M). cobra models tend to use 1000.
-
check_parent_fields
(model)¶ Ensures that the parent model contains all the required fields, raises an assertion error otherwise
-
convert_external_solution_to_modcell
(prodnet, reaction_deletion_array, design_objective)¶ Maps a external solution into modcell for result analysis and to use as starting point.
Parameters: - prodnet (Prodnet object) –
- reaction_deleteion_array (i).rxns (indexed structure) – The index i corresponding to the deletion set and its only field .rxns contains the ids of the reactions being deleted.
- design_objective (str) – e.g. ‘wGCP’.
Returns: mop_solution (modcell solution structure)
Notes
- All inputs must be candidate reactions.
- Does not currently support gene deletions.
-
default_bounds_from_rxn_str
(reaction_formula, M)¶ Returns default boudns based on the reaction formula string.
Notes
- Assumes left to right direction (i.e. ‘a => b’ is valid but ‘b <= a’ is not)
-
exclusive_gene_map
(model, reaction_inds)¶ For each reaction in reaction_inds, finds the genes exclusively associated with that reaction (i.e. they do no appear in the GPR of any other reaction in the model).
Parameters: - model (cobra model) –
- reaction_inds (vector) – indices of the reactions to be mapped
-
findBlockedReaction_fast
(model, method, verbose)¶ Determines those reactions which cannot carry any flux in the given simulation conditions.
USAGE:
BlockedReaction = findBlockedReaction(model)- INPUT:
- model: COBRA model structure
- OPTIONAL INPUT:
- method: ‘FVA’ for flux variability analysis (default)
- ‘L2’ for 2-norm minimization
- OUTPUT:
- blockedReactions: List of blocked reactions
-
get_mapped_gpr
(gprin, geneid2name_file)¶ Convers a gpr with gene ids into gene names
Parameters: - gpridn (cell with string) – e.g. model.grRules(1)
- geneid2name_file (file_path) – Two column .csv with map from id to name
-
get_met_ids_from_rxn_str
(reaction_string)¶ Metabolite ids from a reaction string
Parameters: reaction_string (str) – e.g. ‘acald_c + coa_c + nad_c <=> accoa_c + h_c + nadh_c’ Returns: e.g. Return type: met_ids(cell array of str) Notes
- must use the follwoing compartment format: _c, _e, etc. instead of
[c],[e]…
-
map_non_cand_rxn_to_gene
(model, non_candidate_reactions_ind)¶ Returns the indices of genes which are only associated with non candidate reactions.
Parameters: - model (cobra model) –
- candidate_reactions_ind (vector) –
Returns: non_candidate_genes_ind (vector)
-
optimize_cofactor_turnover
(cmodel, met_id, optsense)¶ Maximize or minimzie cofactor turnover for a given metabolite
Parameters: - cmodel (cobra model) –
- metid (string) – id of the metabolite to maximize cofactor turnover/
- optsense (string, default 'max') – ‘max’ maximize turnover, ‘min’ minimize turnover.
Returns: maximum cofactor turnover
Return type: optct(scalar)
Notes
- Cofactor turnover corresponds to the amount of a metabolite processed
- through the network, and can be defined as ct_i = sum_{j forall J} |S_{ij} r_j| which in matrix notation is ct = |S||r|. Thus to maximize the cofactor turnover in the fba lp, the liniar objective corresponds to the sum of all produced moles of i: c_j = S_{ij} if S_{ij} >0 else c_j =0. note that the sum of all produced mols of i is the same as the sum of all consumed moles of i.
candidate determination¶
-
findFullCoSets
(model, verbose)¶ Finds fully correlated sets/enzyme subsets, the ratio of any two reactions in such set is always constant.
Parameters: model (cobra model) – Returns: - FullCoSets(i).rxns (cell of strings) – Reactions in coset i.
- FullCoSets(i).rxns (string) – Nicely formated string of reactions in coset i.
- FullCoSets(i).ind (vector) – Indices of reactions in coset i.
Notes
- This function uses FC2C to compute cosets. While the software is fast, the output has to be treated carefully since it does not included the blocked reactions (as determined by F2C2 internal functions, which may differ from cobra findBlockedReaction).
- We only need the fully correlated sets which are computed from the kernel of the stocihiometric matrix during preporcessing, and not other info regarding flux coupling.
- Be aware that full cosets in the output of this function do not include blocked reactions.
cobra toolbox updates¶
-
addMetabolite_updated
(model, metID, metName, formula, ChEBIID, KEGGId, PubChemID, InChi, Charge, b)¶ Adds a Metabolite to the Current Reconstruction
USAGE:
newModel = addMetabolite(model, metID, metName, formula, ChEBIID, KEGGId, PubChemID, InChi, Charge, b )- INPUTS:
- model: Cobra model structure metID: The ID(s) of the metabolite(s) (will be the identifier in model.mets)
- OPTIONAL INPUTS:
- metName: Human readable name(s) (String) formula: The chemical formula(s) (String) ChEBIID: The CHEBI Id(s) (String) KEGGId: The KEGG Compound ID(s) (String) PubChemID: The PubChemID(s) (String) InChi: The InChi description(s) (String) Charge: The Charge(s) (int) b: The accumulation(s) or release(s) (double)
- OUTPUT:
- newModel: COBRA model with added metabolite(s)
metID and all optional string arguments either have to be a single value or cell arrays. Charge and b have to be double arrays.
-
addReaction_updated
(model, rxnName, metaboliteList, stoichCoeffList, revFlag, lowerBound, upperBound, objCoeff, subSystem, grRule, geneNameList, systNameList, checkDuplicate, printLevel)¶ Adds a reaction to the model or modify an existing reaction
USAGE:
[model, rxnIDexists] = addReaction(model, rxnName, metaboliteList, stoichCoeffList, revFlag, lowerBound, upperBound, objCoeff, subSystem, grRule, geneNameList, systNameList, checkDuplicate, printLevel)- INPUTS:
model: COBRA model structure rxnName: Reaction name abbreviation (i.e. ‘ACALD’)
(Note: can also be a cell array {‘abbr’,’name’}- metaboliteList: Cell array of metabolite names or alternatively the
- reaction formula for the reaction
- stoichCoeffList: List of stoichiometric coefficients (reactants -ve,
- products +ve), empty if reaction formula is provided
- OPTIONAL INPUTS:
revFlag: Reversibility flag (Default = true) lowerBound: Lower bound (Default = 0 or -vMax`) upperBound: Upper bound (Default = vMax) objCoeff: Objective coefficient (Default = 0) subSystem: Subsystem (Default = ‘’) grRule: Gene-reaction rule in boolean format (and/or allowed)
(Default = ‘’);- geneNameList: List of gene names (used only for translation from
- common gene names to systematic gene names)
systNameList: List of systematic names checkDuplicate: Check S matrix too see if a duplicate reaction is
already in the model (Deafult false)printLevel: default = 1
- OUTPUTS:
model: COBRA model structure with new reaction rxnIDexists: Empty if the reaction did not exist previously, or if
checkDuplicate is false. Otherwise it contains the ID of an identical reaction already present in the model.
EXAMPLES
%1) Add a new irreversible reaction using the formula approach model = addReaction(model,’newRxn1’,’A -> B + 2 C’) %2) Add a the same reaction using the list approach model = addReaction(model,’newRxn1’,{‘A’,’B’,’C’},[-1 1 2],false);
-
checkMassChargeBalance_fixed
(model, printLevel, fileName)¶ [massImbalance, imBalancedMass, imBalancedCharge, imBalancedRxnBool, Elements] = checkMassChargeBalance(model, rxnBool, printLevel) checkMassChargeBalance tests for a list of reactions if these reactions are mass-balanced by adding all elements on left hand side and comparing them with the sums of elements on the right hand side of the reaction.
- INPUT
- model COBRA model structure .S m x n stoichiometric matrix .metForumlas m x 1 cell array of metabolite formulas .metCharges m x 1 double array of charges
- OPTIONAL INPUT
- printLevel {-1,(0),1}
- -1 = print out diagnostics on problem reactions to a file
- 0 = silent 1 = print elements as they are checked (display progress) 2 = also print out diagnostics on problem reactions to screen
model.SIntRxnBool Boolean of reactions heuristically though to be mass balanced.
- OUTPUTS
- massImbalance nRxn x nElement matrix with mass imbalance
- for each element checked. 0 if balanced.
- imBalancedMass nRxn x 1 cell with charge imbalance
- e.g. -3 H means three hydrogens disappear in the reaction.
- imBalancedCharge nRxn x 1 vector with charge imbalance,
- empty if no imbalanced reactions
- imBalancedRxnBool boolean vector indicating imbalanced
- reactions (including exchange reactions!)
- Elements nElement x 1 cell array of element
- abbreviations checked
- missingFormulaeBool nMet x 1 boolean vector indicating
- metabolites without formulae
balancedMetBool boolean vector indicating metabolites involved in balanced reactions
Ines Thiele 12/09 IT, 06/10, Corrected some bugs and improved speed. RF, 09/09/10, Support for very large models and printing to file. RF, 18/12/14, Default is now to check balancing of all reactions. Sergio Garcia 6/10/17, Commented out line 165,166,167 to avoid error at line 255. Also commented out three fprintf. Also, modified to report only charge imbalance in reactions included in model.SIntRxnBool
-
findHiCarbonRxns_updated
(model, nCarbonThr, currencyMets)¶ Returns the list of reactions that act on compounds which contain cabons greater than the threshold set.
USAGE:
[hiCarbonRxns, nCarbon] = findHiCarbonRxns(model, nCarbonThr)- INPUTS:
- model: Structure containing all necessary variables to describe a
- stoichiometric model
- nCarbonThr: defines the min # of carbons that a metabolite, that is
- acted on in a reaction, can have in the final list of reactions
currencyMets: Metabolite ids of metabolites to be ignored.
- OUTPUTS:
- hiCarbonRxns: The list of reactions that act on metabolites with
- greater than the threshold number of carbons
zeroCarbonRxns Reactions with no carbon nCarbon: The number of carbons in each metabolite in the model
-
findTransRxns_updated
(model, inclExc, rxnInds, inclObjAsExc, irrevFlag)¶ Identifes all transport reactions in a model, which are defined as reactions involved with metabolites in more than 1 compartment
USAGE:
[transRxns, nonTransRxns, transRxnsBool] = findTransRxns(model, inclExc, rxnInds, inclObjAsExc, irrevFlag)- INPUT:
- model: COBRA model structure
- OPTIONAL INPUT:
- inclExc: includes exchange reactions as transport = true
- (Default = false)
- rxnInds: indices of reactions to test for transport activity.
- (default = test all columns of model.S)
- inclObjAsExc: includes objective as an exchange reaction = true - this is
- passed to findExcRxns. (default = false)
- irrevFlag: model is irreversible = true - this is passed to findExcRxns.
- (default=false)
- OUTPUTS:
- transRxns: transport reactions in rxnInds nonTransRxns: non-transport reactions in rxnInds transRxnsBool: checks if inclExc or isNonexchangeTransport rxns vector is equal to 1
-
parseMetNames_updated
(metNames)¶ parseMetNames Figure out the base metabolite names and compartments for each metabolite
[baseMetNames,compSymbols,uniqueMetNames,uniqueCompSymbols] = parseMetNames(metNames)- INPUT
- metNames List of metabolite names
- OUTPUTS
baseMetNames List of met names without compartment symbol compSymbols Compartment symbols for each metabolite uniqueMetNames Unique metabolite names (w/o comp symbol) uniqueCompSymbols Unique compartment symbols
Metabolite names should describe the compartment assignment in either the form “metName[compName]” or “metName(compName)”
Markus Herrgard 10/4/06 Sergio Garcia 6/14/17, added suport for metabolite names with _compName
-
production_envelope
(model, deletions, lineColor, targetRxn, biomassRxn, geneDelFlag, nPts)¶ Calculates the byproduct secretion envelope
USAGE:
[biomassValues, targetValues, lineHandle] = productionEnvelope(model, deletions, lineColor, targetRxn, biomassRxn, geneDelFlag, nPts)- INPUTS:
- model: COBRA model structure
- OPTIONAL INPUTS:
- deletions: List of reaction or gene deletions (empty if wild type) lineColor: Line color for plotting (see help plot for color codes) targetRxn: Target metabolite production reaction name biomassRxn: Biomass rxn name geneDelFlag: Perform gene and not reaction deletions nPts: Number of points in the plot
- OUTPUTS:
- biomassValues: Biomass values for plotting targetValues: Target upper and lower bounds for plotting substrateValues: substrate uptake rate at each point. Used for yield. lineHandle: Handle to lineseries object
-
singleGeneDeletion_parallel
(model, method, geneList, verbFlag, uniqueGene)¶ Performs single gene deletion analysis using FBA, MOMA or linearMOMA
USAGE:
[grRatio, grRateKO, grRateWT, delRxns, hasEffect] = singleGeneDeletion(model, method, geneList, verbFlag)- INPUT:
- model: COBRA model structure including gene-reaction associations
- OPTIONAL INPUTS:
- method: Either ‘FBA’, ‘MOMA’ or ‘lMOMA’ (Default = ‘FBA’) geneList: List of genes to be deleted (default = all genes) verbFlag: Verbose output (Default false) uniqueGene: Run unique gene deletion (default = 0).
- OUTPUTS:
grRatio: Computed growth rate ratio between deletion strain and wild type grRateKO: Deletion strain growth rates (1/h) grRateWT: Wild type growth rate (1/h) hasEffect: Does a gene deletion affect anything (i.e. are any reactions
removed from the model)delRxns: List of deleted reactions for each gene KO fluxSolution: FBA/MOMA/lMOMA fluxes for KO strains
-
singleRxnDeletion_parallel
(model, method, rxnList, verbFlag)¶ Performs single reaction deletion analysis using FBA, MOMA or linearMOMA
USAGE:
[grRatio, grRateKO, grRateWT, hasEffect, delRxns, hasEffect] = singleRxnDeletion(model, method, rxnList, verbFlag)- INPUT:
- model: COBRA model structure including reaction names
- OPTIONAL INPUTS:
- method: Either ‘FBA’, ‘MOMA’, or ‘lMOMA’ (Default = ‘FBA’) rxnList: List of reactions to be deleted (Default = all reactions) verbFlag: Verbose output (Default = false)
- OUTPUTS:
- grRatio: Computed growth rate ratio between deletion strain and wild type grRateKO: Deletion strain growth rates (1/h) grRateWT: Wild type growth rate (1/h) hasEffect: Does a reaction deletion affect anything delRxn: Deleted reaction fluxSolution: FBA/MOMA/lMOMA fluxes for KO strains
-Sergio Garcia: Do it in parallel. 6/11/2017