Skip to content

Commit

Permalink
term lookup fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wshayes committed Oct 27, 2020
1 parent f48ca60 commit ff107e3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions bel/db/arangodb.py
Expand Up @@ -211,6 +211,7 @@ def get_resources_handles(client, username=None, password=None):
IndexDefinition(
type="persistent", fields=["obsolete_keys[*]"], unique=False, sparse=True
),
IndexDefinition(type="persistent", fields=["synonyms[*]"], unique=False, sparse=True),
],
)
update_index_state(
Expand Down
5 changes: 4 additions & 1 deletion bel/terms/terms.py
Expand Up @@ -60,11 +60,14 @@ def get_terms(term_key: Key) -> List[Term]:
results = list(resources_db.aql.execute(query))

if len(results) == 0:
if namespace == "EG":
return []

(namespace, label) = term_key.split(":")
query = f"""
for doc in {terms_coll_name}
filter doc.namespace == "{namespace}"
filter "{label}" in doc.synonyms
filter '{label}' in doc.synonyms
return doc
"""
results = list(resources_db.aql.execute(query))
Expand Down
18 changes: 18 additions & 0 deletions tests/lang/test_ast.py
Expand Up @@ -64,6 +64,24 @@ def test_ast_orthologization():
assert False, "Not orthologizable"


def test_ast_nested_orthologization():

assertion = AssertionStr(entire="p(HGNC:AKT1) increases (p(HGNC:AKT1) increases p(HGNC:EGF))")
ast = bel.lang.ast.BELAst(assertion=assertion)

orthologizable = ast.orthologizable("TAX:10090")
print("Orthologizable", orthologizable)

ast.orthologize("TAX:10090").decanonicalize()

expected = ""

result = ast.to_string()
print("Result", result)

assert result == expected


def test_ast_orthologizable():
"""Test AST orthologization"""

Expand Down

0 comments on commit ff107e3

Please sign in to comment.