emdb-empiar / sfftk-rw

Toolkit for reading and writing EMDB-SFF files
Apache License 2.0
2 stars 0 forks source link

KeyError: b'little' #5

Closed tomgoddard closed 3 years ago

tomgoddard commented 4 years ago

Opening emd_1014.hff test data using PyPi sfftk-rw 0.6.1.dev0 gives the following error. The ENDIANNESS dictionary has unicode strings but lookup is trying to use bytes. This is with numpy 1.17.1.

"/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/emdb_sff/init.py", line 24, in open_file return sff.read_sff(session, path) File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/emdb_sff/sff.py", line 29, in read_sff lmodels = lattice_models(session, seg) File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/emdb_sff/sff.py", line 82, in lattice_models d = lattice.data_array # Docs say number array, but emd 1547 gives bytes File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sfftkrw/schema/adapter_v0_8_0_dev1.py", line 622, in data_array start=self.start File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sfftkrw/schema/adapter_v0_8_0_dev1.py", line 698, in decode endianness = ENDIANNESS[endianness] KeyError: b'little'

KeyError: b'little'

File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sfftkrw/schema/adapter_v0_8_0_dev1.py", line 698, in decode endianness = ENDIANNESS[endianness]

tomgoddard commented 4 years ago

File being read was v0.8

sfftk-rw/sfftkrw/test_data/sff/v0.8/emd_1014.hff

paulkorir commented 4 years ago

I've been able to reproduce this. Let me have a look at it.

paulkorir commented 4 years ago

I've fixed this. The problem was the test data files which had bytes stored. I'd changed the package to write HDF5 as unicode but had forgotten to update the test data files. I'll leave this open just in case you spot something related. Please pull the latest master for the fixed HDF5 files.

tomgoddard commented 3 years ago

I have confirmed this is fixed using sfftk-rw 0.7.0.post1 and the current test data files at

https://github.com/emdb-empiar/sfftk-rw/tree/master/sfftkrw/test_data/sff/v0.8