From 522903baabfc57985e9ed43f53907b2128e2c7d4 Mon Sep 17 00:00:00 2001 From: Thomas Hopf Date: Thu, 26 Sep 2024 17:27:28 +0200 Subject: [PATCH] ensure chain IDs are always str --- evcouplings/compare/pdb.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/evcouplings/compare/pdb.py b/evcouplings/compare/pdb.py index 4c41495..850a4be 100644 --- a/evcouplings/compare/pdb.py +++ b/evcouplings/compare/pdb.py @@ -498,7 +498,12 @@ def __init__(self, filehandle, keep_full_data=False): # decode information into dataframe with BioPython helper method self.atom_table = pd.DataFrame({ name: _decode(data[source_column]) for source_column, name in ATOM_TARGET_COLS.items() - }) + }).assign( + # make sure chain identifiers are strings, in some pathologic cases, these are int rather than str + # (e.g. entry 6swy) + auth_asym_id=lambda df: df.auth_asym_id.astype(str), + label_asym_id=lambda df: df.label_asym_id.astype(str), + ) # decode information into dataframe with BioPython helper method; note this section may not be # present if no helices exist in the structure