Opened 22 hours ago

Closed 6 hours ago

#20565 closed defect (fixed)

DCD file reader probably broken with numpy 2

Reported by: Tom Goddard Owned by: Tom Goddard
Priority: moderate Milestone:
Component: Input/Output Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

The DCD file reader code

md_crds/src/dcd/MDToolsMarch97/md_DCD.py

uses the numpy 1 fromstring() method on bytes data and that gives an error in numpy 2 where the frombuffer() routine needs to be used instead. frombuffer() also works in numpy 1. I don't have a DCD file to test on. If you gave me one I could test with my numpy 2 ChimeraX and fix it.

Change History (4)

comment:1 by Eric Pettersen, 8 hours ago

bundles/md_crds/test-data/{start.pdb,test.dcd}

comment:2 by Tom Goddard, 6 hours ago

As expected reading DCD gives an error with numpy 2. Here is the log

UCSF ChimeraX version: 1.13.dev202606302219 (2026-06-30)
© 2016-2026 Regents of the University of California. All rights reserved.
How to cite UCSF ChimeraX
open /Users/goddard/ucsf/chimerax/src/bundles/md_crds/test-data/start.pdb
Chain information for start.pdb #1
Chain	Description
?	No description available

Computing secondary structure
open /Users/goddard/ucsf/chimerax/src/bundles/md_crds/test-data/test.dcd structureModel #1
Traceback (most recent call last):
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/cmd_line/tool.py", line 322, in execute
    cmd.run(cmd_text)
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/core/commands/cli.py", line 3245, in run
    result = ci.function(session, **kw_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/open_command/cmd.py", line 138, in cmd_open
    models = Command(session, registry=registry).run(provider_cmd_text, log=log)[0]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/core/commands/cli.py", line 3245, in run
    result = ci.function(session, **kw_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/open_command/cmd.py", line 234, in provider_open
    models, status = collated_open(session, None, [data], data_format, _add_models,
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/open_command/cmd.py", line 547, in collated_open
    return remember_data_format()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/open_command/cmd.py", line 518, in remember_data_format
    models, status = func(*func_args, **func_kw)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/md_crds/__init__.py", line 137, in open
    num_coords = read_coords(session, data, structure_model, md_type,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/md_crds/read_coords.py", line 64, in read_coords
    num_frames = _set_model_dcd_coordinates(session, model, dcd, replace, start, step, end, omit)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/md_crds/read_coords.py", line 134, in _set_model_dcd_coordinates
    crds = asarray(dcd[i], float64, order = 'C')
                   ~~~^^^
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/md_crds/dcd/MDToolsMarch97/md_DCD.py", line 269, in __getitem__
    x = fromstring(f.read(cs(repr(self.N)+'f')),float32)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: The binary mode of fromstring is removed, use frombuffer instead

ValueError: The binary mode of fromstring is removed, use frombuffer instead

File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/md_crds/dcd/MDToolsMarch97/md_DCD.py", line 269, in __getitem__
x = fromstring(f.read(cs(repr(self.N)+'f')),float32)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

See log for complete Python traceback.

comment:3 by Tom Goddard, 6 hours ago

Owner: changed from Eric Pettersen to Tom Goddard

Fixed.

Replaced numpy fromstring with frombuffer.

comment:4 by Tom Goddard, 6 hours ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.