- This topic has 3 replies, 2 voices, and was last updated 9 years, 2 months ago by Anonymous.
September 22, 2014 at 2:21 pm #2010Anonymous
I would like to get all residues that are close to any chosen residue in my pose. (I need a list of all residues whose side chains could potentially interact with the side chain of my chosen residue.)
I’m guessing the information is available in `pose.energies().tenA_neighbor_graph()`, but I can’t seem to access it in PyRosetta.
for l in pose.energies().tenA_neighbor_graph().get_node(1).edge_list_begin():
TypeError: ‘EdgeListIterator’ object is not iterable
and the `graph::Node` does not seem to expose an array or list or linked-list of edges of each node.
Creating a Vector1 (as suggested here) gives the same error.
Is it possible to iterate over the edges in a node in PyRosetta?
Thank you for your help & best regards,
September 22, 2014 at 3:19 pm #10292Anonymous
Is there any reason you want to use the neighbor graph iteration to do this?
Probably the easier way to do it would be to do a double for-loop iteration over the residues in the pose:
for ii in range(1,pose.total_residue()+1):
for jj in range(ii+1,pose.total_residue()+1):
if not is_neighbor(pose, ii, jj):
#Do whatever you want with neighbor residues
You would have to write the is_neighbor() function yourself, but this allows you to more accurately control how you classify neighbor residues. Rosetta uses a definition that’s optimized for the particular use case in the energy function definition, but you may prefer a slightly different one.
September 22, 2014 at 5:02 pm #10305Anonymous
I wanted to reuse the existing calculation already performed by PyRosetta. (Also since it’s in C++ it’s probably faster than doing this at the Python side. If this speed difference matters is of course another question.)
Perhaps I will have to “manually” implement neighbourhood detection in the end. Since my next question was how to get a neighbourhood graph at an arbitrary distance not just at 10 or 12 Angstrom The custom approach would also enable me to have a separate radius defined for each residue.
I did also find a hacky workaround using ` graph.get_edge_exists`
def get_close_resids(pose, target_resid):
graph = pose.energies().tenA_neighbor_graph()
resids = 
for r in range(1,graph.num_nodes()+1):
if (r <> target_resid) and graph.get_edge_exists(target_resid, r):
September 23, 2014 at 3:44 pm #10311Anonymous
Yeah, the edge_list_begin() returns a C++ iterator, which doesn’t mesh well with the Python iterators in for loops. There’s not really a way exposed to iterate through the edges on the Python level. The workaround you’ve come up with is probably the best way to do things if you want to extract the information out of the existing tenA_neighbor_graph.
- You must be logged in to reply to this topic.