Skip to content

Write one chain ID per chain in summary confidences - #5

Merged
DimaMolod merged 1 commit into
mainfrom
fix/summary-chain-ids
Oct 7, 2026
Merged

DimaMolod merged 1 commit into
mainfrom
fix/summary-chain-ids

Conversation

@DimaMolod

Copy link
Copy Markdown
Contributor

Summary

chain_ids in summary confidences now has one ID per chain, in the order of the chain-level arrays (chain_ptm, chain_iptm, chain_pair_iptm, chain_pair_pae_min).

v3.0.4 added the field, documented as "[num_chains] Chain IDs in the same order as the chain-level ...". But it was built from token_chain_ids, one ID per token: a two-chain input gave five IDs next to two chain_ptm values. Upstream main still has this.

  • Order: the chain-level arrays are indexed by np.unique(asym_id), i.e. ascending asym ID, and featurisation numbers chains in order of each chain's first token. So token_chain_ids, deduplicated in order of first appearance, gives exactly that order (list(dict.fromkeys(...)), with a comment saying why).

Validation

  • New src/alphafold3/model/confidence_types_test.py (absltest; added to CI): AAABB→[A,B], BBBAA→[B,A], CCABBBB→[C,A,B].
    • It uses the model's own featurisation and chain-level functions, and checks lengths, that IDs line up with chain_ptm, and the JSON output.
    • It fails on the unfixed code, e.g. ['B','B','B','A','A'] != ['B','A'], and passes with the fix: 3/3 in the AF3 image on jax 0.10.2.
  • fused_triangle_test.py: 90/90 unchanged.

🤖 Generated with Claude Code

StructureConfidenceSummary.chain_ids is documented as [num_chains] chain
IDs in the same order as the chain-level arrays, but
from_inference_result filled it with the per-token chain IDs from
metadata['token_chain_ids'], so a two-chain prediction of five tokens
wrote five IDs next to two chain_ptm values. Upstream main has the same
code.

The chain-level arrays (chain_ptm, chain_iptm, chain_pair_iptm,
chain_pair_pae_min) are indexed by unique asym ID in ascending order,
and featurisation assigns asym IDs to chains in order of their first
token, so the per-token chain IDs deduplicated in order of first
occurrence follow exactly that order. A chain that comes first in the
input therefore comes first even when its ID does not sort first.

Add confidence_types_test.py, which assigns asym IDs with the
featurisation helper, computes the chain-level arrays with the functions
the model uses, and checks that chain_ids has one entry per chain and
labels each chain's pTM, for two and three chains, a chain order that is
not alphabetical and a single-token chain. It runs on CPU without model
parameters, so add it to CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DimaMolod
DimaMolod merged commit 9878598 into main Oct 7, 2026
1 check passed
DimaMolod added a commit to KosinskiLab/AlphaPulldown that referenced this pull request Oct 7, 2026
)

Summary confidences write one chain ID per chain (v3.0.4 wrote one per token).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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