src/pybel/io/cx.py
def to_cx_file(graph: BELGraph, path: Union[str, TextIO], indent: Optional[int] = 2, **kwargs) -> None:
    """Write a BEL graph to a JSON file in CX format.

    :param graph: A BEL graph
    :param path: A writable file or file-like
    :param indent: How many spaces to use to pretty print. Change to None for no pretty printing

    The example below shows how to output a BEL graph as CX to an open file.

    .. code-block:: python

       from pybel.examples import sialic_acid_graph
       from pybel import to_cx_file
       with open('graph.bel.cx.json', 'w') as file:
           to_cx_file(sialic_acid_graph, file)

    The example below shows how to output a BEL graph as CX to a file at a given path.

    .. code-block:: python

        from pybel.examples import sialic_acid_graph
        from pybel import to_cx_file
        to_cx_file(sialic_acid_graph, 'graph.bel.cx.json')

    If you have a big graph, you might consider storing it as a gzipped JGIF file
    by using :func:`to_cx_gz`.
    """
    graph_cx_json_dict = to_cx(graph)
    json.dump(graph_cx_json_dict, path, ensure_ascii=False, indent=indent, **kwargs)
Write a BEL graph to a JSON file in CX format.

    :param graph: A BEL graph
    :param path: A writable file or file-like
    :param indent: How many spaces to use to pretty print. Change to None for no pretty printing

    The example below shows how to output a BEL graph as CX to an open file.

    .. code-block:: python

       from pybel.examples import sialic_acid_graph
       from pybel import to_cx_file
       with open('graph.bel.cx.json', 'w') as file:
           to_cx_file(sialic_acid_graph, file)

    The example below shows how to output a BEL graph as CX to a file at a given path.

    .. code-block:: python

        from pybel.examples import sialic_acid_graph
        from pybel import to_cx_file
        to_cx_file(sialic_acid_graph, 'graph.bel.cx.json')

    If you have a big graph, you might consider storing it as a gzipped JGIF file
    by using :func:`to_cx_gz`.
    
Write a BEL graph to a JSON file in CX format.
Write a BEL graph to a JSON file in CX format .
def to_cx_file(graph: BELGraph, path: Union[str, TextIO], indent: Optional[int] = 2, **kwargs) -> None:
    graph_cx_json_dict = to_cx(graph)
    json.dump(graph_cx_json_dict, path, ensure_ascii=False, indent=indent, **kwargs)
def to_cx_file ( graph : BELGraph , path : Union [ str , TextIO ] , indent : Optional [ int ] = 2 , ** kwargs ) -> None : graph_cx_json_dict = to_cx ( graph ) json . dump ( graph_cx_json_dict , path , ensure_ascii = False , indent = indent , ** kwargs )
Write a BEL graph to a JSON file in CX format.
Write a BEL graph to a JSON file in CX format .
"""Write a BEL graph to a JSON file in CX format.

    :param graph: A BEL graph
    :param path: A writable file or file-like
    :param indent: How many spaces to use to pretty print. Change to None for no pretty printing

    The example below shows how to output a BEL graph as CX to an open file.

    .. code-block:: python

       from pybel.examples import sialic_acid_graph
       from pybel import to_cx_file
       with open('graph.bel.cx.json', 'w') as file:
           to_cx_file(sialic_acid_graph, file)

    The example below shows how to output a BEL graph as CX to a file at a given path.

    .. code-block:: python

        from pybel.examples import sialic_acid_graph
        from pybel import to_cx_file
        to_cx_file(sialic_acid_graph, 'graph.bel.cx.json')

    If you have a big graph, you might consider storing it as a gzipped JGIF file
    by using :func:`to_cx_gz`.
    """
graph
BELGraph
A BEL graph
A BEL graph
path
Union[str, TextIO]
A writable file or file-like
A writable file or file - like
indent
Optional[int]


code-block:: python

from pybel.examples import sialic_acid_graph
from pybel import to_cx_file
with open('graph.bel.cx.json', 'w') as file:
to_cx_file(sialic_acid_graph, file)

The example below shows how to output a BEL graph as CX to a file at a given path.

code-block:: python

from pybel.examples import sialic_acid_graph
from pybel import to_cx_file
to_cx_file(sialic_acid_graph, 'graph.bel.cx.json')

If you have a big graph, you might consider storing it as a gzipped JGIF file
by using :func:`to_cx_gz`.
code - block :: python from pybel . examples import sialic_acid_graph from pybel import to_cx_file with open ( ' graph . bel . cx . json ' ' w ' ) as file : to_cx_file ( sialic_acid_graph file ) The example below shows how to output a BEL graph as CX to a file at a given path . code - block :: python from pybel . examples import sialic_acid_graph from pybel import to_cx_file to_cx_file ( sialic_acid_graph ' graph . bel . cx . json ' ) If you have a big graph you might consider storing it as a gzipped JGIF file by using : func : ` to_cx_gz ` .