Skip to content

Commit

Permalink
Merge pull request #114 from sybila/improve-parsing
Browse files Browse the repository at this point in the history
Parsing improvements - merge `improve-parsing` into `master`
  • Loading branch information
xtrojak authored May 9, 2024
2 parents 69b45aa + 20de063 commit ab96642
Show file tree
Hide file tree
Showing 88 changed files with 2,480 additions and 1,472 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ jobs:
max-parallel: 5

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.11
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda install -y python=3.11
conda env update --file conda/environment.yml --name base
- name: Test with pytest
run: |
conda install pytest pytest-cov
pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml --ignore='Testing/test_formal_methods.py'
pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml --ignore='Testing/test_formal_methods.py' --ignore='Testing/parsing/test_remote_parsing.py'
7 changes: 6 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.8"

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
configuration: docs/source/conf.py

python:
version: "3.8"
install:
- requirements: docs/requirements.txt
15 changes: 15 additions & 0 deletions Testing/models/get_model_str.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os

def get_model_str(model_name: str) -> str:
if not os.path.splitext(model_name)[1]:
model_name += ".txt"
script_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(script_dir, model_name)

try:
with open(file_path, "r") as file:
model_str = file.read()
return model_str
except FileNotFoundError:
print(f"File {file_path} not found")
return None
12 changes: 12 additions & 0 deletions Testing/models/model1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! rules
X()::rep => @ k1*[X()::rep]
Z()::rep => X()::rep
=> Y()::rep @ 1/(1+([X()::rep])**4)

#! inits
2 X()::rep
Y()::rep

#! definitions
k1 = 0.05
k2 = 0.12
12 changes: 12 additions & 0 deletions Testing/models/model2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! rules
X(K{i})::rep => X(K{p})::rep @ k1*[X()::rep]
X(T{a})::rep => X(T{o})::rep @ k2*[Z()::rep]
=> Y(P{f})::rep @ 1/(1+([X()::rep])**4)

#! inits
2 X(K{c}, T{e}).X(K{c}, T{j})::rep
Y(P{g}, N{l})::rep

#! definitions
k1 = 0.05
k2 = 0.12
12 changes: 12 additions & 0 deletions Testing/models/model3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! rules
Y{i}::rep => Y{a}::rep @ p*[Y{i}::rep]
Y{i}::rep => Y{-}::rep @ (1-p)*[Y{i}::rep]
X()::rep + Y{a}::rep => X().Y{a}::rep @ q*[X()::rep]*[Y{a}::rep]
X(K{i}).Y{_}::rep => X(K{p}).Y{_}::rep @ p*[X(K{i}).Y{_}::rep] // also here

#! inits
2 X(K{i})::rep
1 Y{i}::rep

#! definitions
p = 0.3
11 changes: 11 additions & 0 deletions Testing/models/model4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! rules
X()::rep => @ k1*[X()::rep]
Z()::rep => X()::rep @ k2
=> Y()::rep @ 1/(1+([X()::rep])**4)

#! inits
2 X()::rep
Y()::rep

#! definitions
k2 = 5
12 changes: 12 additions & 0 deletions Testing/models/model5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! rules
// commenting
X(K{i})::rep => X(K{p})::rep @ k1*[X()::rep] // also here
X(T{a})::rep => X(T{o})::rep @ k2*[Z()::rep]
=> Y(P{f})::rep @ 1/(1+([X()::rep])**4) // ** means power (^)

#! inits
2 X(K{c}, T{e})::rep
Y(P{g}, N{l})::rep

#! definitions
k2 = 0.05 // also comment
12 changes: 12 additions & 0 deletions Testing/models/model6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! rules
X()::rep => @ k1*[X()::rep]
Z()::rep => X()::rep @ k2
=> Y()::rep @ 1/(1+([X()::rep])**4)

#! inits
2 X()::rep
Y()::rep

