Skip to content

Commit

Permalink
tidying up
Browse files Browse the repository at this point in the history
  • Loading branch information
teddygroves committed Dec 17, 2024
1 parent c7d9905 commit d4fc52e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def get_steady_state_from_params(parameters: PyTree):
jacobian = jax.jacrev(get_steady_state_from_params)(model.parameters)

```

### Load a kinetic model from an sbml file

```python
Expand Down
15 changes: 9 additions & 6 deletions scripts/sbml_demo.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
from pathlib import Path

import jax
import jax.numpy as jnp
from enzax.sbml import load_libsbml_model, sbml_to_enzax

from enzax.sbml import load_libsbml_model_from_file, sbml_to_enzax
from enzax.steady_state import get_kinetic_model_steady_state

jax.config.update("jax_enable_x64", True)

file_path = "tests/data/brusselator.xml"
model_libsbml = load_libsbml_model(file_path)
file_path = Path("tests") / "data" / "exampleode.xml"
model_libsbml = load_libsbml_model_from_file(file_path)
model = sbml_to_enzax(model_libsbml)

y0 = jnp.array([2.0, 4])
model.flux(y0)
print(f"Flux at {str(y0)}: " + str(model.flux(y0)))

model.dcdt(t=1, conc=y0)
print(f"dcdt at {str(y0)}, t=1: " + str(model.dcdt(t=1, conc=y0)))

guess = jnp.full((2), 0.01)
steady_state = get_kinetic_model_steady_state(model, guess)
print(steady_state)
print("Steady state: " + str(steady_state))
4 changes: 2 additions & 2 deletions tests/test_sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
)
def test_load_libsbml_model(file_path):
sbml.load_libsbml_model(file_path)
sbml.load_libsbml_model_from_file(file_path)


@pytest.mark.parametrize(
Expand All @@ -31,7 +31,7 @@ def test_load_libsbml_model(file_path):
],
)
def test_sbml_to_enzax(path, expected, guess):
libsbml_model = sbml.load_libsbml_model(path)
libsbml_model = sbml.load_libsbml_model_from_file(path)
model = sbml.sbml_to_enzax(libsbml_model)
steady_state = get_kinetic_model_steady_state(model, guess)
assert jnp.isclose(steady_state, expected).all()

0 comments on commit d4fc52e

Please sign in to comment.