Refactor RMSD analyses into MDAnalysis AnaysisBase classes#90
Refactor RMSD analyses into MDAnalysis AnaysisBase classes#90hannahbaumann wants to merge 5 commits intomainfrom
AnaysisBase classes#90Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
+ Coverage 88.16% 96.37% +8.21%
==========================================
Files 7 6 -1
Lines 338 359 +21
==========================================
+ Hits 298 346 +48
+ Misses 40 13 -27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@talagayev and @jthorton : This is a first go at the refactor into the individual RMSD classes, based on the MDAnalysis |
AnaysisBase classes
src/openfe_analysis/rmsd.py
Outdated
| class LigandRMSD(AnalysisBase): | ||
| """ | ||
| 1D RMSD time series for a ligand AtomGroup. | ||
| """ | ||
|
|
||
| def __init__(self, atomgroup, **kwargs): | ||
| super(LigandRMSD, self).__init__(atomgroup.universe.trajectory, **kwargs) | ||
|
|
||
| self._ag = atomgroup | ||
|
|
||
| def _prepare(self): | ||
| self.results.rmsd = [] | ||
| self._reference = self._ag.positions | ||
| self._weights = self._ag.masses / np.mean(self._ag.masses) | ||
|
|
||
| def _single_frame(self): | ||
| rmsd = rms.rmsd( | ||
| self._ag.positions, | ||
| self._reference, | ||
| self._weights, | ||
| center=False, | ||
| superposition=False, | ||
| ) | ||
| self.results.rmsd.append(rmsd) | ||
|
|
||
| def _conclude(self): | ||
| self.results.rmsd = np.asarray(self.results.rmsd) |
There was a problem hiding this comment.
2 initial thoughts:
- Can we make a more general RMSD class that can be reused for protein and ligand analysis, basically it should work on any atom group and does this not already exist in MDAnalysis?
- Do we not want to switch to use the symmetry RMSD (spyrmsd I think its called)?
There was a problem hiding this comment.
@jthorton : There's a difference between the RMSD class in MDAnalysis in what we've been doing, and I'm not sure yet what we want. In MDAnalysis, by default they are doing a superposition (rotational and translational), while we didn't do that. Now I'm not sure, what are we actually interested in, esp. for the ligand RMSD. Should this be the RMSD of the internal conformation of the ligand, or the RMSD of the ligand in the binding pocket/ligand pose? I think in the solvent we would definitely be more interested in the internal conformation of the ligand. In the binding pocket, I'm not sure. We also calculate the ligand COM displacement as a measure of stability in the pocket, but I'm not sure what we would want for the RMSD. What do you think?
talagayev
left a comment
There was a problem hiding this comment.
@hannahbaumann I like it, looks very good to me :) also the structure is like for the MDAnalysis AnalysisBase classes, which is I think @IAlibay wanted to have and also adressing it that it takes any atom group adressing @jthorton comment is good.
Overall Looks good to me :)
| prot2d[ts_i, :, :] = prot.positions | ||
| this_protein_rmsd.append( | ||
| rms.rmsd( | ||
| prot.positions, |
There was a problem hiding this comment.
This means that this is the RMSD of the protein backbone. Do we also want to provide the RMSD of the whole protein?
| prot_rmsd = RMSDAnalysis(prot).run(step=skip) | ||
| output["protein_RMSD"].append(prot_rmsd.results.rmsd) | ||
| # # Using the MDAnalysis RMSD class instead | ||
| # gs = ["protein and name CA", "protein"] |
There was a problem hiding this comment.
Here is an example of how we could do the same analysis using the MDAnalysis RMSD class.
Refactor the rmsd analysis using this example: https://docs.mdanalysis.org/2.7.0/documentation_pages/analysis/base.html
gather_rms_datafunction but access the individual analysis classes directly in the openfeProtocolmake_Universefunction go into utils?