loos icon indicating copy to clipboard operation
loos copied to clipboard

apparent fencepost error in 'pdb traj' reading.

Open lgsmith opened this issue 6 months ago • 0 comments

Describe the bug

I get a:

terminate called after throwing an instance of 'std::out_of_range'
  what():  Bad index for an atom
Aborted (core dumped)

from trying to read to the end of a trajectory defined with the multipose pdb

To Reproduce

I attached an example pdb test-pose.txt (change the extension, obviously). When I try to read it like this:

import loos
from loos import pyloos
m = loos.createSystem('test-pose.pdb')
t = pyloos.Trajectory('test-pose.pdb', m)
print(len(t))
t[len(t) - 1]

I get the segfault. When I delete the last ENDMDL record, the file can be read through the final frame and the iterator exhausts normally. The issues don't arise until trying to reference the 'final' frame.

Expected behavior

Reading all 20 frames, then having the iterator know it's empty instead of thinking there are 21 and segfaulting.

LOOS version and platform

conda install 4.04 linux

Additional context

Alan and I slacked about this. It looks like the ENDMDL record queues the reader to expect another frame, but this PDB (created from a multipose sdf using openbabel) ends with:

ENDMDL
END

lgsmith avatar Jul 26 '24 19:07 lgsmith