@nanopub.command(name="<STR_LIT>", context_settings=CONTEXT_SETTINGS)<EOL>@click.argument("<STR_LIT>")<EOL>@pass_context<EOL>def nanopub_stats(ctx, input_fn):
counts = {<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": {"<STR_LIT>": <NUM_LIT:0>, "<STR_LIT>": <NUM_LIT:0>, "<STR_LIT>": <NUM_LIT:0>, "<STR_LIT>": {}},<EOL>}<EOL>for np in bnf.read_nanopubs(input_fn):<EOL><INDENT>if "<STR_LIT>" in np:<EOL><INDENT>counts["<STR_LIT>"] += <NUM_LIT:1><EOL>counts["<STR_LIT>"]["<STR_LIT>"] += len(np["<STR_LIT>"]["<STR_LIT>"])<EOL>for assertion in np["<STR_LIT>"]["<STR_LIT>"]:<EOL><INDENT>if assertion["<STR_LIT>"] is None:<EOL><INDENT>counts["<STR_LIT>"]["<STR_LIT>"] += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>if re.match("<STR_LIT>", assertion["<STR_LIT:object>"]):<EOL><INDENT>counts["<STR_LIT>"]["<STR_LIT>"] += <NUM_LIT:1><EOL><DEDENT>if (<EOL>not assertion.get("<STR_LIT>")<EOL>in counts["<STR_LIT>"]["<STR_LIT>"]<EOL>):<EOL><INDENT>counts["<STR_LIT>"]["<STR_LIT>"][assertion.get("<STR_LIT>")] = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>counts["<STR_LIT>"]["<STR_LIT>"][<EOL>assertion.get("<STR_LIT>")<EOL>] += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>counts["<STR_LIT>"]["<STR_LIT>"] = sorted(counts["<STR_LIT>"]["<STR_LIT>"])<EOL>print("<STR_LIT>", json.dumps(counts, indent=<NUM_LIT:4>))<EOL>
Collect statistics on nanopub file

    input_fn can be json, jsonl or yaml and additionally gzipped