-
Notifications
You must be signed in to change notification settings - Fork 667
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
occupancy and b-factors not updated when importing multi-frame PBD #3825
Comments
This is an interesting one. We treat things like the occupancy and bfactors main attributes as a "topology" things, so they don't don't get updated as you read a new frame. However, specifically for occupancy, we do actually store that time dependent data under So for example if you did: import MDAnalysis as mda
u = mda.Universe('traj.pdb')
for ts in u.trajectory:
print(ts.data['occupancy']) You should be able to access the time dependent occupancy data. Adding tempfactors to this isn't a very difficult task, and would only require adding similar code bits to what we do with occupancy in this method:
This offers a quick fix, but doesn't remove the fact that we have two competing attributes and asking folks to look in |
Hi, thanks for getting back to me so quickly. I wasn't aware one is able to access the time-depedent data through |
I can second the want for this. Lots of people store frame-specific data in the |
@BradyAJohnston for arbitrary frame specific data we do have the auxiliary system, that probably would be the best place to fetch & store such data if looking to interfacing formally with the MDAnalysis API. |
@IAlibay Thanks but the use case I have I use MDAnalysis under the hood so there is no user interfacing with it. The data goes straight from topology / trajectory to 3D model inside of Blender so the arbitrary data needs to already exist inside of the trajectory (in this case it would be multi-model |
Dynamically updating a topology is a behaviour change I doubt we could allow any time soon (it's a pretty big overhaul of how we expect things to work), is there any way users could pass in a separate file with timeseries data that could be read alongside? I.e. like a CSV, XVG, or EDR file or maybe some kind of serialised xarray input? |
So one way to (ab)use the current tooling would be via a class BFactorUpdater(TransformationBase):
def __init__(self, ag):
self._ag = ag
def _transform(self, ts):
self._ag.bfactors = ts.data['occupancy'] # assumes this is populated by the Reader, true for PDB
return ts
u = mda.Universe()
bfactor_updater = BFactorUpdater(u.atoms)
u.trajectory.add_transformations([bfactor_updater]) that's some scrap code off the top of my head, but it should be possible along those lines |
For my use case at least, the accessing via: for ts in univ.traj:
ts.data['tempfactors'] With the same setup as the occupancies would work totally fine. I don't need it to be topology related, just a frame-specific data access. There is potential for reading |
Herein lies the issue. It's a non-standard use case for a deprecated format. I myself am guilty of abusing the PDB format this way so I'm happy to open a PR with the relevant fix as a temporary stopgap, but I would very much like to open the discussion about how this should be dealt with going forward. Having these arbitrary changes to readers are both user unfriendly and end up having a reasonably large maintenance cost in the long run. I'd like to be able to offer something that suits the downstream needs that would be the canonical way we encourage folks to use things. |
I would certainly be very appreciative of any direction you wish to take, both in short-term solutions and longer-term design plans. |
MDAnalysis uses the occupancies/b-factors of the first frame for all subsequent frames when importing a multi-frame PDB.
Code to reproduce the behavior
Also,
And link to traj.pdb.
Expected behavior
Actual behavior
Current version of MDAnalysis
The text was updated successfully, but these errors were encountered: