Source code for cobra.manipulation.validate

from math import isinf, isnan

                           "SBO:0000628",  # DEMAND
                           "SBO:0000629",  # BIOMASS
                           "SBO:0000631",  # PSEUDOREACTION
                           "SBO:0000632",  # SINK

[docs]def check_mass_balance(model): warnings = [] unbalanced = {} for reaction in model.reactions: if reaction.annotation.get("SBO") not in NOT_MASS_BALANCED_TERMS: balance = reaction.check_mass_balance() if balance: unbalanced[reaction] = balance return unbalanced
[docs]def check_reaction_bounds(model): errors = [] for reaction in model.reactions: if reaction.lower_bound > reaction.upper_bound: errors.append("Reaction '%s' has lower bound > upper bound" % if isinf(reaction.lower_bound): errors.append("Reaction '%s' has infinite lower_bound" % elif isnan(reaction.lower_bound): errors.append("Reaction '%s' has NaN for lower_bound" % if isinf(reaction.upper_bound): errors.append("Reaction '%s' has infinite upper_bound" % elif isnan(reaction.upper_bound): errors.append("Reaction '%s' has NaN for upper_bound" % return errors
[docs]def check_metabolite_compartment_formula(model): errors = [] for met in model.metabolites: if met.compartment is not None and \ met.compartment not in model.compartments: errors.append("Metabolite '%s' compartment '%s' not found" % (, met.compartment)) if met.formula is not None and len(met.formula) > 0: if not met.formula.isalnum(): errors.append("Metabolite '%s' formula '%s' not alphanumeric" % (, met.formula)) return errors