samirelanduk / atomium

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

KeyError: 'branched' when fetching some pdb files #27

Closed NicoBio closed 4 years ago

NicoBio commented 4 years ago

Expected behaviour

fetch a mmCIF structure

Actual behaviour

Key error

Example code to reproduce

s =atomium.fetch('6xlu')

Python Version/Operating System

3.8.3

For Bug Reports


KeyError Traceback (most recent call last) ~/anaconda3/envs/Py3/lib/python3.8/site-packages/atomium/mmcif.py in add_atom_to_non_polymer(atom, aniso, model, mol_type, names) 519 try: --> 520 model[mol_type][mol_id]["atoms"][ 521 int(atom["id"])

KeyError: 'branched'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)

in 1 # Downloading PDB ----> 2 s =atomium.fetch('6xlu') ~/anaconda3/envs/Py3/lib/python3.8/site-packages/atomium/utilities.py in fetch(code, *args, **kwargs) 73 if response.status_code == 200: 74 text = response.content if code.endswith(".mmtf") else response.text ---> 75 return parse_string(text, code, *args, **kwargs) 76 raise ValueError("Could not find anything at {}".format(url)) 77 ~/anaconda3/envs/Py3/lib/python3.8/site-packages/atomium/utilities.py in parse_string(filestring, path, file_dict, data_dict) 122 parsed = file_func(filestring) 123 if not file_dict: --> 124 parsed = data_func(parsed) 125 if not data_dict: 126 filetype = data_func.__name__.split("_")[0].replace("mmc", "c") ~/anaconda3/envs/Py3/lib/python3.8/site-packages/atomium/mmcif.py in mmcif_dict_to_data_dict(mmcif_dict) 206 update_quality_dict(mmcif_dict, data_dict) 207 update_geometry_dict(mmcif_dict, data_dict) --> 208 update_models_list(mmcif_dict, data_dict) 209 return data_dict 210 ~/anaconda3/envs/Py3/lib/python3.8/site-packages/atomium/mmcif.py in update_models_list(mmcif_dict, data_dict) 432 add_atom_to_polymer(atom, aniso, model, names) 433 else: --> 434 add_atom_to_non_polymer(atom, aniso, model, mol_type, names) 435 data_dict["models"].append(model) 436 for model in data_dict["models"]: ~/anaconda3/envs/Py3/lib/python3.8/site-packages/atomium/mmcif.py in add_atom_to_non_polymer(atom, aniso, model, mol_type, names) 523 except: 524 name = atom["auth_comp_id"] --> 525 model[mol_type][mol_id] = { 526 "name": name, "full_name": names.get(name), 527 "internal_id": atom["label_asym_id"], KeyError: 'branched'
samirelanduk commented 4 years ago

Thanks for flagging this, I'll aim to get a fix out this week.

samirelanduk commented 4 years ago

This should be fixed now in the new 1.0.6 version - let me know if there any problems.