/
test_syntax_checks.py
76 lines (50 loc) · 1.73 KB
/
test_syntax_checks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Local Imports
import bel.lang.belobj
from bel.Config import config
bo = bel.lang.belobj.BEL(
config["bel"]["lang"]["default_bel_version"], config["bel_api"]["servers"]["api_url"]
)
SPECIFIED_VERSION_UNDERLINED = config["bel"]["lang"]["default_bel_version"]
#####################
# SYNTAX TEST CASES #
#####################
def test_extra_right_paren():
s = 'a(CHEBI:"nitric oxide")) decreases r(HGNC:CFTR, var("c.1521_1523delCTT"))'
bo.parse(s)
print(bo.validation_messages)
def test_extra_left_paren():
s = 'a((CHEBI:"oxygen atom")'
bo.parse(s)
print(bo.validation_messages)
def test_missing_parens():
s = "act(p(MGI:Akt1), ma(kin)) decreases MGI:Cdkn1b"
bo.parse(s)
print(bo.validation_messages)
def test_bad_namespace():
s = 'abundance(CHEBI:"prostaglandin J2":TEST)'
bo.parse(s)
assert not bo.parse_valid
def test_arg_outside():
s = "act(p(HGNC:FOXO1)) ma(tscript)"
bo.parse(s)
assert not bo.parse_valid
def test_no_comma_between_args():
s = "act(p(HGNC:FOXO3) ma(tscript)) =| r(HGNC:MIR21)"
bo.parse(s)
assert not bo.parse_valid
def test_no_func_given():
s = "act(p(MGI:Akt1), ma(kin)) decreases (MGI:Cdkn1b)"
bo.parse(s)
assert not bo.parse_valid
##############################
# VALID STATEMENT TEST CASES #
##############################
def test_valid_statements():
stmts = [
"p(HGNC:AKT1) increases p(HGNC:EGF)",
"proteinAbundance(HGNC:AKT1, proteinModification(P, T, 308)) directlyIncreases activity(proteinAbundance(HGNC:AKT1), molecularActivity(DEFAULT:kin))",
'a(CHEBI:"nitric oxide") decreases r(HGNC:CFTR, var("c.1521_1523delCTT"))',
]
for s in stmts:
bo.parse(s)
assert bo.parse_valid