def _load_constraintbased_model(sbml_model, model): model_extended = model.copy() _load_compartments(sbml_model, model_extended) _load_metabolites(sbml_model, model_extended) _load_reactions(sbml_model, model_extended) _load_cobra_bounds(sbml_model, model_extended) _load_cobra_objective(sbml_model, model_extended) reactions_ids = list(model_extended.reactions.keys())[len(model.reactions):] return (model_extended, reactions_ids)
def _load_constraintbased_model(sbml_model, model): model_extended = model.copy() _load_compartments(sbml_model, model_extended) _load_metabolites(sbml_model, model_extended) _load_reactions(sbml_model, model_extended) _load_cobra_bounds(sbml_model, model_extended) _load_cobra_objective(sbml_model, model_extended) reactions_ids = model_extended.reactions.keys()[len(model.reactions):] return (model_extended, reactions_ids)
def load_kinetic_model(filename, kmap=None): """ Load the dynamic model present in a SBML file. Args: filename (str): SBML file. kmap (dict): Dictionary with the parameters that can be used in the strain optimization process for each reaction.{id_reaction: [param1, param2]} Returns: KineticModel Contains all information related with the dynamic model (reactions, kinetic equations, metabolites, compartments, etc.) """ document = readSBMLFromFile(filename) sbmlModel = document.getModel() if sbmlModel is None: raise IOError('Failed to load model.') model = KineticModel(sbmlModel.getId()) _load_compartments(sbmlModel, model) _load_metabolites(sbmlModel, model) _load_reactions(sbmlModel, model) _load_concentrations(sbmlModel, model) _load_global_parameters(sbmlModel, model) _load_local_parameters(sbmlModel, model) _load_ratelaws(sbmlModel, model) _load_assignment_rules(sbmlModel, model) # parse rates, rules and xdot expressions model._set_parsed_attr() if isinstance(kmap, str): aux = OrderedDict([(rId, re.findall(kmap, ratelaw)) for rId, ratelaw in model.ratelaws.items()]) # aux = OrderedDict([(rId , [rId+"_"+x for x in re.findall("(rmax\w*)", ratelaw)]) # for rId, ratelaw in model.ratelaws.items()]) # CHASSAGNOLE model.reacParamsFactors = OrderedDict([(rId, params) for rId, params in aux.items() if len(params) > 0]) else: model.set_reactions_parameters_factors(kmap) return model