MDAnalysis / mdanalysis

MDAnalysis is a Python library to analyze molecular dynamics simulations.
https://mdanalysis.org
Other
1.31k stars 648 forks source link

Should we allow adding additional information to a MemoryReader #1057

Open kain88-de opened 8 years ago

kain88-de commented 8 years ago

Connected to #1037

This post on the mailing list lead me to think if we should allow to add write auxillary data into specific format fields. So for example if the following code could write the b-factor information for every time.

u.trajectory.add_aux('tempfactor', temp_factors)
u.trajectory.write('test.pdb')

This isn't an ideal syntax I'm aware. But the general idea looks nice to me. It will also make it easier to prepare PDB's to be consumed by other tools. Currently we would have to write

u.trajectory.add_aux('tempfactor', temp_factors)
with mda.Writer('test.pdb') as w:
    for ts in u.trajectory:
        ag.tempfactor = ts.aux.tempfactor
        w.write(ag)

I'm not sure how easy it would be to implement the first variant and if it's a common enough use case that it's worth making the writers/aux system more complex. The second example should still be useful as an example in the docs to use the aux system inside of mdanalysis and preparing PDB's for example VMD.

orbeckst commented 7 years ago

What I find interesting about your idea is that we now start thinking of trajectories as full-fledged objects in their own rights and how we can operate on trajectories. (The PSA module, where paths are compared, is obviously doing this, at least in principle.) This, I think, is also still different from what MDSynthesis does, where universes are primarily thought of as data sources whereas here, we would be thinking of operating on trajectories. This could become a useful and powerful abstraction.

Is there a "MemoryReader"-like equivalent of aux timeseries, i.e., could we think of a memory-resident aux tied to either an on-disk trajectory or an in-memory trajectory?