samirelanduk / atomium

Python macromolecular parsing (with .pdb/.cif/.mmtf parsing and production)
https://atomium.bio
MIT License
102 stars 19 forks source link

Loading 6LU7 from mmtf fails in decode_dict #31

Closed zacharyrs closed 3 years ago

zacharyrs commented 3 years ago

Expected behaviour

Should read the 6lu7.mmtf file and return a atomium.data.File instance.

Actual behaviour

Crashes within decode_dict.

~/.pyenv/versions/3.8.6/envs/helico-base/lib/python3.8/site-packages/atomium/mmtf.py in decode_dict(d)
     41             elif isinstance(new_value[0], bytes):
     42                 new_value = [x.decode() for x in new_value]
---> 43         new[key.decode()] = new_value
     44     return new
     45 

AttributeError: 'str' object has no attribute 'decode'

I think the .decode() call is unnecessary.

Example code to reproduce

mmtf1 = atomium.open('/home/zach/Downloads/6lu7.mmtf')

Python Version/Operating System

Python 3.8.6 in a venv, on Ubuntu 20.04.1.

samirelanduk commented 3 years ago

This was a strange one - I couldn't replicate it on Mac on Python 3.8, or Ubuntu on Python 3.6, but I did replicate it on Ubuntu on Python 3.8. Not sure what was happening there.

In any case I think I've fixed the issue now - it will now only try to decode if it's a bytestring.