Exemplo n.º 1
0
def test_ast_parse_fus():

    assertion = AssertionStr(
        entire="act(p(fus(HGNC:EWSR1, start, HGNC:FLI1, end)), ma(tscript))")

    ast = bel.lang.ast.BELAst(assertion=assertion)

    print("To String", ast.to_string())

    assert (
        ast.to_string() ==
        "act(p(fus(HGNC:3508!EWSR1, start, HGNC:3749!FLI1, end)), ma(tscript))"
    )
Exemplo n.º 2
0
def test_ast_canonicalization(test_input, expected):
    """Test AST canonicalization and sorting function arguments

    See issue: https://github.com/belbio/bel/issues/13
    """

    assertion = AssertionStr(entire=test_input)

    ast = bel.lang.ast.BELAst(assertion=assertion)

    ast.canonicalize()

    print("Canonicalized", ast.to_string())

    assert ast.to_string() == expected
Exemplo n.º 3
0
def test_ast_canonicalization_2():
    """Test AST canonicalization and sorting function arguments

    See issue: https://github.com/belbio/bel/issues/13
    """

    test_input = "path(DO:0080600!COVID-19)"
    expected = "path(DO:0080600)"

    assertion = AssertionStr(entire=test_input)

    ast = bel.lang.ast.BELAst(assertion=assertion)

    ast.canonicalize()

    print("Canonicalized", ast.to_string())

    assert ast.to_string() == expected
Exemplo n.º 4
0
def test_ast_orthologization():
    """Test AST orthologization"""

    assertion = AssertionStr(entire="p(HGNC:AKT1)")

    ast = bel.lang.ast.BELAst(assertion=assertion)

    if ast.orthologizable("TAX:10090"):
        ast.orthologize("TAX:10090")

        print("Orthologized to mouse", ast.to_string())
        assert ast.to_string() == "p(EG:11651!Akt1)"

        ast.decanonicalize()

        print("Orthologized and decanonicalized to mouse", ast.to_string())

        assert ast.to_string() == "p(MGI:87986!Akt1)"

    else:
        assert False, "Not orthologizable"
Exemplo n.º 5
0
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 = "p(MGI:87986!Akt1) increases (p(MGI:87986!Akt1) increases p(MGI:95290!Egf))"

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

    assert result == expected