Skip to content

Commit

Permalink
Added comments in ops.py showing next possible steps for test_transit…
Browse files Browse the repository at this point in the history
…ion and added decorator to all unit tests that require sbmlmath
  • Loading branch information
nanglo123 committed Sep 8, 2023
1 parent 53a1e7c commit d41f00b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mira/modeling/askenet/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ def remove_transition(tm, transition_id):


@amr_to_mira
# option 1 take in optional parameters dict if rate law contains parameters that aren't already present
# option 2, reverse engineer rate law and find parameters and states within the rate law and add to model
def add_transition(tm, new_transition_id, rate_law_mathml, src_id=None, tgt_id=None):
rate_law_sympy = SympyExprStr(mathml_to_expression(rate_law_mathml))
if src_id is None and tgt_id is None:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_modeling/test_askenet_ops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import requests
import pytest
from copy import deepcopy as _d
from mira.modeling.askenet.ops import *
from sympy import *
Expand Down Expand Up @@ -185,6 +186,7 @@ def test_remove_observable_or_parameter(self):

self.assertEqual(old_obs['id'], new_obs['id'])

@pytest.mark.sbmlmath
def test_add_observable(self):
amr = _d(self.sir_amr)
new_id = 'testinf'
Expand All @@ -203,6 +205,7 @@ def test_add_observable(self):
self.assertEqual(xml_expression, new_observable_dict[new_id]['expression_mathml'])
self.assertEqual(sstr(mathml_to_expression(xml_expression)), new_observable_dict[new_id]['expression'])

@pytest.mark.sbmlmath
def test_replace_parameter_id(self):
old_id = 'beta'
new_id = 'TEST'
Expand Down Expand Up @@ -252,6 +255,7 @@ def test_replace_parameter_id(self):
self.assertEqual(mathml_to_expression(old_parameter['units']['expression_mathml']),
mathml_to_expression(new_parameter['units']['expression_mathml']))

@pytest.mark.sbmlmath
def test_add_parameter(self):
amr = _d(self.sir_amr)

Expand Down Expand Up @@ -313,6 +317,7 @@ def test_remove_transition(self):
for new_transition in new_model_transition:
self.assertNotEquals(removed_transition, new_transition['id'])

@pytest.mark.sbmlmath
def test_add_transition(self):
infected = Concept(name="infected_population", identifiers={"ido": "0000511"})
recovered = Concept(name="immune_population", identifiers={"ido": "0000592"})
Expand Down Expand Up @@ -380,6 +385,7 @@ def test_add_transition(self):
self.assertEqual(sstr(mathml_to_expression(expression_xml)),
natural_degradation_rates_dict[new_transition_id]['expression'])

@pytest.mark.sbmlmath
def test_replace_rate_law_sympy(self):
transition_id = 'inf'
target_expression_xml_str = '<apply><plus/><ci>X</ci><cn>8</cn></apply>'
Expand All @@ -394,6 +400,7 @@ def test_replace_rate_law_sympy(self):
self.assertEqual(sstr(target_expression_sympy), new_rate['expression'])
self.assertEqual(target_expression_xml_str, new_rate['expression_mathml'])

@pytest.mark.sbmlmath
def test_replace_rate_law_mathml(self):
amr = _d(self.sir_amr)
transition_id = 'inf'
Expand All @@ -409,6 +416,7 @@ def test_replace_rate_law_mathml(self):
self.assertEqual(sstr(target_expression_sympy), new_rate['expression'])
self.assertEqual(target_expression_xml_str, new_rate['expression_mathml'])

@pytest.mark.sbmlmath
# Following 2 unit tests only test for replacing expressions in observables, not initials
def test_replace_expression_sympy(self):
object_id = 'noninf'
Expand All @@ -422,6 +430,7 @@ def test_replace_expression_sympy(self):
self.assertEqual(sstr(target_expression_sympy), new_obs['expression'])
self.assertEqual(target_expression_xml_str, new_obs['expression_mathml'])

@pytest.mark.sbmlmath
def test_replace_expression_mathml(self):
object_id = 'noninf'
amr = _d(self.sir_amr)
Expand Down

0 comments on commit d41f00b

Please sign in to comment.