cytoscape / py2cytoscape

Python utilities for Cytoscape and Cytoscape.js
https://py2cytoscape.readthedocs.io
MIT License
178 stars 45 forks source link

python 3.x support for utils, from_networkx #26

Open cs48a opened 7 years ago

cs48a commented 7 years ago

Hi,

(If I got it right) it seems after using a map function there is an access by index which throws an error in python 3.x as map no longer returns a list.

` if layout is not None: pos = map(lambda position: {'x': position[0]scale, 'y': position[1]scale}, layout.values())

nodes = g.nodes()
if isinstance(g, nx.MultiDiGraph) or isinstance(g, nx.MultiGraph):
    edges = g.edges(data=True, keys=True)
    edge_builder = __build_multi_edge
else:
    edges = g.edges(data=True)
    edge_builder = __build_edge

# Map network table data
cygraph[DATA] = __map_table_data(g.graph.keys(), g.graph)

for i, node_id in enumerate(nodes):
    new_node = __create_node(g.node[node_id], node_id)
    if layout is not None:
        new_node['position'] = pos[i]

`

shfong commented 6 years ago

I second a from_networkx function. This would make py2cytoscape much more usable for a lot of python users who already use networkx for the main data structure. (Also needs to bundle node and edge attributes!)