Skip to content

Commit ab0b696

Browse files
author
Dani Bodor
committed
use _find_low_occ_records to limit yield
1 parent 0ad1c9c commit ab0b696

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

deeprank2/tools/pdbprep/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ def _prune_records(fhandle: TextIO) -> Generator[str]:
5656
"HSD": "HIS",
5757
}
5858

59-
for record in fhandle:
59+
for i, record in enumerate(fhandle):
6060
resname = record[_RESNAME_COLS]
61-
if record.startswith(atomic_record) and resname != water:
61+
if record.startswith(atomic_record) and resname != water and i not in _find_low_occ_records(fhandle):
62+
# TODO: if within a single file mixed residue nomenclature is used, it is not detected by _find_low_occ_records
63+
# probably fix this by running these in separate functions rather than all at once.
6264
standardized_resname = standard_resnames.get(resname, resname)
63-
yield record[:17] + standardized_resname + record[20:]
65+
record = record[: _RESNAME_COLS.start] + standardized_resname + record[_RESNAME_COLS.stop :] # noqa: PLW2901
66+
yield record
6467

6568

6669
def _find_low_occ_records(pdb: list[str]) -> list[int]:

0 commit comments

Comments
 (0)