Skip to content

fix: keep AF2 chain IDs at A, B, C under padding and out-of-order asym_id - #641

Merged
DimaMolod merged 1 commit into
mainfrom
fix/af2-chain-index-padding-and-order
Sep 8, 2026
Merged

DimaMolod merged 1 commit into
mainfrom
fix/af2-chain-index-padding-and-order

Conversation

@DimaMolod

Copy link
Copy Markdown
Collaborator

Two chain-labelling bugs in _normalize_asym_id, both in the AF2 asym_idProtein.chain_index handoff that feeds protein.to_pdb.

Ranking used the wrong permutation. appearance_order[inverse_indices] applies the first-appearance ordering instead of its inverse. Three or more chains whose asym_id are not already in first-appearance order come out shuffled — 3,1,2 produced B, C, A.

Batch padding outranked the real chains. pad_input_features zero-pads asym_id to the batch-wide residue bound, so --desired_num_res runs reach the remap as [1…1, 2…2, 0…0]. The padding then took rank 0 and a dimer came out labelled C and A. Trailing zeros are now treated as padding and ranked after every real chain; a leading zero still reads as a genuine 0-based encoding.

Verified against the real pad_input_features inside alphafold2_2.5.0.sif: a padded dimer goes from C/A to A/B.

Four regression tests in test/unit/test_alphafold2_backend_helpers.py. The two covering these bugs fail before the change; the other two pin behaviour that already worked — stability across the five models that share one feature dict in multimer mode, and 0-based encodings. test/unit is 500 passed, 11 skipped (test_diagnostics.py fails to collect on main too, missing af2plots).

🤖 Generated with Claude Code

…m_id

_normalize_asym_id ranked chains by the wrong permutation, so three or more
chains whose asym_id are not already in first-appearance order got shuffled.
Batch padding hit the same path: pad_input_features zero-pads asym_id, and the
padding then outranked the real chains, labelling a dimer C and A.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@DimaMolod
DimaMolod merged commit 7a9b665 into main Sep 8, 2026
6 checks passed
@DimaMolod
DimaMolod deleted the fix/af2-chain-index-padding-and-order branch September 8, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant