@belc.command(context_settings=CONTEXT_SETTINGS)<EOL>@click.argument("<STR_LIT>")<EOL>@click.option("<STR_LIT>", help="<STR_LIT>")<EOL>@click.option("<STR_LIT>", help="<STR_LIT>")<EOL>@click.option(<EOL>"<STR_LIT>", default="<STR_LIT:->", help="<STR_LIT>"<EOL>)<EOL>@click.option(<EOL>"<STR_LIT>",<EOL>help='<STR_LIT>',<EOL>)<EOL>@click.option(<EOL>"<STR_LIT>", help="<STR_LIT>"<EOL>)<EOL>@click.option(<EOL>"<STR_LIT>",<EOL>help='<STR_LIT>',<EOL>)<EOL>@click.option("<STR_LIT>", help="<STR_LIT>")<EOL>@click.option("<STR_LIT>", help="<STR_LIT>")<EOL>@click.option(<EOL>"<STR_LIT>", help="<STR_LIT>"<EOL>)<EOL>@pass_context<EOL>def pipeline(<EOL>ctx,<EOL>input_fn,<EOL>db_save,<EOL>db_delete,<EOL>output_fn,<EOL>rules,<EOL>species,<EOL>namespace_targets,<EOL>version,<EOL>api,<EOL>config_fn,<EOL>):
if config_fn:<EOL><INDENT>config = bel.db.Config.merge_config(ctx.config, override_config_fn=config_fn)<EOL><DEDENT>else:<EOL><INDENT>config = ctx.config<EOL><DEDENT>if namespace_targets:<EOL><INDENT>namespace_targets = json.loads(namespace_targets)<EOL><DEDENT>if rules:<EOL><INDENT>rules = rules.replace("<STR_LIT:U+0020>", "<STR_LIT>").split("<STR_LIT:U+002C>")<EOL><DEDENT>namespace_targets = utils.first_true(<EOL>[namespace_targets, config["<STR_LIT>"]["<STR_LIT>"].get("<STR_LIT>")], None<EOL>)<EOL>rules = utils.first_true(<EOL>[rules, config["<STR_LIT>"]["<STR_LIT>"].get("<STR_LIT>", False)], False<EOL>)<EOL>api = utils.first_true(<EOL>[api, config["<STR_LIT>"]["<STR_LIT>"].get("<STR_LIT>", None)], None<EOL>)<EOL>version = utils.first_true(<EOL>[version, config["<STR_LIT>"]["<STR_LIT>"].get("<STR_LIT>", None)], None<EOL>)<EOL>n = bnn.Nanopub()<EOL>try:<EOL><INDENT>json_flag, jsonl_flag, yaml_flag, jgf_flag = False, False, False, False<EOL>all_bel_edges = []<EOL>fout = None<EOL>if db_save or db_delete:<EOL><INDENT>if db_delete:<EOL><INDENT>arango_client = bel.db.arangodb.get_client()<EOL>bel.db.arangodb.delete_database(arango_client, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>arango_client = bel.db.arangodb.get_client()<EOL><DEDENT>edgestore_handle = bel.db.arangodb.get_edgestore_handle(arango_client)<EOL><DEDENT>elif re.search("<STR_LIT>", output_fn):<EOL><INDENT>yaml_flag = True<EOL><DEDENT>elif "<STR_LIT>" in output_fn:<EOL><INDENT>jsonl_flag = True<EOL><DEDENT>elif "<STR_LIT>" in output_fn:<EOL><INDENT>json_flag = True<EOL><DEDENT>elif "<STR_LIT>" in output_fn:<EOL><INDENT>jgf_flag = True<EOL><DEDENT>if db_save:<EOL><INDENT>pass<EOL><DEDENT>elif "<STR_LIT>" in output_fn:<EOL><INDENT>fout = gzip.open(output_fn, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>fout = open(output_fn, "<STR_LIT>")<EOL><DEDENT>nanopub_cnt = <NUM_LIT:0><EOL>with timy.Timer() as timer:<EOL><INDENT>for np in bnf.read_nanopubs(input_fn):<EOL><INDENT>nanopub_cnt += <NUM_LIT:1><EOL>if nanopub_cnt % <NUM_LIT:100> == <NUM_LIT:0>:<EOL><INDENT>timer.track(f"<STR_LIT>")<EOL><DEDENT>bel_edges = n.bel_edges(<EOL>np,<EOL>namespace_targets=namespace_targets,<EOL>orthologize_target=species,<EOL>rules=rules,<EOL>)<EOL>if db_save:<EOL><INDENT>bel.edge.edges.load_edges_into_db(edgestore_handle, edges=bel_edges)<EOL><DEDENT>elif jsonl_flag:<EOL><INDENT>fout.write("<STR_LIT>".format(json.dumps(bel_edges)))<EOL><DEDENT>else:<EOL><INDENT>all_bel_edges.extend(bel_edges)<EOL><DEDENT><DEDENT><DEDENT>if db_save:<EOL><INDENT>pass<EOL><DEDENT>elif yaml_flag:<EOL><INDENT>fout.write("<STR_LIT>".format(yaml.dumps(all_bel_edges)))<EOL><DEDENT>elif json_flag:<EOL><INDENT>fout.write("<STR_LIT>".format(json.dumps(all_bel_edges)))<EOL><DEDENT>elif jgf_flag:<EOL><INDENT>bnf.edges_to_jgf(output_fn, all_bel_edges)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if fout:<EOL><INDENT>fout.close()<EOL><DEDENT><DEDENT>
BEL Pipeline - BEL Nanopubs into BEL Edges

    This will process BEL Nanopubs into BEL Edges by validating, orthologizing (if requested),
    canonicalizing, and then computing the BEL Edges based on the given rule_set.

    \b
    input_fn:
        If input fn has *.gz, will read as a gzip file
        If input fn has *.jsonl*, will parsed as a JSONLines file
        IF input fn has *.json*, will be parsed as a JSON file
        If input fn has *.yaml* or *.yml*,  will be parsed as a YAML file

    \b
    output_fn:
        If output fn has *.gz, will written as a gzip file
        If output fn has *.jsonl*, will written as a JSONLines file
        IF output fn has *.json*, will be written as a JSON file
        If output fn has *.yaml* or *.yml*,  will be written as a YAML file
        If output fn has *.jgf, will be written as JSON Graph Formatted file