Skip to content

Conversation

@PardhavMaradani
Copy link

@PardhavMaradani PardhavMaradani commented Dec 22, 2025

Fixes #5183

Changes made in this Pull Request:

  • Added a current frame iterator for streamed trajectories
    • The iterator is created when the frames array has a single value that is same as the current frame

This PR allows us to do something like the following:

import MDAnalysis as mda
from MDAnalysis.analysis.dssp import DSSP

top = "/tmp/imd-workshop-2025/workshop/sample_simulation/GROMACS/input/start.gro"
u = mda.Universe(top, "imd://localhost:8889")
_dssp = DSSP(u)
for i in range(5):
    ts = u.trajectory.ts
    print(ts.data, ts.frame)
    run = _dssp.run(frames=[ts.frame])
    print("".join(run.results.dssp[0]))
    u.trajectory.next()

Here is a sample output of the per-frame analysis above:

{'time': 14.76, 'dt': 0.002, 'step': 7380} 0
-E--HHHHHHHHHH-----HHHE-HHHHHHHHHHHH--E---EEE-----EEE----E------E-------------EHHHHH----HHHHHHHHHHH-----HHH-HHHHHH------HHHH-----
{'time': 14.8, 'dt': 0.002, 'step': 7400} 1
-E--HHHHHHHHHH-----HHHE-HHHHHHHHHHHH--E---EEE-----EEE----EE-----E-------------EHHHH-----HHHHHHHHHHH----HHHH-HHHHHH------HHHH-----
{'time': 14.84, 'dt': 0.002, 'step': 7420} 2
-E--HHHHHHHHHH-----HHHE-HHHHHHHHHHHH--E---EEE-----EEE----EE-----E-------------EHHHH-----HHHHHHHHHH-----HHHH-HHHHHH------HHHH-----
{'time': 14.88, 'dt': 0.002, 'step': 7440} 3
-E--HHHHHHHHHH-----HHHE-HHHHHHHHHHH---E---EEE-----EEE----EE-----E-------------EHHHH-----HHHHHHHHHHH----HHHH-HHHHHH---------------
{'time': 14.92, 'dt': 0.002, 'step': 7460} 4
-E--HHHHHHHHHH-----HHHE-HHHHHHHHHHH---E---EEE-----EEE----EE-----E-------------EHHHHH----HHHHHHHHHHHH---HHHH-HHHHHH------HHH------

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added?
  • Documentation updated/added?
  • package/CHANGELOG file updated?
  • Is your name in package/AUTHORS? (If it is not, add it!)

Developers Certificate of Origin

I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.


📚 Documentation preview 📚: https://mdanalysis--5184.org.readthedocs.build/en/5184/

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on GitHub Discussions so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS as part of this PR.

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.74%. Comparing base (9fb8b0a) to head (04f60c0).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5184      +/-   ##
===========================================
+ Coverage    92.72%   92.74%   +0.01%     
===========================================
  Files          180      180              
  Lines        22472    22487      +15     
  Branches      3188     3190       +2     
===========================================
+ Hits         20838    20856      +18     
+ Misses        1176     1174       -2     
+ Partials       458      457       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BradyAJohnston
Copy link
Member

This seems like a good idea to me - but I would defer to those more experienced with MDA & streaming as for why this approach maybe wasn't already taken.

@orbeckst
Copy link
Member

I’m away from most of work (and open source) and won’t get to reviewing until the new year. But please let this not halt any discussions here!

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.

Support per-frame analysis by AnalysisBase-based classes for streamed trajectories

3 participants