Summary

Summary functions for BEL graphs.

pybel.struct.summary.get_syntax_errors(graph)[source]

List the syntax errors encountered during compilation of a BEL script.

Return type

List[Tuple[Optional[str], BELParserWarning, Mapping]]

pybel.struct.summary.count_error_types(graph)[source]

Count the occurrence of each type of error in a graph.

Return type

Counter[str]

Returns

A Counter of {error type: frequency}

pybel.struct.summary.count_naked_names(graph)[source]

Count the frequency of each naked name (names without namespaces).

Return type

Counter[str]

Returns

A Counter from {name: frequency}

pybel.struct.summary.get_naked_names(graph)[source]

Get the set of naked names in the graph.

Return type

Set[str]

pybel.struct.summary.calculate_incorrect_name_dict(graph)[source]

Get missing names grouped by namespace.

Return type

Mapping[str, List[str]]

pybel.struct.summary.calculate_error_by_annotation(graph, annotation)[source]

Group error names by a given annotation.

Return type

Mapping[str, List[str]]

pybel.struct.summary.get_functions(graph)[source]

Get the set of all functions used in this graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Set[str]

Returns

A set of functions

pybel.struct.summary.count_functions(graph)[source]

Count the frequency of each function present in a graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Counter[str]

Returns

A Counter from {function: frequency}

pybel.struct.summary.count_namespaces(graph)[source]

Count the frequency of each namespace across all nodes (that have namespaces).

Parameters

graph (pybel.BELGraph) – A BEL graph

Returns

A Counter from {namespace: frequency}

Return type

collections.Counter

pybel.struct.summary.get_namespaces(graph)[source]

Get the set of all namespaces used in this graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Set[str]

Returns

A set of namespaces

pybel.struct.summary.count_names_by_namespace(graph, namespace)[source]

Get the set of all of the names in a given namespace that are in the graph.

Parameters
Return type

Counter[str]

Returns

A counter from {name: frequency}

Raises

IndexError – if the namespace is not defined in the graph.

pybel.struct.summary.get_names_by_namespace(graph, namespace)[source]

Get the set of all of the names in a given namespace that are in the graph.

Parameters
Return type

Set[str]

Returns

A set of names belonging to the given namespace that are in the given graph

Raises

IndexError – if the namespace is not defined in the graph.

pybel.struct.summary.get_unused_namespaces(graph)[source]

Get the set of all namespaces that are defined in a graph, but are never used.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Set[str]

Returns

A set of namespaces that are included but not used

pybel.struct.summary.count_variants(graph)[source]

Count how many of each type of variant a graph has.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Counter[str]

pybel.struct.summary.get_names(graph)[source]

Get all names for each namespace.

Return type

dict[str,set[str]]

pybel.struct.summary.count_pathologies(graph)[source]

Count the number of edges in which each pathology is incident.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Counter[BaseEntity]

pybel.struct.summary.get_top_pathologies(graph, n=15)[source]

Get the top highest relationship-having edges in the graph by BEL.

Parameters
  • graph (pybel.BELGraph) – A BEL graph

  • n (Optional[int]) – The number of top connected pathologies to return. If None, returns all nodes

Return type

List[Tuple[BaseEntity, int]]

pybel.struct.summary.get_top_hubs(graph, *, n=15)[source]

Get the top hubs in the graph by BEL.

Parameters
Return type

List[Tuple[BaseEntity, int]]

pybel.struct.summary.iterate_pubmed_identifiers(graph)[source]

Iterate over all PubMed identifiers in a graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Iterable[str]

Returns

An iterator over the PubMed identifiers in the graph

pybel.struct.summary.get_pubmed_identifiers(graph)[source]

Get the set of all PubMed identifiers cited in the construction of a graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Set[str]

Returns

A set of all PubMed identifiers cited in the construction of this graph

pybel.struct.summary.iter_annotation_value_pairs(graph)[source]

Iterate over the key/value pairs, with duplicates, for each annotation used in a BEL graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Iterable[Tuple[str, str]]

pybel.struct.summary.iter_annotation_values(graph, annotation)[source]

Iterate over all of the values for an annotation used in the graph.

Parameters
Return type

Iterable[str]

pybel.struct.summary.get_annotation_values_by_annotation(graph)[source]

Get the set of values for each annotation used in a BEL graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Mapping[str, Set[str]]

Returns

A dictionary of {annotation key: set of annotation values}

pybel.struct.summary.get_annotation_values(graph, annotation)[source]

Get all values for the given annotation.

Parameters
  • graph (pybel.BELGraph) – A BEL graph

  • annotation (str) – The annotation to summarize

Return type

Set[str]

Returns

A set of all annotation values

pybel.struct.summary.count_relations(graph)[source]

Return a histogram over all relationships in a graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Counter

Returns

A Counter from {relation type: frequency}

pybel.struct.summary.get_annotations(graph)[source]

Get the set of annotations used in the graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Set[str]

Returns

A set of annotation keys

pybel.struct.summary.count_annotations(graph)[source]

Count how many times each annotation is used in the graph.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Counter

Returns

A Counter from {annotation key: frequency}

pybel.struct.summary.get_unused_annotations(graph)[source]

Get the set of all annotations that are defined in a graph, but are never used.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Set[str]

Returns

A set of annotations

pybel.struct.summary.get_unused_list_annotation_values(graph)[source]

Get all of the unused values for list annotations.

Parameters

graph (pybel.BELGraph) – A BEL graph

Return type

Mapping[str, Set[str]]

Returns

A dictionary of {str annotation: set of str values that aren’t used}

pybel.struct.summary.get_metaedge_to_key(graph)[source]

Get all edge types.

Return type

Mapping[Tuple[str, Optional[Tuple], Optional[Tuple]], Set[Tuple[BaseEntity, BaseEntity, str]]]