aksell commited on
Commit
14646a1
·
1 Parent(s): b6e0c9a

Catch potential KeyError from chain

Browse files
hexviz/🧬Attention_Visualization.py CHANGED
@@ -283,7 +283,10 @@ Pick a PDB ID, layer and head to visualize attention from the selected protein l
283
  chain_dict = {f"{chain.id}": chain for chain in list(structure.get_chains())}
284
  data = []
285
  for att_weight, _, chain, resi in top_residues:
286
- res = chain_dict[chain][resi]
 
 
 
287
  el = (att_weight, f"{res.resname:3}{res.id[1]}")
288
  data.append(el)
289
 
 
283
  chain_dict = {f"{chain.id}": chain for chain in list(structure.get_chains())}
284
  data = []
285
  for att_weight, _, chain, resi in top_residues:
286
+ try:
287
+ res = chain_dict[chain][resi]
288
+ except KeyError:
289
+ continue
290
  el = (att_weight, f"{res.resname:3}{res.id[1]}")
291
  data.append(el)
292