Skip to content

Commit 64eff9d

Browse files
Gate bond restoration behind nonstandard-residue check
Only run _restore_component_bonds, _add_backbone_bonds_for_nonstandard_residues, and _sort_bonds when the source structure actually has backbone connections to nonstandard residues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3824771 commit 64eff9d

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
REQUIRED_INFERENCE_ANNOTATIONS,
3434
)
3535
from rfd3.inference.legacy_input_parsing import (
36+
_check_has_backbone_connections_to_nonstandard_residues,
3637
create_atom_array_from_design_specification_legacy,
3738
)
3839
from rfd3.inference.parsing import InputSelection
@@ -1361,17 +1362,25 @@ def accumulate_components(
13611362
# ... Concatenate all components
13621363
atom_array_accum = struc.concatenate(atom_array_accum)
13631364
atom_array_accum.set_annotation("pn_unit_iid", atom_array_accum.chain_id)
1364-
atom_array_accum = _restore_component_bonds(
1365-
atom_array_accum=atom_array_accum,
1366-
src_atom_array=src_atom_array,
1367-
source_to_accum_idx=source_to_accum_idx,
1368-
source_idx_to_component=source_idx_to_component,
1369-
unindexed_components=unindexed_component_names,
1370-
)
1371-
atom_array_accum = _add_backbone_bonds_for_nonstandard_residues(
1372-
atom_array_accum=atom_array_accum
1365+
should_restore_bonds = (
1366+
src_atom_array is not None
1367+
and bool(source_to_accum_idx)
1368+
and _check_has_backbone_connections_to_nonstandard_residues(
1369+
atom_array_accum, src_atom_array
1370+
)
13731371
)
1374-
atom_array_accum = _sort_bonds(atom_array_accum)
1372+
if should_restore_bonds:
1373+
atom_array_accum = _restore_component_bonds(
1374+
atom_array_accum=atom_array_accum,
1375+
src_atom_array=src_atom_array,
1376+
source_to_accum_idx=source_to_accum_idx,
1377+
source_idx_to_component=source_idx_to_component,
1378+
unindexed_components=unindexed_component_names,
1379+
)
1380+
atom_array_accum = _add_backbone_bonds_for_nonstandard_residues(
1381+
atom_array_accum=atom_array_accum
1382+
)
1383+
atom_array_accum = _sort_bonds(atom_array_accum)
13751384

13761385
# Reset res_id for unindexed residues to avoid duplicates (ridiculously long lines of code, cleanup later)
13771386
if np.any(atom_array_accum.is_motif_atom_unindexed.astype(bool)) and not np.all(

0 commit comments

Comments
 (0)