Kappa-Dev / KAMI

Bio-curation library for modelling cellular signalling
MIT License
7 stars 0 forks source link

Error importing Kami.Hierarchy #7

Closed hmedina closed 6 years ago

hmedina commented 6 years ago

I get an error when trying to import Kami Hierarchy. For both Kami and ReGraph, I am on branch master and up to date (as of this posting).

hmedina@Hector-Surface:~$ cd KAMI-python/
hmedina@Hector-Surface:~/KAMI-python$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
hmedina@Hector-Surface:~/KAMI-python$ cd ../ReGraph/
hmedina@Hector-Surface:~/ReGraph$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
hmedina@Hector-Surface:~/ReGraph$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from kami.entities import (Gene, Region, Site, Residue, State, RegionActor, SiteActor)
>>> from kami.interactions import (Binding, Modification)
>>> from kami.hierarchy import (KamiHierarchy)
Traceback (most recent call last):
  File "/home/hmedina/ReGraph/regraph/primitives.py", line 75, in add_nodes_from
    node_id, node_attrs = n
ValueError: too many values to unpack (expected 2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hmedina/.local/lib/python3.5/site-packages/kami-0.1-py3.5.egg/kami/hierarchy.py", line 13, in <module>
    from kami.resources import default_components
  File "/home/hmedina/.local/lib/python3.5/site-packages/kami-0.1-py3.5.egg/kami/resources/default_components.py", line 2, in <module>
    from kami.resources import (metamodels,
  File "/home/hmedina/.local/lib/python3.5/site-packages/kami-0.1-py3.5.egg/kami/resources/metamodels.py", line 20, in <module>
    "action"
  File "/home/hmedina/ReGraph/regraph/primitives.py", line 78, in add_nodes_from
    add_node(graph, n)
  File "/home/hmedina/ReGraph/regraph/primitives.py", line 50, in add_node
    graph.node[node_id] = new_attrs
TypeError: 'NodeView' object does not support item assignment
>>>

As this is a Kami call, I'm filing it here, even though all the errors arise on ReGraph calls. If this should be posted to the ReGraph issues page, kindly let me know.

eugeniashurko commented 6 years ago

The second exception (TypeError: 'NodeView' object does not support item assignment) is related to the fact that at the moment ReGraph is implemented using NetworkX v1, and I think you have NetworkX v2 installed. In the second version the result of graph.node[node_id] is not a dictionary object (as in v1), but a 'NodeView' object. Please, try to check which version of nx you have installed, try to downgrade it to v1, and tell me if both errors persist.

hmedina commented 6 years ago

I had the latest stable release of NetworkX, version 2.1 After uninstalling v2.1 to force loading of the already installed v1.11, I get no errors.

Side note, is there a way of making ReGraph call the legacy version of NetworkX, if multiple are installed? ReGraph's setup.py file correctly states the dependency as 1.11, so pip handles the installation correctly.