From b4eb674c1ba1332daf954c35644902015d1aac2d Mon Sep 17 00:00:00 2001 From: Thomas Hopf Date: Wed, 24 Jan 2024 16:45:28 +0100 Subject: [PATCH] Fix PDB chain retrieval regression by pandas/numpy updates --- evcouplings/compare/pdb.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/evcouplings/compare/pdb.py b/evcouplings/compare/pdb.py index e16aaf1..3bbb6ce 100644 --- a/evcouplings/compare/pdb.py +++ b/evcouplings/compare/pdb.py @@ -585,12 +585,10 @@ def get_chain(self, chain, model=0): ) # collect internal indeces of all residues/groups in chain - residue_indeces = np.concatenate( - np.array([ - np.arange(self.first_residue_index[i], self.last_residue_index[i]) - for i in target_chain_indeces - ], dtype=np.object_) - ) + residue_indeces = np.concatenate([ + np.arange(self.first_residue_index[i], self.last_residue_index[i]) + for i in target_chain_indeces + ]) # chain indeces and identifiers for all residues # (not to be confused with chain name!); @@ -619,7 +617,11 @@ def get_chain(self, chain, model=0): ("sec_struct", self.sec_struct[residue_indeces]), ]) - res_df = pd.DataFrame(res) + # also store entity IDs and indices + res_df = pd.DataFrame(res).assign( + entity_index=lambda df: df.chain_index.map(self.chain_to_entity), + entity_id=lambda df: df.entity_index + 1 + ) # shift seqres indexing to start at 1; # However, do not add to positions without sequence index (-1)