Grouping

Functions for grouping BEL graphs into sub-graphs.

pybel.struct.grouping.get_subgraphs_by_annotation(graph, annotation, sentinel=None)[source]

Stratify the given graph into sub-graphs based on the values for edges’ annotations.

Parameters
  • graph (BELGraph) – A BEL graph

  • annotation (str) – The annotation to group by

  • sentinel (Optional[str]) – The value to stick unannotated edges into. If none, does not keep undefined.

Return type

Mapping[Entity, BELGraph]

pybel.struct.grouping.get_subgraphs_by_citation(graph)[source]

Stratify the graph based on citations.

Parameters

graph (BELGraph) – A BEL graph

Return type

Mapping[Tuple[str, str], BELGraph]

Returns

A mapping of each citation db/id to the BEL graph from it.