Skip to content

Commit 5cf868e

Browse files
a-r-jchemonke
authored andcommitted
fix failing tests
1 parent bd6e39d commit 5cf868e

4 files changed

Lines changed: 18 additions & 3 deletions

File tree

biopandas/mmcif/pandas_mmcif.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,11 @@ def amino3to1(
430430
indices = []
431431

432432
residue_number_insertion = (
433-
tmp[residue_number_col].astype(str) + tmp["pdbx_PDB_ins_code"]
433+
tmp[chain_col].astype(str)
434+
+ "_"
435+
+ tmp[residue_number_col].astype(str)
436+
+ "_"
437+
+ tmp["pdbx_PDB_ins_code"].fillna("")
434438
)
435439

436440
for num, ind in zip(residue_number_insertion, np.arange(tmp.shape[0])):

biopandas/mmtf/pandas_mmtf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ def amino3to1(self, record="ATOM", residue_col="residue_name", fillna="?"):
236236
indices = []
237237

238238
residue_number_insertion = (
239-
tmp["residue_number"].astype(str) + tmp["insertion"]
239+
tmp["chain_id"].astype(str)
240+
+ "_"
241+
+ tmp["residue_number"].astype(str)
242+
+ "_"
243+
+ tmp["insertion"].fillna("")
240244
)
241245

242246
for num, ind in zip(residue_number_insertion, np.arange(tmp.shape[0])):

biopandas/pdb/pandas_pdb.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,13 @@ def amino3to1(self, record="ATOM", residue_col="residue_name", fillna="?"):
606606
cmp = "placeholder"
607607
indices = []
608608

609-
residue_number_insertion = tmp["residue_number"].astype(str) + tmp["insertion"]
609+
residue_number_insertion = (
610+
tmp["chain_id"].astype(str)
611+
+ "_"
612+
+ tmp["residue_number"].astype(str)
613+
+ "_"
614+
+ tmp["insertion"].fillna("")
615+
)
610616

611617
for num, ind in zip(residue_number_insertion, np.arange(tmp.shape[0])):
612618
if num != cmp:

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Release Notes ![](img/logos/3eiy_120.png)
22

3+
- Fix: improves robustness of `amino3to1` residue identification by handling `NaN` insertion codes (NumPy 2.4+ compatibility) and including chain IDs and separators to avoid collisions.
34
- Supports `mol` files that have empty lines between blocks, (Via [Ruibin Liu](https://github.com/Ruibin-Liu) PR #[140](https://github.com/BioPandas/biopandas/pull/140#))
45

56
The CHANGELOG for the current development version is available at

0 commit comments

Comments
 (0)