#! definitions
k2 = 5
k1 = 2
13 changes: 13 additions & 0 deletions Testing/models/model7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! rules
// commenting
X(K{i})::rep => X(K{p})::rep @ k1*[X()::rep] // also here
X(T{a})::rep => X(T{o})::rep @ k2*[Z()::rep]
=> Y(P{f})::rep @ 1/(1+([X()::rep])**4) // ** means power (^)

#! inits
2 X(K{c}, T{e}).X(K{c}, T{j})::rep
Y(P{g}, N{l})::rep

#! definitions
k2 = 0.05 // also comment
k1 = 2
15 changes: 15 additions & 0 deletions Testing/models/model_TS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! rules
=> K(S{u},T{i})::cyt @ omega
K(S{u})::cyt => K(S{p})::cyt @ alpha*[K(S{u})::cyt]
K(S{p})::cyt + B{a}::cyt => K(S{p}).B{a}::cyt @ beta*[K(S{p})::cyt]*[B{a}::cyt]
B{_}::cyt => @ gamma*[B{_}::cyt]
K(S{u},T{i}).B{a}::cyt => @ 5

#! inits
1 B{a}::cyt

#! definitions
alpha = 10
beta = 5
gamma = 2
omega = 3
10 changes: 10 additions & 0 deletions Testing/models/model_abstract.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! rules
=> X()::rep @ k2*[T{_}::rep]
T{a}::rep => T{i}::rep @ k1*[T{_}::rep]

#! inits
10 T{a}::rep

#! definitions
k1 = 0.05
k2 = 0.12
15 changes: 15 additions & 0 deletions Testing/models/model_bigger_TS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! rules
=> 2 K(S{u},T{i})::cyt @ omega
K(S{u})::cyt => K(S{p})::cyt @ alpha*[K(S{u})::cyt]
K(S{p})::cyt + B{a}::cyt => K(S{p}).B{a}::cyt @ beta*[K(S{p})::cyt]*[B{a}::cyt]
B{_}::cyt => @ gamma*[B{_}::cyt]
K(S{u},T{i}).B{a}::cyt => @ 5

#! inits
6 B{a}::cyt

#! definitions
alpha = 10
beta = 5
gamma = 2
omega = 3
5 changes: 5 additions & 0 deletions Testing/models/model_cmplx_in_abstr_seq1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! rules
S{i}::A()::A2::cell => A()::cell

#! complexes
A2 = A().A()
2 changes: 2 additions & 0 deletions Testing/models/model_cmplx_in_abstr_seq2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#! rules
S{i}::A()::A().A()::cell => A()::cell
15 changes: 15 additions & 0 deletions Testing/models/model_even_bigger_TS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! rules
=> K(S{u},T{i})::cyt @ omega
K(S{u})::cyt => K(S{p})::cyt @ alpha*[K(S{u})::cyt]
K(S{p})::cyt + B{a}::cyt => K(S{p}).B{a}::cyt @ beta*[K(S{p})::cyt]*[B{a}::cyt]
B{_}::cyt => @ gamma*[B{_}::cyt]
K(S{u},T{i}).B{a}::cyt => @ 5

#! inits
10 B{a}::cyt

#! definitions
alpha = 10
beta = 5
gamma = 2
omega = 3
9 changes: 9 additions & 0 deletions Testing/models/model_for_bound.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! rules
=> A{i}::cyt @ k
=> C{i}::cyt @ k

#! inits
2 B{i}::cyt

#! definitions
k = 1
16 changes: 16 additions & 0 deletions Testing/models/model_for_matching.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! rules
K(S{i}).B()::cyt + C{_}::cell => K(S{i})::cyt + B()::cyt + C{_}::cell @ 3*[K(S{i}).B()::cyt]/2*v_1
A{p}.K(S{i})::cyt => A{i}::cyt + K(S{a})::cyt + C{a}::cyt @ 0.3*[A{p}.K(S{i})::cyt]
K(S{i},T{i})::cyt + C{_}::cell => K(S{a},T{i})::cyt @ k2*[K(S{i},T{i})::cyt]
C{_}::cell + C{_}::cell => C{_}.C{_}::cell @ v_1*[C{_}::cell]**2
C{_}::cell + K()::cell => C{_}.K()::cell @ v_1*[C{_}::cell]**2

