Skip to content

Commit 7b7e881

Browse files
committed
Avoid duplicate residue numbers within same chain id
1 parent d45d369 commit 7b7e881

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

mmtbx/solvent/map_to_water.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ def attribute_water_to_chains(model):
148148
nonw = h.select(~wsel)
149149
nonwa = nonw.atoms()
150150
#
151+
# chain ID <> max residue number mapping
152+
can = {}
153+
for c in nonw.chains():
154+
last = list(c.residue_groups())[-1]
155+
can.setdefault(c.id, []).append(last.resseq_as_int())
156+
for k in can.keys():
157+
can[k] = max(can[k])
158+
#
151159
dic = {}
152160
for aw in wh.atoms():
153161
d_min = 1.e9
@@ -169,8 +177,9 @@ def attribute_water_to_chains(model):
169177
new_atom_group = iotbx.pdb.hierarchy.atom_group(altloc="",
170178
resname="HOH")
171179
new_atom_group.append_atom(atom=new_atom.detached_copy())
180+
i_seq_ = i_seq + 1 + can[chain_id]
172181
new_residue_group = iotbx.pdb.hierarchy.residue_group(
173-
resseq=iotbx.pdb.resseq_encode(value=i_seq), icode=" ")
182+
resseq=iotbx.pdb.resseq_encode(value=i_seq_), icode=" ")
174183
new_residue_group.append_atom_group(atom_group=new_atom_group)
175184
new_chain.append_residue_group(residue_group=new_residue_group)
176185
pdb_model.append_chain(chain=new_chain)

0 commit comments

Comments
 (0)