src/pybel/io/hetionet/hetionet.py
def from_hetionet_json(
    hetionet_dict: Mapping[str, Any],
    use_tqdm: bool = True,
) -> BELGraph:
    """Convert a Hetionet dictionary to a BEL graph."""
    graph = BELGraph(  # FIXME what metadata is appropriate?
        name='Hetionet',
        version='1.0',
        authors='Daniel Himmelstein',
    )
    # FIXME add namespaces
    # graph.namespace_pattern.update({})

    kind_identifier_to_name = {
        (x['kind'], x['identifier']): x['name']
        for x in hetionet_dict['nodes']
    }

    edges = hetionet_dict['edges']

    if use_tqdm:
        edges = tqdm(edges, desc='Converting Hetionet', unit_scale=True)
        it_logger = edges.write
    else:
        it_logger = logger.info

    for edge in edges:
        _add_edge(graph, edge, kind_identifier_to_name, it_logger)

    return graph
Convert a Hetionet dictionary to a BEL graph.
Convert a Hetionet dictionary to a BEL graph.
Convert a Hetionet dictionary to a BEL graph .
def from_hetionet_json(
    hetionet_dict: Mapping[str, Any],
    use_tqdm: bool = True,
) -> BELGraph:
    graph = BELGraph(  
        name='Hetionet',
        version='1.0',
        authors='Daniel Himmelstein',
    )
    kind_identifier_to_name = {
        (x['kind'], x['identifier']): x['name']
        for x in hetionet_dict['nodes']
    }
    edges = hetionet_dict['edges']
    if use_tqdm:
        edges = tqdm(edges, desc='Converting Hetionet', unit_scale=True)
        it_logger = edges.write
    else:
        it_logger = logger.info
    for edge in edges:
        _add_edge(graph, edge, kind_identifier_to_name, it_logger)
    return graph
def from_hetionet_json ( hetionet_dict : Mapping [ str , Any ] , use_tqdm : bool = True , ) -> BELGraph : graph = BELGraph ( name = 'Hetionet' , version = '1.0' , authors = 'Daniel Himmelstein' , ) kind_identifier_to_name = { ( x [ 'kind' ] , x [ 'identifier' ] ) : x [ 'name' ] for x in hetionet_dict [ 'nodes' ] } edges = hetionet_dict [ 'edges' ] if use_tqdm : edges = tqdm ( edges , desc = 'Converting Hetionet' , unit_scale = True ) it_logger = edges . write else : it_logger = logger . info for edge in edges : _add_edge ( graph , edge , kind_identifier_to_name , it_logger ) return graph
Convert a Hetionet dictionary to a BEL graph.
Convert a Hetionet dictionary to a BEL graph .
"""Convert a Hetionet dictionary to a BEL graph.""" # FIXME what metadata is appropriate? # FIXME add namespaces # graph.namespace_pattern.update({})
hetionet_dict
Mapping[str, Any]
use_tqdm
bool