|
33 | 33 | REQUIRED_INFERENCE_ANNOTATIONS, |
34 | 34 | ) |
35 | 35 | from rfd3.inference.legacy_input_parsing import ( |
| 36 | + _check_has_backbone_connections_to_nonstandard_residues, |
36 | 37 | create_atom_array_from_design_specification_legacy, |
37 | 38 | ) |
38 | 39 | from rfd3.inference.parsing import InputSelection |
@@ -1361,17 +1362,25 @@ def accumulate_components( |
1361 | 1362 | # ... Concatenate all components |
1362 | 1363 | atom_array_accum = struc.concatenate(atom_array_accum) |
1363 | 1364 | 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 | + ) |
1373 | 1371 | ) |
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) |
1375 | 1384 |
|
1376 | 1385 | # Reset res_id for unindexed residues to avoid duplicates (ridiculously long lines of code, cleanup later) |
1377 | 1386 | if np.any(atom_array_accum.is_motif_atom_unindexed.astype(bool)) and not np.all( |
|
0 commit comments