Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #88 +/- ##
==========================================
+ Coverage 98.38% 98.50% +0.11%
==========================================
Files 10 11 +1
Lines 496 602 +106
==========================================
+ Hits 488 593 +105
- Misses 8 9 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| import prolif as plf | ||
|
|
||
|
|
||
| class ProLIFAnalysis: |
There was a problem hiding this comment.
Can you subclass AnalysisBase here?
There was a problem hiding this comment.
Yup should be doable, will look into it :)
Wanted to wait and see how RMSD will look like to use an identical structure and have this initial PR to have bulletpoints to discuss tomorrow during the meeting and also have an easier overview on what was changed etc. :)
There was a problem hiding this comment.
We leave it as is for now and will change this when Prolif implements per frame analysis.
|
I am not sure if this should be handled in the analysis class or in a protocol before running this class but there is an issue when doing this kind of analysis on trajectories from our hybrid topology protocol, where the connectivity of the end state ligands and identities of the atoms can get confused see this example on end stateB when looking at torsions. Should we add an option to provide and rdkit molecule for the ligand and use this to correct the ligand atom group automatically or should we have users fix this beforehand? This will be needed in the torsion analysis as well so a general function which could fix an atom group might be a good idea? |
…FreeEnergy/openfe_analysis into prolif_class_implementation
hannahbaumann
left a comment
There was a problem hiding this comment.
Thanks @talagayev , this looks good! The main part I'm not sure about is the run function, maybe we can discuss that tomorrow!
Resolved the test_prolif.py conflict by keeping the refactored version (universe/ligand_ag fixtures, WaterBridge test renamed to *_warns_and_raises, with-water test removed, plotting tests moved to tests/utils/test_plotting.py). prolif.py, plotting.py and conft.py (Zenodo fix #125) auto-merged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
…FreeEnergy/openfe_analysis into prolif_class_implementation
The universe fixture opened a netCDF file per test without closing it, so handles accumulated and a later open crashed on Windows. Close the trajectory on teardown, as test_universe_utils.py already does. Add two ProLIF example notebooks: one for a trajectory (per-frame and aggregate ligand network, barcode, 3D view, choosing interactions) and one for a single structure, including WaterBridge with a custom water_selection for SPC water. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
Thanks @talagayev for writing the tutorials! Could you maybe put them into a separate PR as this PR is becoming so big. I think that would make the review easier and allow us to already merge this main ProLIF PR earlier! |
hannahbaumann
left a comment
There was a problem hiding this comment.
Thanks @talagayev this is great! It's getting really close, these comments are mostly very small, but I think still important. And I was also wondering if you could put the notebooks into a separate PR so I can review them separately, that would be very helpful! Thanks!
| - openff-units | ||
| - pip | ||
| - tqdm | ||
| - prolif |
There was a problem hiding this comment.
I think you may also have to add prolif to the docs/environment.yaml file, hopefuly that will fix the readthedocs that are currently failing.
There was a problem hiding this comment.
Done added it to the docs environment :)
| water_order: int = 3, | ||
| protein_cutoff: float = 12.0, | ||
| water_cutoff: float = 8.0, | ||
| interactions: Optional[Sequence[str] | str] = None, |
There was a problem hiding this comment.
The reason why I would change here the str to Literal["all"] is that if you provided any str other than "all" (e.g. "Hydrophobic"), this would be split into ["H", "y", "d", ...]. We'd either have to handle the string other than all explicitly, or not allow it, but have the user always provide a list, even if it's of length 1.
|
|
||
| # Water: only if water-mediated interactions are of interest | ||
| water = self.universe.select_atoms(self.water_selection) | ||
| if water.n_atoms: |
There was a problem hiding this comment.
Should the guessing of water bonds also be conditional of whether WaterBridge is being requested?
There was a problem hiding this comment.
Yes that makes sense, no need if we don't do waterbridge so agree :)
| self.times = self.frames * self.universe.trajectory.dt | ||
| else: | ||
| self.times = None | ||
| except Exception: |
There was a problem hiding this comment.
I think we should be more specific here, otherwise any error during the above will just be silently turned into no frames/time found. Maybe we only except here for TypeError, AttributeError, maybe also ValueError, instead of a blank Exception?
There was a problem hiding this comment.
Adjusted the code, removed try/except since there should not be a case for them with MDAnalysis supporting len and dt
| else: | ||
| self.times = None | ||
| except Exception: | ||
| # Best-effort metadata: some readers lack len()/indices()/.dt. |
There was a problem hiding this comment.
Do you know which readers lack this information? I was just wondering, if e.g. in this repo we mostly want to support the FEReader which has the dt, the try/except would not be necessary?
There was a problem hiding this comment.
I think the MDAnalysis readers all support those, checked and didn't find any exceptions, so removed the try/except
| *, | ||
| figsize: tuple[int, int] = (8, 10), | ||
| dpi: int = 100, | ||
| interactive: bool = True, |
There was a problem hiding this comment.
Should we maybe have the default as false since we may mostly use this to write out pngs?
There was a problem hiding this comment.
Agree, yes better to have it as false via default
| Test for identification of interactions | ||
| """ | ||
| analysis = ProLIFAnalysis(universe, ligand_ag, interactions=["VdWContact"], guess_bonds=True) | ||
| analysis.run(stop=5, step=1, n_jobs=1, progress=False) |
There was a problem hiding this comment.
Should we add a test with n_jobs > 1 to test the parallel strategy?
There was a problem hiding this comment.
Yes that would be good, added test_run_parallel_matches_serial for that :)
| fp_interactions = None | ||
|
|
||
| elif interactions == "all": | ||
| # ProLIF's "all" excludes bridged interactions (e.g. WaterBridge) |
There was a problem hiding this comment.
Above in the doc string we're saying that "all" includes water bridges. Is this comment stale or would we need to update the dostring above?
There was a problem hiding this comment.
Yup the docstring is correct, comment was stale :) ProLIF’s own "all" currently leaves out water bridge interactions, which is why we build the list ourselves including WaterBridge. I adjusted the comment.
| assert analysis._parameters is not None | ||
| assert "WaterBridge" in analysis._parameters |
There was a problem hiding this comment.
| assert analysis._parameters is not None | |
| assert "WaterBridge" in analysis._parameters | |
| assert analysis._parameters is not None | |
| assert "WaterBridge" in analysis._parameters | |
| assert set(analysis.fp.interactions) == {"WaterBridge"} |
There was a problem hiding this comment.
Adjusted the code a little bit, since would else fail, but should work now :)
| u, | ||
| ligand_ag, | ||
| interactions=["WaterBridge"], | ||
| guess_bonds=False, |
There was a problem hiding this comment.
Could we also check the guess_bonds=True here? I wonder how expensive the water bond guessing will be...
There was a problem hiding this comment.
Yup switched to true. From CC looking at the times the system we have has 7900 SPC waters and the test went up from 1 to 18s.
Moving the ProLIF tutorials to a separate PR as requested in review, to keep this PR focused. They are preserved in 38b626a. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…FreeEnergy/openfe_analysis into prolif_class_implementation
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
| self.protein_ag = self.universe.select_atoms( | ||
| f"protein and byres around {protein_cutoff} group ligand", | ||
| ligand=self.ligand_ag, | ||
| updating=True, |
There was a problem hiding this comment.
I just saw here (https://prolif.readthedocs.io/en/v2.2.3/notebooks/water-bridge.html) that updating=True is not recommended for the protein. Should we maybe use false here, or use the select_over_trajectory() method mentioned on the same page?
| - openff-units | ||
| - pip | ||
| - tqdm | ||
| - prolif |
There was a problem hiding this comment.
We should probably pin to a minimum version here, maybe 2.1.0 since the WaterBridge was introduced there?
| - prolif | |
| - prolif>=2.1.0 |
| # Due to FEReader trajectory only certain strategies work with the format | ||
| if parallel_strategy is None: | ||
| # avoid ProLIF trying to pickle FEReader/netCDF trajectory to auto-pick strategy | ||
| parallel_strategy = "chunk" if (n_jobs is None or n_jobs == 1) else "queue" |
There was a problem hiding this comment.
A just realized we don't have a test for n_jobs=None and I just tried it out and it failed, I think because Prolif then defaults to parallel, so should it maybe be queue then or maybe I did something wrong in the test.
First draft of the ProLIF implementation into OpenFE Analysis.
Changes made:
ProLIFAnalysisclass for calculation of interactions using ProLIFtest_prolif.py, which mainly look into if interactions were calculated sucessfully and protein/ligand conversion fromMDAnalysisintoProLIFworked sucessfully.Currently that is the first draft and PR is to see that the tests work etc.
Some notes:
pd.DataFrameformat, since that is easy to see if it worked. We can see what the best way is to present the results, be it 2D visualization of the interactions, dataframes or some other format.MDAnalysisis sometimes tricky, which is the case here. So the code currently needs to guess bonds, which it does here:universe.select_atoms("protein").guess_bonds(vdwradii=vdwradii)But for the
vdwradiiit wants some values forCl,Bretc. that we need to provide, so we need to see what defaults we select there.3, which means it can be something like:Ligand--Water--Water--Water--ProteinProLIFAnalysis.run()there we can also look into what the defaults have to be, how many cores and if the interactions should beatombased (Ligand with Protein atom) orresiduebased (Ligand with Protein residue).This is the first draft, will be updated during further development :)
PS. A small thing I also noticed, since I tested it on different PCs with one being with Windows currently somehow
python 3.14has module loading Issues withrdkitand thus I had to downgrade there topython 3.13.