def convert_sub(sub):
    """Convert BEL1 sub() to BEL2 var()"""

    args = sub.args
    (ref_aa, pos, new_aa) = args

    parent_fn_name = sub.parent_function.name_short
    prefix_list = {"p": "p.", "r": "r.", "g": "c."}
    prefix = prefix_list[parent_fn_name]

    new_var_arg = f'"{prefix}{spec["namespaces"]["AminoAcid"]["to_short"][ref_aa.value]}{pos.value}{spec["namespaces"]["AminoAcid"]["to_short"][new_aa.value]}"'

    new_var = bel.lang.ast.Function("var", bo.spec)

    new_var.add_argument(StrArg(new_var_arg, new_var))

    return new_var
def convert_sub ( sub ) : args = sub . args ( ref_aa , pos , new_aa ) = args parent_fn_name = sub . parent_function . name_short prefix_list = { "p" : "p." , "r" : "r." , "g" : "c." } prefix = prefix_list [ parent_fn_name ] new_var_arg = f'"{prefix}{spec["namespaces"]["AminoAcid"]["to_short"][ref_aa.value]}{pos.value}{spec["namespaces"]["AminoAcid"]["to_short"][new_aa.value]}"' new_var = bel . lang . ast . Function ( "var" , bo . spec ) new_var . add_argument ( StrArg ( new_var_arg , new_var ) ) return new_var
Convert BEL1 sub() to BEL2 var()