-
Notifications
You must be signed in to change notification settings - Fork 663
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
Allow analysis classes to run on arbitrary selections of frames #1985
Comments
👍 I like the idea of using the new trajectory iterables as a concise way to work with trajectories. I suppose, this is now being called "working with frames". |
Sidenote: I think this approach frames_group0 = u.trajectory[labels == 0] is beautiful. Would it make sense to add a t2 = u.trajectory.copy()
frames2 = t2[labels == 2] so that we can have multiple frames iterables that do not interfere with each other, e.g., for cross correlation time analysis... EDIT: Yes, this is flawed... it is not clear where one |
For this you can use the universe copy method and individual selections for each. |
We have a |
Copying only the reader is going to badly mess with the Universe and
Atomgroup. Except if it spawn a new Universe, but it is seriously
non-intuitive and non trivial to do as a reader does not have knowledge
of the universe.
…On 07/13/2018 07:15 PM, Oliver Beckstein wrote:
We have a |Universe.copy()|
<https://www.mdanalysis.org/docs/documentation_pages/core/universe.html?highlight=universe%20copy#MDAnalysis.core.universe.Universe.copy>
... apparently so. And we also have |trajectory.copy()|. I didn't
know... (and the docs don't tell me when this was added, so must have
been a while.)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1985 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUWuirRToWgVHvgpZceYmS3FhdvakOmks5uGNXEgaJpZM4VOeEi>.
|
Fair enough ;-) |
Nope fairly recent. It's mentioned in the changelog though. |
@rsexton2 , as discussed, this might be an outline for changing from MDAnalysis.tests import datafiles as data
import MDAnalysis as mda
u = mda.Universe(data.TPR, data.XTC)
frames = [0, 2, 4, 5]
def setup_frames(start, stop, step, frames):
if frames is not None:
if any([start, stop, step]):
raise ValueError("start/stop/step cannot be combined with frames")
slicer = frames
else:
slicer = slice(start, stop, step)
sliced_traj = u.trajectory[slicer]
n_frames = len(sliced_traj)
return n_frames, sliced_traj |
@orbeckst that solution might need care if combined with mdanalysis/package/MDAnalysis/coordinates/base.py Lines 1694 to 1696 in 943da48
|
The way that @rsexton2 and I discussed it (which should be reflected in the snippet) is that using |
For right now we also did not include the original suggestion to be able to pass a sliced trajectory in ag.write("traj.xtc", frames=ag.universe.trajectory[::2]) where frames can be a sliced trajectory (a |
- Fix MDAnalysis#1985 - Added changes to AUTHORS CHANGELOG - Added tests to test_base.py and changes to base.py
It would be convenient to be able to run some analyses on an arbitrary set of frames. I recently encounter a case where I wanted to build an RSMD matrix with
mda.analysis.diffusionmap.DistanceMatrix
on a selection of frame I obtained from clustering. For now, the only ways I could find to do that was to either write a new trajectory (on file or in memory), or to hack aSelectionReader
. Adding aframes
argument to run alonsidestart
,stop
, andstep
(see #1979) would allow to pass an array of frame indices, or a mask, or an already indexed trajectory using #1934. The interface would be the same as forag.write
.Some analyses rely on the time step to be constant, so the use of the
frames
must be limited for these analyses. An slices trajectory can be used, but not an indexed one. In these case, aNotImplementedError
should be raised. This could be achieved by using a class attribute to switch off arbitrary frame selections:The text was updated successfully, but these errors were encountered: