INNER CODE UNIT · Python
prune
pybel/pybel · src/pybel/cli.py:556
def prune(manager: Manager):
"""Prune nodes not belonging to any edges."""
nodes_to_delete = [
node for node in tqdm(manager.session.query(Node), total=manager.count_nodes()) if not node.networks
]
manager.session.delete(nodes_to_delete)
manager.session.commit()
@manage.command()
@click.pass_obj
def summarize(manager: Manager):
"""Summarize the contents of the database."""
click.echo(f"Networks: {manager.count_networks()}")
click.echo(f"Edges: {manager.count_edges()}")
click.echo(f"Nodes: {manager.count_nodes()}")
click.echo(f"Namespaces: {manager.count_namespaces()}")
click.echo(f"Namespaces entries: {manager.count_namespace_entries()}")