Skip to content

Error when loading multiple large DCD trajectories #4039

@vdeshchenya

Description

@vdeshchenya

Expected behavior

I create a Universe with several large trajectory files (size > 2 GB) and use the transfer_to_memory function to load them.

Actual behavior

The transfer_to_memory function fails after loading 53458/117600 frames with the error "OSError: DCD seek failed with DCD error=Normal EOF".

Loading frames:  45%|████████████████████████████████████████████████████████▎                                                                   | 53458/117600 [00:07<00:09, 7050.72it/s]
Traceback (most recent call last):
  File "/Users/vladimir/test.py", line 15, in <module>
    u.transfer_to_memory(verbose=True)
  File "/opt/anaconda3/envs/work/lib/python3.9/site-packages/MDAnalysis/core/universe.py", line 626, in transfer_to_memory
    for i, ts in enumerate(ProgressBar(self.trajectory[start:stop:step],
  File "/opt/anaconda3/envs/work/lib/python3.9/site-packages/tqdm/std.py", line 1195, in __iter__
    for obj in iterable:
  File "/opt/anaconda3/envs/work/lib/python3.9/site-packages/MDAnalysis/coordinates/chain.py", line 672, in __next__
    self.ts = self.active_reader[f]
  File "/opt/anaconda3/envs/work/lib/python3.9/site-packages/MDAnalysis/coordinates/base.py", line 828, in __getitem__
    return self._read_frame_with_aux(frame)
  File "/opt/anaconda3/envs/work/lib/python3.9/site-packages/MDAnalysis/coordinates/base.py", line 860, in _read_frame_with_aux
    ts = self._read_frame(frame)  # pylint: disable=assignment-from-no-return
  File "/opt/anaconda3/envs/work/lib/python3.9/site-packages/MDAnalysis/coordinates/DCD.py", line 198, in _read_frame
    self._file.seek(i)
  File "MDAnalysis/lib/formats/libdcd.pyx", line 398, in MDAnalysis.lib.formats.libdcd.DCDFile.seek
OSError: DCD seek failed with DCD error=Normal EOF

(53458 frames take up about 2 GB of memory)

Code to reproduce the behavior

import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD

u = mda.Universe(PSF, DCD)

# creating a big trajectory (2.2 GB)
ag = u.select_atoms("all")
with mda.Writer('test.dcd', ag.n_atoms) as w:
    for _ in range(600):
        for ts in u.trajectory:
            w.write(ag)


u = mda.Universe(PSF, 'test.dcd', 'test.dcd')
u.transfer_to_memory(verbose=True)

Current version of MDAnalysis

  • Which version are you using? (run python -c "import MDAnalysis as mda; print(mda.__version__)"): 2.4.2
  • Which version of Python (python -V)?: Python 3.9.15
  • Which operating system?: MacOS Ventura 13.1 (22C65)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions