Skip to content

Commit

Permalink
Change node numbering to atomic data
Browse files Browse the repository at this point in the history
  • Loading branch information
jvsguerra committed Sep 21, 2021
1 parent ce5439b commit bd6d6f5
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 41 deletions.
10 changes: 6 additions & 4 deletions SERD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,22 +824,24 @@ def r2g(
if selection != "all":
atomic = _get_atom_selection(atomic, selection=selection)

# Keep solvent exposed residues
# https://stackoverflow.com/questions/51352527/check-for-identical-rows-in-different-numpy-arrays
atomic = atomic[(atomic[:, 0:3][:, None] == residues).all(-1).any(-1)]

# Calculate distance
distance = _calculate_distance(atomic[:, 4:7])

if selection == "all":
distance = _all_atoms_to_residues(atomic, distance)
atomic = _get_atom_selection(atomic, selection=selection)

# Calculate adjacency matrix
if intraresidual:
adjacency = (distance < cutoff).astype(int)
else:
adjacency = numpy.logical_and(distance > 0.0, distance < cutoff).astype(int)

# Keep solvent exposed residues
# https://stackoverflow.com/questions/51352527/check-for-identical-rows-in-different-numpy-arrays
adjacency[:, ~(atomic[:, 0:3][:, None] == residues).all(-1).any(-1)] = 0
adjacency[~(atomic[:, 0:3][:, None] == residues).all(-1).any(-1), :] = 0

# Create networkx.Graph
G = networkx.Graph()
G.add_edges_from(numpy.argwhere(adjacency))
Expand Down
152 changes: 115 additions & 37 deletions notebooks/1FMO.ipynb

Large diffs are not rendered by default.

0 comments on commit bd6d6f5

Please sign in to comment.