a-r-j / graphein

Protein Graph Library
https://graphein.ai/
MIT License
1.02k stars 131 forks source link

compute graph edges #266

Closed thollis23 closed 1 year ago

thollis23 commented 1 year ago

executing tutorial in colab notebook, running graphein 1.5.2:

from graphein.protein.graphs import construct_graph g = construct_graph(config=config, pdb_code="7TQN")

produces the following error:

AttributeError Traceback (most recent call last) in 1 from graphein.protein.graphs import construct_graph 2 ----> 3 g = construct_graph(config=config, pdb_code="7TQN")

/usr/local/lib/python3.8/dist-packages/graphein/protein/graphs.py in construct_graph(config, name, pdb_path, uniprot_id, pdb_code, chain_selection, model_index, df_processing_funcs, edge_construction_funcs, edge_annotation_funcs, node_annotation_funcs, graph_annotation_funcs) 730 task4 = progress.add_task("Constructing edges...", total=1) 731 # Compute graph edges --> 732 g = compute_edges( 733 g, 734 funcs=config.edge_construction_functions,

/usr/local/lib/python3.8/dist-packages/graphein/protein/graphs.py in compute_edges(G, funcs, get_contacts_config) 587 func(G) 588 --> 589 return add_distance_to_edges(G) 590 591

/usr/local/lib/python3.8/dist-packages/graphein/protein/edges/distance.py in add_distance_to_edges(G) 94 G.graph["dist_mat"] = dist_mat 95 ---> 96 mat = np.where(nx.to_numpy_matrix(G), dist_mat, 0) 97 node_map = {n: i for i, n in enumerate(G.nodes)} 98 for u, v, d in G.edges(data=True):

AttributeError: module 'networkx' has no attribute 'to_numpy_matrix'

a-r-j commented 1 year ago

This is due to version drift with Networkx. If you downgrade to Networkx <2.8 (iirc) it should work. Alternatively, you can install graphein from the main branch in this repository where this should be resolved.

a-r-j commented 1 year ago

How did you get on? Can I close this issue?

thollis23 commented 1 year ago
Sorry, yes your suggestion fixed the issue.  Please close.Thanks! Sent from Mail for Windows From: Arian JamasbSent: Thursday, March 9, 2023 10:28 PMTo: a-r-j/grapheinCc: thollis23; AuthorSubject: Re: [a-r-j/graphein] compute graph edges (Issue #266) How did you get on? Can I close this issue?—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>