-
Notifications
You must be signed in to change notification settings - Fork 112
Add DSSP support for trajectories #1072
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
base: main
Are you sure you want to change the base?
Add DSSP support for trajectories #1072
Conversation
BradyAJohnston
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this mostly nails it straight up.
Only real change is I think we should allow for someone to enable or disable the SS computation after import. This will require a new property on the object, and to be able to handle doing the setup for the SS after import if not previously set up on import.
I did think about having this as a dynamic option like you suggested, but wasn't sure how intensive the analysis run could be, etc - so thought it'd be best to leave it at initial import. If we are making this true by default, one other option is to include a "None" option to the |
|
Oh I didn't realise it was all being run on import. The "ideal" would be that it runs on frame change (not sure how possible this is) - so that we are only ever computing what is currently relevant (and could support streaming trajectories also). Depends on how feasible this is and what kind of overhead is associated with calling the analysis each frame instead of once on initial import. I think your suggestion of adding the |
The dssp run can be done for specific frames - i.e., on frame change for us, but then, we'll not have the concept of averaging because that requires a run across the whole trajectory. It also introduces an analysis run every frame change and if we make this the default, it could make scrubbing the timeline etc a bit laggy. I also tried out for streaming trajectories, but couldn't get this to work yet (even though there is frame slicing support) - seems like this is common for most other analysis stuff too that depend on
I wasn't thinking of removing the original |
* Control display (average/per-frame/none) with single enum, default: per-frame * Expose the DSSP selection in the 3D viewport n-panel under Trajectory details * Use cached values from full run if available * Change default from None to "all" for style selection param
|
Hi Brady, the above commit is the closest we can get to "ideal" case. I also figured out why the sec structures were not showing up until a frame change when importing a trajectory from the GUI or from the API without an explicit selection string. (the issue I described at the end of the initial comment). The reason for this is that an Here is a summary of the changes:
|
|
Forgot to add a few rough performance measurements I made earlier in my setup:
|
* Universe(GRO_MEMPROT, XTC_MEMPROT) is example of missing and non-seq resids
|
The current DSSP Analysis Class unfortunately doesn't work with streaming trajectories. There is however a standalone assign function that can be used to get the sec structs, but the changes are a bit more involved. They seem to work fine for some simpler cases, but requires more testing, etc. I think it is best to handle those as a separate PR for the |
You are right that this has broken. I'm not sure when but it seems like it has been broken for a while & I haven't noticed it. I've got a version that is working again (in the branch you have seen) that is about 15x faster than what was previous running (and not working). Given potential performance hits that you have detailed, it does make me think that maybe instead we should have SS computation disabled by default. Whether we still compute and store I've seen you PR about the current frame iterator which should help us here. Additionally I've opened a PR that will help speed up SS computation : MDAnalysis/mdanalysis#5182 |
* Change sec_struct attribute type to int to match nodes
|
Hi Brady, I changed the default to none. Thus, this will not change any existing behavior and even the |
|
Here is the regular psf/dcd viewport animation using the mda dssp computed average values: psf-dcd-dssp-avg-animation.mp4 |
|
Looks like something strange is happening with the cartoon style - likely an issue with the node and not this PR. I'll have a look into it. |
Hi Brady, just fyi that I am using the import MDAnalysis as mda
import molecularnodes as mn
from MDAnalysis.tests.datafiles import DCD, PSF
u = mda.Universe(PSF, DCD)
canvas = mn.Canvas()t = mn.entities.Trajectory(u).add_style("cartoon") |
BradyAJohnston
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could organise it a bit more maybe with a helper class for DSSP related stuff, and allow a user to change the window over which we average SS computed frames.
Additionally when changing from "per-frame" to "average" and the DSSP has to be run on the entire trajectory - some kind of feedback to the user that Blender might freeze for some time (especially on larger systems) would be good. An enum isn't usually something you might expect to freeze the program when you change. Not sure what the best approach might be though.
Hi Brady, given the requirements are evolving, could we agree upon how this will eventually look (from both the GUI and API perspective) before I go ahead and make any further changes? Here is what I have in mind that could potentially address all the issues discussed so far:
Your thoughts? Thanks |
* Support a sliding window average * Support trajectory average with threshold * Undo previous style selection default to "all" changes
* Fix docstring
|
Hi Brady, I went ahead and made changes as per the previous comment. A few minor changes from there - mostly for better usability, but the rest are the same. You could give this a try. Here is a video that shows the new options: trajectory-dssp-manager-new.mp4 |
* Add an option to control threshold comparison * Explicitly set to default (none) after init

Hi Brady, this PR adds DSSP support for trajectories that you mentioned in this comment and pointed to an existing issue #872. Instead of an annotation, I think it would be better to have this as a direct import option for trajectories (both though GUI and API) - it might be helpful later too when everything moves to an MDA backend. This should fix #872
Here are some before and after examples:
For the API, there is a new

use_dsspparam and for the GUI, there is a new checkbox as follows:The DSSP example from the user guide shows how an average value can be used as well. Using this (which is the default) leads to a more smoother animation as these don't change per frame. This is a runtime option that can be changed from the API using

dssp_typeattribute in the trajectory or as below from the GUI (The GUI option only shows when there is valid dssp run info):I added a couple of tests (with and without dssp) for basic validations.
One issue I ran into that you probably know more than me why it happens: From the GUI, the sec structure only show up after a frame change. It is the same from the API if the style is created without any selection (eg:
t = mn.entities.Trajectory(u, use_dssp=True).add_style("cartoon")requires a frame change to see the results, but fort = mn.entities.Trajectory(u, use_dssp=True).add_style("cartoon", selection="all"), this shows up right away in the viewport.