-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document sbml functionality and add convenience functions
- Loading branch information
1 parent
1669e64
commit c7d9905
Showing
7 changed files
with
168 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ::: enzax.sbml | ||
options: | ||
show_root_heading: true | ||
filters: | ||
- "!check" | ||
members: | ||
- load_libsbml_model_from_url | ||
- load_libsbml_model_from_file | ||
- sbml_to_enzax | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,19 @@ | ||
import jax | ||
import jax.numpy as jnp | ||
from enzax import sbml | ||
from enzax.kinetic_model import KineticModelStructure, KineticModelSbml | ||
from enzax.sbml import load_libsbml_model, sbml_to_enzax | ||
from enzax.steady_state import get_kinetic_model_steady_state | ||
|
||
jax.config.update("jax_enable_x64", True) | ||
|
||
file_path = "tests/data/exampleode_names.xml" | ||
model_sbml = sbml.load_sbml(file_path) | ||
reactions_sympy = sbml.sbml_to_sympy(model_sbml) | ||
sym_module = sbml.sympy_to_enzax(reactions_sympy) | ||
|
||
species = [s.getId() for s in model_sbml.getListOfSpecies()] | ||
|
||
balanced_species = [ | ||
b.getId() for b in model_sbml.getListOfSpecies() if not b.boundary_condition | ||
] | ||
|
||
reactions = [reaction.getId() for reaction in model_sbml.getListOfReactions()] | ||
|
||
stoichiometry = { | ||
reaction.getId(): { | ||
r.getSpecies(): -r.getStoichiometry(), | ||
p.getSpecies(): p.getStoichiometry(), | ||
} | ||
for reaction in model_sbml.getListOfReactions() | ||
for r in reaction.getListOfReactants() | ||
for p in reaction.getListOfProducts() | ||
} | ||
|
||
structure = KineticModelStructure( | ||
stoichiometry=stoichiometry, | ||
species=species, | ||
reactions=reactions, | ||
balanced_species=balanced_species, | ||
) | ||
|
||
parameters_local = { | ||
p.getId(): p.getValue() | ||
for r in model_sbml.getListOfReactions() | ||
for p in r.getKineticLaw().getListOfParameters() | ||
} | ||
|
||
parameters_global = { | ||
p.getId(): p.getValue() | ||
for p in model_sbml.getListOfParameters() | ||
if p.constant | ||
} | ||
|
||
compartments = {c.getId(): c.volume for c in model_sbml.getListOfCompartments()} | ||
|
||
unbalanced_species = { | ||
u.getId(): u.getInitialConcentration() | ||
for u in model_sbml.getListOfSpecies() | ||
if u.boundary_condition | ||
} | ||
|
||
para = { | ||
**parameters_local, | ||
**parameters_global, | ||
**compartments, | ||
**unbalanced_species, | ||
} | ||
|
||
kinmodel_sbml = KineticModelSbml( | ||
parameters=para, | ||
structure=structure, | ||
sym_module=sym_module, | ||
) | ||
file_path = "tests/data/brusselator.xml" | ||
model_libsbml = load_libsbml_model(file_path) | ||
model = sbml_to_enzax(model_libsbml) | ||
|
||
y0 = jnp.array([2.0, 4]) | ||
kinmodel_sbml.flux(y0) | ||
model.flux(y0) | ||
|
||
kinmodel_sbml.dcdt(t=1, conc=y0) | ||
model.dcdt(t=1, conc=y0) | ||
|
||
guess = jnp.full((2), 0.01) | ||
steady_state = get_kinetic_model_steady_state(kinmodel_sbml, guess) | ||
steady_state = get_kinetic_model_steady_state(model, guess) | ||
print(steady_state) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters