Skip to content

Commit

Permalink
Updated bel obj in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wshayes committed Jan 4, 2018
1 parent 7bda4d4 commit d7eefce
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 65 deletions.
40 changes: 20 additions & 20 deletions tests/lang/test_canonicalize.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import bel.lang
import bel.lang.belobj

from bel.Config import config

bel_obj = bel.lang.bel.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])
bo = bel.lang.belobj.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])

# TODO Add test for specified canonical_targets - need to make sure BEL.bio API endpoint is updated to handle this querystring arg

Expand All @@ -13,11 +13,11 @@ def test_canon_one():

expected = 'activity(proteinAbundance(EG:207), molecularActivity(GO:"kinase activity"))'

bel_obj.parse(statement)
bo.parse(statement)

bel_obj.canonicalize()
bo.canonicalize()

assert bel_obj.ast.to_string(fmt='long') == expected
assert bo.ast.to_string(fmt='long') == expected


def test_canon_two():
Expand All @@ -26,11 +26,11 @@ def test_canon_two():

expected = 'activity(proteinAbundance(EG:4615), molecularActivity(GO:"catalytic activity")) directlyIncreases complexAbundance(proteinAbundance(EG:4615), proteinAbundance(EG:3654), proteinAbundance(EG:51135))'

bel_obj.parse(statement)
bo.parse(statement)

bel_obj.canonicalize()
bo.canonicalize()

assert bel_obj.ast.to_string(fmt='long') == expected
assert bo.ast.to_string(fmt='long') == expected


def test_canon_nested():
Expand All @@ -39,11 +39,11 @@ def test_canon_nested():

expected = 'activity(proteinAbundance(EG:4615), molecularActivity(GO:"catalytic activity")) directlyIncreases (complexAbundance(proteinAbundance(EG:4615), proteinAbundance(EG:3654), proteinAbundance(EG:51135)) directlyIncreases complexAbundance(proteinAbundance(EG:4615), proteinAbundance(EG:3654), proteinAbundance(EG:51135)))'

bel_obj.parse(statement)
bo.parse(statement)

bel_obj.canonicalize()
bo.canonicalize()

assert bel_obj.ast.to_string(fmt='long') == expected
assert bo.ast.to_string(fmt='long') == expected


def test_decanon_one():
Expand All @@ -52,11 +52,11 @@ def test_decanon_one():

expected = 'activity(proteinAbundance(HGNC:AKT1), molecularActivity(GO:"kinase activity"))'

bel_obj.parse(statement)
bo.parse(statement)

bel_obj.decanonicalize()
bo.decanonicalize()

assert bel_obj.ast.to_string(fmt='long') == expected
assert bo.ast.to_string(fmt='long') == expected


def test_decanon_two():
Expand All @@ -65,11 +65,11 @@ def test_decanon_two():

expected = 'activity(proteinAbundance(HGNC:MYD88), molecularActivity(GO:"catalytic activity")) directlyIncreases complexAbundance(proteinAbundance(HGNC:MYD88), proteinAbundance(HGNC:IRAK1), proteinAbundance(HGNC:IRAK4))'

bel_obj.parse(statement)
bo.parse(statement)

bel_obj.decanonicalize()
bo.decanonicalize()

assert bel_obj.ast.to_string(fmt='long') == expected
assert bo.ast.to_string(fmt='long') == expected


def test_decanon_nested():
Expand All @@ -78,8 +78,8 @@ def test_decanon_nested():

expected = 'activity(proteinAbundance(HGNC:MYD88), molecularActivity(GO:"catalytic activity")) directlyIncreases (complexAbundance(proteinAbundance(HGNC:MYD88), proteinAbundance(HGNC:IRAK1), proteinAbundance(HGNC:IRAK4)) directlyIncreases complexAbundance(proteinAbundance(HGNC:MYD88), proteinAbundance(HGNC:IRAK1), proteinAbundance(HGNC:IRAK4)))'

bel_obj.parse(statement)
bo.parse(statement)

bel_obj.decanonicalize()
bo.decanonicalize()

assert bel_obj.ast.to_string(fmt='long') == expected
assert bo.ast.to_string(fmt='long') == expected
40 changes: 20 additions & 20 deletions tests/lang/test_computed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bel.lang.bel
import bel.lang.belobj
from bel.Config import config

bel_obj = bel.lang.bel.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])
bo = bel.lang.belobj.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])


def test_abundance():
Expand All @@ -11,7 +11,7 @@ def test_abundance():
'MESHD:Inflammation componentOf bp(MESHD:Inflammation)'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -33,7 +33,7 @@ def test_complex():
'ma(tscript) componentOf act(complex(SCOMP:"Nfkb Complex"), ma(tscript))'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -58,7 +58,7 @@ def test_composite():
'ma(kin) componentOf act(p(HGNC:PRKCA), ma(kin))'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -79,7 +79,7 @@ def test_g():
'var("c.1521_1523delCTT") componentOf g(REF:NM_000492.3, var("c.1521_1523delCTT"))'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -101,7 +101,7 @@ def test_m():
expected_edges = ['MGI:Mir21 componentOf m(MGI:Mir21)'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -125,7 +125,7 @@ def test_p():
'MESHCS:Cytoplasm componentOf loc(MESHCS:Cytoplasm)',
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -145,7 +145,7 @@ def test_r():
'HGNC:ENO1 componentOf r(HGNC:ENO1)'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -167,7 +167,7 @@ def test_bp():
'ma(kin) componentOf act(p(HGNC:KDR), ma(kin))'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -187,7 +187,7 @@ def test_path():
'MESH:"Skin Diseases" componentOf path(MESH:"Skin Diseases")'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -209,7 +209,7 @@ def test_act():
'ma(GOMF:"transporter activity") componentOf {}'.format(statement)
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -233,7 +233,7 @@ def test_tloc():
'toLoc(MESHCL:"Cell Nucleus") componentOf {}'.format(statement)
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -254,7 +254,7 @@ def test_sec():
'a(CHEBI:"nitric oxide") componentOf sec(a(CHEBI:"nitric oxide"))'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -278,7 +278,7 @@ def test_surf():
'complex(p(HGNC:ITGA2), p(HGNC:ITGB1)) componentOf surf(complex(p(HGNC:ITGA2), p(HGNC:ITGB1)))'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -303,7 +303,7 @@ def test_deg():
'deg(p(HGNC:HBP1)) decreases p(HGNC:HBP1)'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -329,7 +329,7 @@ def test_rxn():
'products(a(CHEBI:"hydrogen peroxide"), a(CHEBI:oxygen)) componentOf {}'.format(statement)
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -352,7 +352,7 @@ def test_list():
'p(HGNC:MAPK9) componentOf list(p(HGNC:MAPK8), p(HGNC:MAPK9))'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -373,7 +373,7 @@ def test_nested_one():
'GO:"apoptotic process" componentOf bp(GO:"apoptotic process")'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand All @@ -395,7 +395,7 @@ def test_nested_two():
'CHEBI:EXAMPLE2 componentOf a(CHEBI:EXAMPLE2)'
]

actual_edges_partials = bel_obj.parse(statement).compute_edges()
actual_edges_partials = bo.parse(statement).compute_edges()
actual_edges = []

for each in actual_edges_partials:
Expand Down
24 changes: 12 additions & 12 deletions tests/lang/test_orthologize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bel.lang
import bel.lang.belobj
from bel.Config import config

bel_obj = bel.lang.bel.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])
bo = bel.lang.belobj.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])


# def test_ortho():
Expand All @@ -16,7 +16,7 @@
# ['EG:21858']]

# for index, (gene, species) in enumerate(gene_species_id_tuples):
# result = bel_obj.orthologize(gene, species)
# result = bo.orthologize(gene, species)
# assert result == list_of_expected[index]


Expand All @@ -25,27 +25,27 @@ def test_ortho_one():
statement = 'act(p(HGNC:AKT1), ma(GO:"kinase activity"))'
expected = 'activity(proteinAbundance(MGI:Akt1), molecularActivity(GO:"kinase activity"))'

bel_obj.parse(statement)
bel_obj.orthologize('TAX:10090')
bo.parse(statement)
bo.orthologize('TAX:10090')

assert bel_obj.ast.to_string(fmt='long') == expected
assert bo.ast.to_string(fmt='long') == expected


def test_ortho_two():

statement = 'act(p(HGNC:A1BG), ma(GO:"catalytic activity")) directlyIncreases complex(p(HGNC:ROCK1), p(HGNC:SOD1), p(HGNC:TIMP2))'
expected = 'activity(proteinAbundance(MGI:A1bg), molecularActivity(GO:"catalytic activity")) directlyIncreases complexAbundance(proteinAbundance(MGI:Rock1), proteinAbundance(MGI:Sod1), proteinAbundance(EG:21858))'

bel_obj.parse(statement)
bel_obj.orthologize('TAX:10090')
assert bel_obj.ast.to_string(fmt='long') == expected
bo.parse(statement)
bo.orthologize('TAX:10090')
assert bo.ast.to_string(fmt='long') == expected


def test_ortho_nested():

statement = 'act(p(HGNC:A1BG), ma(GO:"catalytic activity")) directlyIncreases (complex(p(HGNC:ROCK1), p(HGNC:SOD1), p(HGNC:TIMP2)) directlyIncreases complex(p(HGNC:ROCK1), p(HGNC:SOD1), p(HGNC:TIMP2)))'
expected = 'activity(proteinAbundance(MGI:A1bg), molecularActivity(GO:"catalytic activity")) directlyIncreases (complexAbundance(proteinAbundance(MGI:Rock1), proteinAbundance(MGI:Sod1), proteinAbundance(EG:21858)) directlyIncreases complexAbundance(proteinAbundance(MGI:Rock1), proteinAbundance(MGI:Sod1), proteinAbundance(EG:21858)))'

bel_obj.parse(statement)
bel_obj.orthologize('TAX:10090')
assert bel_obj.ast.to_string(fmt='long') == expected
bo.parse(statement)
bo.orthologize('TAX:10090')
assert bo.ast.to_string(fmt='long') == expected
18 changes: 9 additions & 9 deletions tests/lang/test_parse.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import bel.lang
import bel.lang.belobj
from bel.Config import config

bel_obj = bel.lang.bel.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])
bo = bel.lang.belobj.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])


def test_empty_string():

statement = ''
bel_obj.parse(statement)
bo.parse(statement)

assert bel_obj.ast is None
assert 'Please include a valid BEL statement.' in bel_obj.validation_messages[0][1]
assert bo.ast is None
assert 'Please include a valid BEL statement.' in bo.validation_messages[0][1]


def test_bad_string_start():

statement = '$$!@$'
bel_obj.parse(statement)
bo.parse(statement)

assert bel_obj.ast is None
assert 'Failed parse at position 0.' in bel_obj.validation_messages[0][1]
assert bo.ast is None
assert 'Failed parse at position 0.' in bo.validation_messages[0][1]

# def test_whitespace_string():
#
# statement = 'a('
# parse_obj = bel_obj.parse(statement)
# parse_obj = bo.parse(statement)
#
# print(parse_obj.error)
# assert isinstance(parse_obj, ParseObject)
Expand Down
4 changes: 2 additions & 2 deletions tests/lang/test_semantic_checks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
import bel.lang
import bel.lang.belobj
from bel.Config import config

bo = bel.lang.bel.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])
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']

Expand Down
4 changes: 2 additions & 2 deletions tests/lang/test_syntax_checks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bel.lang.bel
import bel.lang.belobj
from bel.Config import config

bo = bel.lang.bel.BEL(config['bel']['lang']['default_bel_version'], config['bel_api']['servers']['api_url'])
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']

Expand Down

0 comments on commit d7eefce

Please sign in to comment.