src/pybel/struct/summary/supersummary.py
def citations(graph: BELGraph, n: Optional[int] = 15, file: Optional[TextIO] = None) -> None:
    """Print a summary of the citations in the graph."""
    edge_mapping = multidict(
        ((data[CITATION][NAMESPACE], data[CITATION][IDENTIFIER]), graph.edge_to_bel(u, v, data))
        for u, v, data in graph.edges(data=True)
        if CITATION in data
    )
    edge_c = Counter({top_level_edge: len(edges) for top_level_edge, edges in edge_mapping.items()})
    df = pd.DataFrame(
        [
            (':'.join(top_level_edge), count, random.choice(edge_mapping[top_level_edge]))  # noqa:S311
            for top_level_edge, count in edge_c.most_common(n=n)
        ],
        columns=['Citation', 'Count', 'Example'],
    )

    if n is None or len(edge_mapping) < n:
        print('{} Citation Count: {}'.format(graph, len(edge_mapping)))
    else:
        print('{} Citation Count: {} (Showing top {})'.format(graph, len(edge_mapping), n))
    print(tabulate(df.values, headers=df.columns), file=file)
Print a summary of the citations in the graph.
Print a summary of the citations in the graph.
Print a summary of the citations in the graph .
def citations(graph: BELGraph, n: Optional[int] = 15, file: Optional[TextIO] = None) -> None:
    edge_mapping = multidict(
        ((data[CITATION][NAMESPACE], data[CITATION][IDENTIFIER]), graph.edge_to_bel(u, v, data))
        for u, v, data in graph.edges(data=True)
        if CITATION in data
    )
    edge_c = Counter({top_level_edge: len(edges) for top_level_edge, edges in edge_mapping.items()})
    df = pd.DataFrame(
        [
            (':'.join(top_level_edge), count, random.choice(edge_mapping[top_level_edge]))  
            for top_level_edge, count in edge_c.most_common(n=n)
        ],
        columns=['Citation', 'Count', 'Example'],
    )
    if n is None or len(edge_mapping) < n:
        print('{} Citation Count: {}'.format(graph, len(edge_mapping)))
    else:
        print('{} Citation Count: {} (Showing top {})'.format(graph, len(edge_mapping), n))
    print(tabulate(df.values, headers=df.columns), file=file)
def citations ( graph : BELGraph , n : Optional [ int ] = 15 , file : Optional [ TextIO ] = None ) -> None : edge_mapping = multidict ( ( ( data [ CITATION ] [ NAMESPACE ] , data [ CITATION ] [ IDENTIFIER ] ) , graph . edge_to_bel ( u , v , data ) ) for u , v , data in graph . edges ( data = True ) if CITATION in data ) edge_c = Counter ( { top_level_edge : len ( edges ) for top_level_edge , edges in edge_mapping . items ( ) } ) df = pd . DataFrame ( [ ( ':' . join ( top_level_edge ) , count , random . choice ( edge_mapping [ top_level_edge ] ) ) for top_level_edge , count in edge_c . most_common ( n = n ) ] , columns = [ 'Citation' , 'Count' , 'Example' ] , ) if n is None or len ( edge_mapping ) < n : print ( '{} Citation Count: {}' . format ( graph , len ( edge_mapping ) ) ) else : print ( '{} Citation Count: {} (Showing top {})' . format ( graph , len ( edge_mapping ) , n ) ) print ( tabulate ( df . values , headers = df . columns ) , file = file )
Print a summary of the citations in the graph.
Print a summary of the citations in the graph .
"""Print a summary of the citations in the graph.""" # noqa:S311
graph
BELGraph
n
Optional[int]
file
Optional[TextIO]