From c485552812664da34f12dbd6b1bcf7b42e00ca2e Mon Sep 17 00:00:00 2001 From: Freiburgermsu_Sequoia Date: Wed, 18 Sep 2024 21:20:03 +0000 Subject: [PATCH] commKinetics updates --- modelseedpy/core/msmodelutl.py | 2 +- modelseedpy/fbapkg/commkineticpkg.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modelseedpy/core/msmodelutl.py b/modelseedpy/core/msmodelutl.py index 1b6671f4..c3892a52 100644 --- a/modelseedpy/core/msmodelutl.py +++ b/modelseedpy/core/msmodelutl.py @@ -625,7 +625,7 @@ def add_ms_reaction(self, rxn_dict, msdb_path=None, msdb_object=None, comp_trans return output def create_constraint(self, constraint, coef=None, sloppy=False, printing=False): - if printing: print(coef) + # if printing: print(coef) self.model.add_cons_vars(constraint, sloppy=sloppy) self.model.solver.update() if coef: constraint.set_linear_coefficients(coef) diff --git a/modelseedpy/fbapkg/commkineticpkg.py b/modelseedpy/fbapkg/commkineticpkg.py index 8ca3b1e1..529b8fa3 100644 --- a/modelseedpy/fbapkg/commkineticpkg.py +++ b/modelseedpy/fbapkg/commkineticpkg.py @@ -11,7 +11,7 @@ class CommKineticPkg(BaseFBAPkg): def __init__(self, model): BaseFBAPkg.__init__(self, model, "community kinetics", {}, {"commKin": "string"}) - def build_package(self, kinetic_coef, community_model, probs=None): + def build_package(self, kinetic_coef, community_model, probs={}): self.validate_parameters({}, [], {"kinetic_coef": kinetic_coef, "community": community_model}) for species in self.parameters["community"].members: if species.id+"_commKin" in self.model.constraints: @@ -25,6 +25,5 @@ def build_constraint(self, species, probs): for rxn in self.model.reactions: rxnIndex = int(FBAHelper.rxn_compartment(rxn)[1:]) if (rxnIndex == species.index and rxn != species.primary_biomass): - val = 1 if not isinstance(probs, dict) else probs.get(rxn.id, 1) - coef[rxn.forward_variable] = coef[rxn.reverse_variable] = val + coef[rxn.forward_variable] = coef[rxn.reverse_variable] = probs.get(rxn.id, 1) return BaseFBAPkg.build_constraint(self, "commKin", None, 0, coef, species.id)