Skip to content

Commit bd6d6f5

Browse files
committed
Change node numbering to atomic data
1 parent ce5439b commit bd6d6f5

File tree

2 files changed

+121
-41
lines changed

2 files changed

+121
-41
lines changed

SERD/__init__.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -824,22 +824,24 @@ def r2g(
824824
if selection != "all":
825825
atomic = _get_atom_selection(atomic, selection=selection)
826826

827-
# Keep solvent exposed residues
828-
# https://stackoverflow.com/questions/51352527/check-for-identical-rows-in-different-numpy-arrays
829-
atomic = atomic[(atomic[:, 0:3][:, None] == residues).all(-1).any(-1)]
830-
831827
# Calculate distance
832828
distance = _calculate_distance(atomic[:, 4:7])
833829

834830
if selection == "all":
835831
distance = _all_atoms_to_residues(atomic, distance)
832+
atomic = _get_atom_selection(atomic, selection=selection)
836833

837834
# Calculate adjacency matrix
838835
if intraresidual:
839836
adjacency = (distance < cutoff).astype(int)
840837
else:
841838
adjacency = numpy.logical_and(distance > 0.0, distance < cutoff).astype(int)
842839

840+
# Keep solvent exposed residues
841+
# https://stackoverflow.com/questions/51352527/check-for-identical-rows-in-different-numpy-arrays
842+
adjacency[:, ~(atomic[:, 0:3][:, None] == residues).all(-1).any(-1)] = 0
843+
adjacency[~(atomic[:, 0:3][:, None] == residues).all(-1).any(-1), :] = 0
844+
843845
# Create networkx.Graph
844846
G = networkx.Graph()
845847
G.add_edges_from(numpy.argwhere(adjacency))

notebooks/1FMO.ipynb

+115-37
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)