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

Features/rmsd rmsf #381

Draft
wants to merge 7 commits into
base: staging
Choose a base branch
from
Draft

Features/rmsd rmsf #381

wants to merge 7 commits into from

Conversation

schampoux
Copy link
Contributor

No description provided.

@schampoux schampoux changed the base branch from main to staging February 21, 2025 21:08
Comment on lines +436 to +441
def calculate_rmsd(simulation, reference_simulation) -> float:
positions = simulation.context.getState(getPositions=True).getPositions(asNumpy=True)
reference_simulation_positions = reference_simulation.context.getState(getPositions=True).getPositions(asNumpy=True)
diff = positions - reference_simulation_positions
rmsd = np.sqrt(np.mean(diff**2))
return rmsd
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont like that these take simulation objects rather than the positions themselves. We should be able to decouple the functionality of obtaining the information need for rmsd and calculating rmsd. This function does more than just calculate. Please refactor

Copy link
Contributor

Choose a reason for hiding this comment

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

to further motivate this, I would like to iterate over many frames of the simulation, rather than a single one. I want this function to not need a simulation object at all unless needed

Copy link
Contributor

Choose a reason for hiding this comment

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

also, there are different ways (likely more accepted ways) to do this calculation. see:

  1. https://docs.mdanalysis.org/1.1.1/documentation_pages/analysis/rms.html
  2. https://userguide.mdanalysis.org/stable/examples/analysis/alignment_and_rms/rmsf.html

these are related to alignment. I have also done this in the past and you can't just simply take the rmsd, but you need to check if the number of atoms is the same because it actually does change if you don't do the same processing to the molecule

return False

# Check to see if we have a logging resolution of 10 or better, if not the run is not valid
if (self.log_file['#"Step"'][1] - self.log_file['#"Step"'][0]) > 10:
return False

return True
return True, rmsd
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this - why does the method need to return rmsd here instead of doing the calculation somewhere else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants