Source code for

# -*- coding: utf-8 -*-

"""The Umbrella Node-Link JSON format is similar to node-link but uses full BEL terms as nodes.

Given a BEL statement describing that ``X`` phosphorylates ``Y`` like ``act(p(X)) -> p(Y, pmod(Ph))``,
PyBEL usually stores the ``act()`` information about ``X`` as part of the relationship. In Umbrella mode,
this stays as part of the node.

Note that this generates additional nodes in the network for each of the "modified" versions of
the node. For example, ``act(p(X))`` will be represented as individual node instead of
``p(X)``, as in the standard node-link JSON exporter.

A user might want to use this exporter in the following scenarios:

- Represent transitivity in activities like in ``p(X, pmod(Ph)) -> act(p(X)) -> p(Y, pmod(Ph)) -> act(p(Y))``
  with four nodes that are more ammenable to simulatons (e.g., boolean networks, petri nets).
- Visualizing networks that in similar way to the legacy BEL
  `Cytoscape plugin <>`_ from the BEL Framework (warning: now defunct)
  using tools like Cytoscape.

import gzip
import json
from itertools import chain, count
from typing import Any, Mapping, TextIO, Union

from networkx.utils import open_file

from ..canonicalize import _decanonicalize_edge_node, edge_to_tuple
from ..struct import BELGraph

__all__ = [