#! inits
2 K(S{i},T{i}).B(T{a})::cyt
1 A{p}.K(S{i},T{i})::cyt
2 C{i}::cell
1 C{a}::cell

#! definitions
v_1 = 0.05
k2 = 0.12
28 changes: 28 additions & 0 deletions Testing/models/model_miyoshi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! rules
S{u}::KaiC()::KaiC6::cyt => S{p}::KaiC()::KaiC6::cyt @ (kcat1*[KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
S{p}::KaiC()::KaiC6::cyt => S{u}::KaiC()::KaiC6::cyt @ (kcat2*[KaiB4{a}.KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
T{u}::KaiC()::KaiC6::cyt => T{p}::KaiC()::KaiC6::cyt @ (kcat3*[KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
T{p}::KaiC()::KaiC6::cyt => T{u}::KaiC()::KaiC6::cyt @ (kcat4*[KaiB4{a}.KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
KaiB4{i}::cyt => KaiB4{a}::cyt @ (kcatb2*[KaiB4{i}::cyt])/(Kmb2 + [KaiB4{i}::cyt])
KaiB4{a}::cyt => KaiB4{i}::cyt @ (kcatb1*[KaiB4{a}::cyt])/(Kmb1 + [KaiB4{a}::cyt])
KaiB4{a}.KaiA2()::cyt => KaiB4{a}::cyt + KaiA2()::cyt @ k12*[KaiB4{a}.KaiA2()::cyt]
KaiC6::cyt => 6 KaiC()::cyt @ kdimer*[KaiC6::cyt]
6 KaiC()::cyt => KaiC6::cyt @ kdimer*[KaiC()::cyt]*([KaiC()::cyt] - 1)*([KaiC()::cyt] - 2)*([KaiC()::cyt] - 3)*([KaiC()::cyt] - 4)*([KaiC()::cyt] - 5)

#! inits
6 KaiC(S{p},T{p})::cyt
1 KaiB4{a}.KaiA2()::cyt

#! definitions
kcat1 = 0.539
kcat3 = 0.89
Km = 0.602
kcatb2 = 0.346
kcatb1 = 0.602
Kmb2 = 66.75
Kmb1 = 2.423
k12 = 0.0008756
kdimer = 1.77

#! complexes
KaiC6 = KaiC().KaiC().KaiC().KaiC().KaiC().KaiC()
33 changes: 33 additions & 0 deletions Testing/models/model_miyoshi_non_param.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! rules
S{u}:KaiC():KaiC6::cyt => S{p}:KaiC():KaiC6::cyt @ (kcat1*[KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
S{p}:KaiC():KaiC6::cyt => S{u}:KaiC():KaiC6::cyt @ (kcat2*[KaiB4{a}.KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
T{u}:KaiC():KaiC6::cyt => T{p}:KaiC():KaiC6::cyt @ (kcat3*[KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
T{p}:KaiC():KaiC6::cyt => T{u}:KaiC():KaiC6::cyt @ (kcat4*[KaiB4{a}.KaiA2()::cyt]*[KaiC6::cyt])/(Km + [KaiC6::cyt])
KaiB4{i}::cyt => KaiB4{a}::cyt @ (kcatb2*[KaiB4{i}::cyt])/(Kmb2 + [KaiB4{i}::cyt])
KaiB4{a}::cyt => KaiB4{i}::cyt @ (kcatb1*[KaiB4{a}::cyt])/(Kmb1 + [KaiB4{a}::cyt])
KaiB4{a}.KaiA2()::cyt => KaiB4{a}::cyt + KaiA2()::cyt @ k12*[KaiB4{a}.KaiA2()::cyt]
KaiC6::cyt => 6 KaiC()::cyt @ kdimer*[KaiC6::cyt]
6 KaiC()::cyt => KaiC6::cyt @ kdimer*[KaiC()::cyt]
KaiC().KaiC()::cyt => KaiC()::cyt + KaiC()::cyt @ kcat1

#! inits
6 KaiC(S{p},T{p})::cyt
1 KaiB4{a}.KaiA2()::cyt
1 KaiC(S{u},T{p})::cyt
1 KaiC(S{u},T{p}).KaiC(S{p},T{p})::cyt

#! definitions
kcat2 = 0.539
kcat4 = 0.89
kcat1 = 0.539
kcat3 = 0.89
Km = 0.602
kcatb2 = 0.346
kcatb1 = 0.602
Kmb2 = 66.75
Kmb1 = 2.423
k12 = 0.0008756
kdimer = 1.77

#! complexes
KaiC6 = KaiC().KaiC().KaiC().KaiC().KaiC().KaiC()
11 changes: 11 additions & 0 deletions Testing/models/model_nonreachable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! rules
K(S{i}).B()::cyt => K(S{a})::cyt + B()::cyt @ 3*[K(S{i}).B()::cyt]/2*v_1
K(S{a})::cyt + A{i}::cyt => K(S{a}).A{i}::cyt

#! inits
2 K(S{i}).B()::cyt
1 A{i}::cyt

#! definitions
v_1 = 0.05
k2 = 0.12
12 changes: 12 additions & 0 deletions Testing/models/model_parametrised.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! rules
// commenting
X(K{i})::rep => X(K{p})::rep @ k1*[X()::rep] // also here
X(T{a})::rep => X(T{o})::rep @ k2*[Z()::rep]
=> Y(P{f})::rep @ 1/(v_3+([X()::rep])**4) // ** means power (^)

#! inits
2 X(K{c}, T{e}).X(K{c}, T{j})::rep
Y(P{g}, N{l})::rep // comment just 1 item

#! definitions
k1 = 0.05
15 changes: 15 additions & 0 deletions Testing/models/model_parametrised2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! rules
=> K(S{u},T{i})::cyt @ omega
K(S{u})::cyt => K(S{p})::cyt @ alpha*[K(S{u})::cyt]
K(S{p})::cyt + B{a}::cyt => K(S{p}).B{a}::cyt @ beta*[K(S{p})::cyt]*[B{a}::cyt]
B{_}::cyt => @ gamma*[B{_}::cyt]
K(S{u},T{i}).B{a}::cyt => @ 5

#! inits
1 B{a}::cyt

#! definitions
alpha = 10
beta = 5
//gamma = 2
omega = 3
12 changes: 12 additions & 0 deletions Testing/models/model_reachable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! rules
K(S{i}).B()::cyt => K(S{a})::cyt + B()::cyt @ 3*[K(S{i}).B()::cyt]/2*v_1
K(S{a})::cyt + A{i}::cyt => K(S{a}).A{i}::cyt
K().A{i}::cyt => K().A{a}::cyt

#! inits
2 K(S{i}).B()::cyt
1 A{i}::cyt

#! definitions
v_1 = 0.05
k2 = 0.12
15 changes: 15 additions & 0 deletions Testing/models/model_with_comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! rules
// commenting
X(K{i})::rep => X(K{p})::rep @ k1*[X()::rep] // also here
X(T{a})::rep => X(T{o})::rep @ k2*[Z()::rep]
=> Y(P{f})::rep @ 1/(1+([X()::rep])**4) // ** means power (^)

#! inits
// here
2 X(K{c}, T{e}).X(K{c}, T{j})::rep
Y(P{g}, N{l})::rep // comment just 1 item

#! definitions
// and
k1 = 0.05 // also
k2 = 0.12
Loading

0 comments on commit ab96642

Please sign in to comment.