fix: keep AF2 chain IDs at A, B, C under padding and out-of-order asym_id - #641
Merged
Merged
Conversation
…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>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two chain-labelling bugs in
_normalize_asym_id, both in the AF2asym_id→Protein.chain_indexhandoff that feedsprotein.to_pdb.Ranking used the wrong permutation.
appearance_order[inverse_indices]applies the first-appearance ordering instead of its inverse. Three or more chains whoseasym_idare not already in first-appearance order come out shuffled —3,1,2producedB, C, A.Batch padding outranked the real chains.
pad_input_featureszero-padsasym_idto the batch-wide residue bound, so--desired_num_resruns reach the remap as[1…1, 2…2, 0…0]. The padding then took rank 0 and a dimer came out labelledCandA. 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_featuresinsidealphafold2_2.5.0.sif: a padded dimer goes fromC/AtoA/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/unitis 500 passed, 11 skipped (test_diagnostics.pyfails to collect on main too, missingaf2plots).🤖 Generated with Claude Code