Skip to content

Commit 01d92a9

Browse files
Use legacy res_id offset when allow_ligand_on_existing_chain is True
The override path now matches the old behaviour (offset from protein max res_id). The default path (separate chains) sets each ligand chain's res_id to 1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9d4ea2c commit 01d92a9

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

models/rfd3/src/rfd3/inference/input_parsing.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,20 @@ def _append_ligand(self, atom_array, atom_array_input_annotated):
697697
f"ligand must be on its own chain, or set "
698698
f"'allow_ligand_on_existing_chain: true' to override."
699699
)
700-
# Reset ligand res_id to start from 1 per chain. When ligands
701-
# share a chain (override mode), preserve relative gaps.
702-
for chain in ligand_chains:
703-
mask = ligand_array.chain_id == chain
704-
chain_res_ids = ligand_array.res_id[mask]
705-
ligand_array.res_id[mask] = chain_res_ids - np.min(chain_res_ids) + 1
700+
if self.allow_ligand_on_existing_chain:
701+
# Legacy behaviour: offset from protein max to avoid clashes.
702+
ligand_array.res_id = (
703+
ligand_array.res_id
704+
- np.min(ligand_array.res_id)
705+
+ np.max(atom_array.res_id)
706+
+ 1
707+
)
708+
else:
709+
# Reset ligand res_id to start from 1 per chain, matching
710+
# the convention AF3 uses in its output CIF files.
711+
for chain in ligand_chains:
712+
mask = ligand_array.chain_id == chain
713+
ligand_array.res_id[mask] = 1
706714
# Harmonize conditioning annotations before concatenation: biotite's
707715
# concatenate only preserves annotations present in ALL arrays (set
708716
# intersection), so mismatched optional conditioning annotations

0 commit comments

Comments
 (0)