Refactor of universe creation and applying transformations#93
Conversation
| from openfe_analysis.utils.multistate import _determine_position_indices | ||
|
|
||
|
|
||
| def _create_universe_single_state(top, trj, state): |
There was a problem hiding this comment.
I think this should go into utils. The reader file should really concentrate on reader things rather than universe creation.
There was a problem hiding this comment.
I moved it into it's own universe_utils.py file.
| ligand: Optional[mda.AtomGroup] = None, | ||
| ): | ||
| """ | ||
| Apply a collection of transformations to a Universe. |
There was a problem hiding this comment.
Since MDAnalysis transformations are meant to be quite flexible and additive, it might be good to be more descriptive about this sentence. Maybe be even just "collection of transformations usually required for X, Y, Z analyses" would be fine.
There was a problem hiding this comment.
Added that they are typically used in RMSD analyses and other structural analyses.
| u.trajectory.add_transformations(*transforms) | ||
|
|
||
|
|
||
| def _apply_transformations_complex(protein, ligand=None): |
There was a problem hiding this comment.
Please do add type hints everywhere.
jthorton
left a comment
There was a problem hiding this comment.
Thanks @hannahbaumann looks great, nothing to add over @IAlibay so i'll approve early!
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
There was a problem hiding this comment.
Tests are now in test_gather_rms_data.py and test_transformations.py
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
+ Coverage 96.93% 97.63% +0.70%
==========================================
Files 6 8 +2
Lines 359 381 +22
==========================================
+ Hits 348 372 +24
+ Misses 11 9 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
IAlibay
left a comment
There was a problem hiding this comment.
Couple of small things that might be worth fixing, I'm going to eagerly approve.
| from ..reader import FEReader | ||
|
|
||
|
|
||
| def create_universe_single_state(top: Path, trj: nc.Dataset, state: int) -> mda.Universe: |
There was a problem hiding this comment.
| def create_universe_single_state(top: Path, trj: nc.Dataset, state: int) -> mda.Universe: | |
| def create_universe_single_state(top: Path | mda.core.topology.Topology, trj: nc.Dataset, state: int) -> mda.Universe: |
Or something like that - you can actually pass anything that Universe accepts for the topology argument. In practice we actually pass through a pre-existing Topology (see how it's called in gather_rms_data), so making it clear that it could at least be one of Path and Topology would be grand.
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
|
pre-commit.ci autofix |
The
make_Universefunction did two things: Create a Universe for a state and then applying some transformations to it, hard coding selection strings for protein and ligand.Here, I split off the creation of the universe and the applying of transformations into separate steps. This allows passing AtomGroups to the
apply_transformationsfunction. I thought that this might be useful for moving towards a more individualProtocolbased analysis.