File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
6669def _find_low_occ_records (pdb : list [str ]) -> list [int ]:
@@ -111,9 +114,8 @@ def pdb_prep(fhandle: TextIO) -> None:
111114 # step 1 - keep coordinates: removes non coordinate lines for simplicity
112115 # step 2 - delresname: remove waters
113116 # step 3 - rplresname: convert residue names to standard names, ex: MSE to MET
114- _new_pdb = _prune_records (fhandle )
115-
116117 # step 4 - selaltloc: select most probable alternative location
118+ _new_pdb = _prune_records (fhandle )
117119
118120 # step 5 - fixinsert: fix inserts
119121 # step 6 - sort: sort chains and resides, necessary for OpenMM
You can’t perform that action at this time.
0 commit comments