Skip to content
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

prevent un-necessary recalculation of RMSD matrix #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pyext/src/exhaust.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,20 @@ def main():

print("Size of conformation matrix", conforms.shape)

if not args.skip_sampling_precision:
# get_rmsds_matrix modifies conforms, so save it to a file and restore
# afterwards (so that we retain the original IMP orientation)
numpy.save("conforms", conforms)
# get_rmsds_matrix modifies conforms, so save it to a file and restore
# afterwards (so that we retain the original IMP orientation)
numpy.save("conforms", conforms)

if not os.path.isfile("Distances_Matrix.data.npy"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the user

  • runs a simulation
  • does analysis, creating Distances_Matrix.data.npy
  • goes back and runs a new simulation
  • does a 2nd round of analysis?

Won't this file then be out of date and result in a hard-to-diagnose issue (matrix is for the first run but is used in the second run)? If so, one fix might be to stat the matrix/RMF/PDB files and only skip the matrix creation if the .npy file is newer than all RMF/PDB. Another would be to never reuse your cached matrix unless the user explicitly requests it with a --use-cache option or similar. Always better to err on the side of caution with caching.

print("Computing RMSD matrix...")
inner_data = rmsd_calculation.get_rmsds_matrix(
conforms, args.mode, args.align, args.cores, symm_groups)
conforms, args.mode, args.align, args.cores, symm_groups)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff seems unnecessary since you don't change any logic, only whitespace. In fact, it may even cause flake8 to complain.

print("Size of RMSD matrix (flattened):", inner_data.shape)
del conforms
conforms = numpy.load("conforms.npy")
os.unlink('conforms.npy')
else:
print("Loading saved RMSD matrix")

from pyRMSD.matrixHandler import MatrixHandler
mHandler = MatrixHandler()
Expand Down