Skip to content
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

Can only run encore convergence on DCDReader/MemoryReader trajectories #2578

Closed
lilyminium opened this issue Mar 4, 2020 · 3 comments · Fixed by #3890
Closed

Can only run encore convergence on DCDReader/MemoryReader trajectories #2578

lilyminium opened this issue Mar 4, 2020 · 3 comments · Fixed by #3890

Comments

@lilyminium
Copy link
Member

Expected behavior

I can run encore.[dr/c]es_convergence on any MDAnalysis universe trajectory.

Actual behavior

It fails because prepare_ensembles_for_convergence_increasing_window fails to transfer trajectories into memory before calling timeseries on them.

Code to reproduce the behavior

Show us how to reproduce the failiure. If you can, use trajectory files from the test data.

>>> import MDAnalysis as mda
>>> from MDAnalysis.tests.datafiles import PSF, DCD,  GRO, PDB, TPR, XTC, TRR,  PRMncdf, NCDF
>>> from MDAnalysis.analysis import encore

>>> u = mda.Universe(TPR, XTC)
>>> encore.dres_convergence(u, 10)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-23-24fe8767487d> in <module>
----> 1 encore.dres_convergence(u, 10)

~/pydev/mdanalysis/package/MDAnalysis/analysis/encore/similarity.py in dres_convergence(original_ensemble, window_size, select, dimensionality_reduction_method, nsamples, ncores)
   1672 
   1673     ensembles = prepare_ensembles_for_convergence_increasing_window(
-> 1674         original_ensemble, window_size, select=select)
   1675 
   1676     coordinates, dimred_details = \

~/pydev/mdanalysis/package/MDAnalysis/analysis/encore/similarity.py in prepare_ensembles_for_convergence_increasing_window(ensemble, window_size, select)
    693     """
    694 
--> 695     ens_size = ensemble.trajectory.timeseries(ensemble.select_atoms(select),
    696                                               order='fac').shape[0]
    697 

AttributeError: 'XTCReader' object has no attribute 'timeseries'

Currently version of MDAnalysis

  • Which version are you using? (run python -c "import MDAnalysis as mda; print(mda.__version__)") 0.20.2-dev
  • Which version of Python (python -V)?
  • Which operating system?
@richardjgowers
Copy link
Member

Related work:

#1400 (comment)

#2271

I think maybe the cleanest fix would be to scrap the concept of .timeseries() (which dumps coordinates into memory) and instead use .transfer_to_memory() (which also dumps coordinates into memory, but in a more useful form). Ie a MemoryReader is much better than a numpy array

@orbeckst
Copy link
Member

orbeckst commented Mar 5, 2020

There are legitimate reasons to have a whole trajectory as one big array; however, one can use MemoryReader.get_array() (or just MemoryReader.coordinate_array (although this is not explicitly documented). The MemoryReader.timeseries() method is useful, though, because it can reshape the array – how often that is used is another question.

@hmacdope
Copy link
Member

linked to #3761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants