Skip to content

Commit

Permalink
Fix PDB chain retrieval regression by pandas/numpy updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashopf committed Jan 24, 2024
1 parent 5b3b3f0 commit b4eb674
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions evcouplings/compare/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b4eb674

Please sign in to comment.