Skip to content

Commit

Permalink
fix to enable to vary or keep constant the reactant species specified…
Browse files Browse the repository at this point in the history
… as boundary species in the original SBML file
  • Loading branch information
mayalenE committed Feb 26, 2024
1 parent 40f766b commit dc19c4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sbmltoodejax/modulegeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def GenerateModel(modelData, outputFilePath,
ModelStepName: str='ModelStep',
ModelRolloutName: str='ModelRollout',
vary_constant_reactants: bool=False,
vary_boundary_reactants: bool=False,
deltaT: float =0.1,
atol: float=1e-6,
rtol: float = 1e-12,
Expand Down Expand Up @@ -398,8 +399,9 @@ def ParseRHS(rawRateLaw, extended_param_names=[], reaction_name=None, yvar="y",
reactionCounter += 1
reaction = reactions[rxnId]
for reactant in reaction.reactants:
if (reactant[1] in y_indexes) and (not species[reactant[1]].isBoundarySpecies):
stoichCoeffMat = stoichCoeffMat.at[y_indexes[reactant[1]], reactionIndex[rxnId]].add(reactant[0])
if (reactant[1] in y_indexes):
if (not species[reactant[1]].isBoundarySpecies) or vary_boundary_reactants:
stoichCoeffMat = stoichCoeffMat.at[y_indexes[reactant[1]], reactionIndex[rxnId]].add(reactant[0])

rateArray = ['0.0'] * len(y_indexes)
for rule_name, rule in rateRules.items():
Expand Down
8 changes: 6 additions & 2 deletions sbmltoodejax/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from sbmltoodejax.modulegeneration import GenerateModel
from sbmltoodejax.parse import ParseSBMLFile

def generate_biomodel(model_idx, model_fp="jax_model.py", deltaT=0.1, atol=1e-6, rtol=1e-12, mxstep=5000000):
def generate_biomodel(model_idx, model_fp="jax_model.py",
vary_constant_reactants=False, vary_boundary_reactants=False,
deltaT=0.1, atol=1e-6, rtol=1e-12, mxstep=5000000):
"""Calls the `sbmltoodejax.modulegeneration.GenerateModel` for a SBML model hosted on the BioModel website and indexed by the provided `model_idx`.
Args:
Expand All @@ -19,7 +21,9 @@ def generate_biomodel(model_idx, model_fp="jax_model.py", deltaT=0.1, atol=1e-6,
"""
model_xml_body = get_content_for_model(model_idx)
model_data = ParseSBMLFile(model_xml_body)
GenerateModel(model_data, model_fp, deltaT=deltaT, atol=atol, rtol=rtol, mxstep=mxstep)
GenerateModel(model_data, model_fp,
vary_constant_reactants=vary_constant_reactants, vary_boundary_reactants=vary_boundary_reactants,
deltaT=deltaT, atol=atol, rtol=rtol, mxstep=mxstep)

return model_fp

Expand Down

0 comments on commit dc19c4a

Please sign in to comment.