-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error occurred while Constructing edges when reading PDB file. #384
Comments
Hi @1412140736 can you share a snippet and the pdb id to reproduce this? |
yes,this is the snippet : Here are the IDs of some problematic PDB files that I downloaded from RCSB:
|
Thanks! I could reproduce it. It looks like removing altlocs throws off the indexing order in the dataframe. Quick fix first: replace def add_distance_threshold(
G: nx.Graph, long_interaction_threshold: int, threshold: float = 5.0
):
"""
Adds edges to any nodes within a given distance of each other.
Long interaction threshold is used to specify minimum separation in sequence
to add an edge between networkx nodes within the distance threshold
:param G: Protein Structure graph to add distance edges to
:type G: nx.Graph
:param long_interaction_threshold: minimum distance in sequence for two
nodes to be connected
:type long_interaction_threshold: int
:param threshold: Distance in angstroms, below which two nodes are connected
:type threshold: float
:return: Graph with distance-based edges added
"""
pdb_df = filter_dataframe(
G.graph["pdb_df"], "node_id", list(G.nodes()), True
)
dist_mat = compute_distmat(pdb_df)
interacting_nodes = get_interacting_atoms(threshold, distmat=dist_mat)
interacting_nodes = list(zip(interacting_nodes[0], interacting_nodes[1]))
log.info(f"Found: {len(interacting_nodes)} distance edges")
count = 0
for a1, a2 in interacting_nodes:
n1 = G.graph["pdb_df"].iloc[a1]["node_id"]
n2 = G.graph["pdb_df"].iloc[a2]["node_id"]
n1_chain = G.graph["pdb_df"].iloc[a1]["chain_id"]
n2_chain = G.graph["pdb_df"].iloc[a2]["chain_id"]
n1_position = G.graph["pdb_df"].iloc[a1]["residue_number"]
n2_position = G.graph["pdb_df"].iloc[a2]["residue_number"]
condition_1 = n1_chain == n2_chain
condition_2 = (
abs(n1_position - n2_position) < long_interaction_threshold
)
if not (condition_1 and condition_2):
count += 1
add_edge(G, n1, n2, "distance_threshold")
log.info(
f"Added {count} distance edges. ({len(list(interacting_nodes)) - count}\
removed by LIN)"
) Longer term fix: resetting the index after removing altlocs. |
Thank you for your prompt response. I have followed your advice to change However, a new error has occurred, and the error message is as follows (thanks again for your response):
|
Apologies, syntax error on my part. I've updated the codeblock above. |
The issue has been resolved. Thank you! |
Hello, I'm facing the same problem you encountered. Could you tell me how you overcame it? |
* add AYA to constants #387 * bump changelog * reset index after handling altlocs #384 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Arian Jamasb <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The error message is as follows:
The text was updated successfully, but these errors were encountered: