Skip to content

Commit

Permalink
Merge pull request #14 from hmcezar/split-reorder-solvent
Browse files Browse the repository at this point in the history
Perform the reorder of the solvent atoms separetely.
  • Loading branch information
hmcezar authored Dec 19, 2024
2 parents a8806a6 + b6ca3ef commit 9d50cdf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
13 changes: 9 additions & 4 deletions clusttraj/distmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,26 @@ def compute_distmat_line(

# reorder the solvent atoms separately
if reorder:
# if the solute is specified, reorder just the solvent atoms in this step
if nsatoms:
exclusions = np.unique(np.concatenate((np.arange(natoms), reorderexcl)))

Check warning on line 262 in clusttraj/distmat.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/distmat.py#L261-L262

Added lines #L261 - L262 were not covered by tests
else:
exclusions = reorderexcl

Check warning on line 264 in clusttraj/distmat.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/distmat.py#L264

Added line #L264 was not covered by tests

# get the view without the excluded atoms
view = np.delete(np.arange(len(P)), reorderexcl)
view = np.delete(np.arange(len(P)), exclusions)

Check warning on line 267 in clusttraj/distmat.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/distmat.py#L267

Added line #L267 was not covered by tests
Pview = P[view]
Paview = Pa[view]

prr = reorder(Qa[view], Paview, Q[view], Pview)
Pview = Pview[prr]

# build the total molecule with the reordered atoms
# whereins = np.where(np.isin(np.arange(len(P)), reorderexcl) is True)
whereins = np.where(np.atleast_1d(np.isin(np.arange(len(P)), reorderexcl)))
whereins = np.where(np.atleast_1d(np.isin(np.arange(len(P)), exclusions)))

Check warning on line 275 in clusttraj/distmat.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/distmat.py#L275

Added line #L275 was not covered by tests
Pr = np.insert(
Pview,
[x - whereins[0].tolist().index(x) for x in whereins[0]],
P[reorderexcl],
P[exclusions],
axis=0,
)

Expand Down
15 changes: 11 additions & 4 deletions clusttraj/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,23 +844,30 @@ def save_clusters_config(

# reorder the solvent atoms separately
if reorder:
# if the solute is specified, reorder just the solvent atoms in this step
if nsatoms:
exclusions = np.unique(

Check warning on line 849 in clusttraj/io.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/io.py#L848-L849

Added lines #L848 - L849 were not covered by tests
np.concatenate((np.arange(natoms), reorderexcl))
)
else:
exclusions = reorderexcl

Check warning on line 853 in clusttraj/io.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/io.py#L853

Added line #L853 was not covered by tests

# get the view without the excluded atoms
view = np.delete(np.arange(len(P)), reorderexcl)
view = np.delete(np.arange(len(P)), exclusions)

Check warning on line 856 in clusttraj/io.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/io.py#L856

Added line #L856 was not covered by tests
Pview = P[view]
Paview = Pa[view]

prr = reorder(Qa[view], Paview, Q[view], Pview)
Pview = Pview[prr]

# build the total molecule with the reordered atoms
# whereins = np.where(np.isin(np.arange(len(P)), reorderexcl) is True)
whereins = np.where(

Check warning on line 864 in clusttraj/io.py

View check run for this annotation

Codecov / codecov/patch

clusttraj/io.py#L864

Added line #L864 was not covered by tests
np.atleast_1d(np.isin(np.arange(len(P)), reorderexcl))
np.atleast_1d(np.isin(np.arange(len(P)), exclusions))
)
Pr = np.insert(
Pview,
[x - whereins[0].tolist().index(x) for x in whereins[0]],
P[reorderexcl],
P[exclusions],
axis=0,
)
else:
Expand Down

0 comments on commit 9d50cdf

Please sign in to comment.