Skip to content

Support Chothia Martin and Aho - #51

Open
ThijsMaas wants to merge 14 commits into
mainfrom
add-schemes-chothia-martin-aho
Open

Support Chothia Martin and Aho#51
ThijsMaas wants to merge 14 commits into
mainfrom
add-schemes-chothia-martin-aho

Conversation

@ThijsMaas

@ThijsMaas ThijsMaas commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Extends the numbering beyond IMGT and Kabat to support the Chothia, Martin, and AHo antibody numbering schemes for heavy (H), kappa (K), and lambda (L) chains.

Each new scheme is exercised by validation fixtures for heavy (H), kappa (K), and lambda (L) chains (fixtures/validation/), and wired through the Rust core, Python bindings, Polars, and WASM interfaces. Benchmark results and correctness plots are updated accordingly, and unwanted alignment positions are now dropped from the consensus output.

New consensus fixtures (fixtures/validation/ab_{H,K,L}_{chothia,martin,aho}.csv) drive per-scheme, per-chain tests in src/validation.rs, asserting both perfect-sequence rate and per-position accuracy thresholds (≥99%). A few documented edge cases where a count-based rule cannot disambiguate equal-length regions gapped differently (Chothia lambda, AHo kappa FR3) have their perfect-sequence threshold relaxed to 98% while per-position accuracy stays ≥99%.

@ThijsMaas
ThijsMaas requested a review from rickbeeloo July 20, 2026 05:02
@ThijsMaas
ThijsMaas marked this pull request as ready for review July 24, 2026 18:52

@rickbeeloo rickbeeloo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to verify the rules themselves except from just validating against ANARCHI.

I did notice, looking at the validation that for Aho there are a few where the CDR3 gets suffix clipped causing discrepancy with ANARCHI. Would it make sense to actually just force clipping to only happen after FR4 start, or maybe even FR4 end. Now it seems that if CDR3 is quite different it will clip part of the CDR3 end (and FR4) off.

Instead maybe like:

const FR4_NEAR_END_MARGIN: u8 = 3;
    let last_consensus_position = positions[cons_len - 1].position;
    let fr4_near_end = last_consensus_position.saturating_sub(FR4_NEAR_END_MARGIN);
    let mut best_i = query_len;
    let mut best_j = row_best_j[query_len];
    for i in 1..query_len {
        let finished_fr4 =
            row_best_j[i] > 0 && positions[row_best_j[i] - 1].position >= fr4_near_end;
        if finished_fr4
            && row_max_score[i] > row_max_score[query_len] + SUFFIX_CLIP_THRESHOLD
            && row_max_score[i] > row_max_score[best_i]
        {
            best_i = i;
            best_j = row_best_j[i];
        }
    }

Seems to improve the Aho results, but 3 does feel a bit random, maybe it can just be the end instead.

Comment thread src/numbering/aho.rs

/// AHo kappa chain numbering rules (VK CDR1 deletion order: two-residue gap at 27/28).
///
/// Kappa FR1 is a true 1:1 map (no gap at AHo 8), so it uses `fr` rather than the indel-on-8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Do you know why this actually happens? Looking at scheme.py from ANARCI it seems they assume it is there for kappa but it only triggers when the FR1 length is >10?

Edit: aah it's actually the opposite. It was added so Kappa could "insert" at 8 (rather than the others delete; but insertions/deletions are relative, of course):

Some of the gaps introduced by the Honegger numbering scheme serve to accommodate the length variations observed in variable domains across different proteins within the immunoglobulin superfamily. For example, the ∆8 gap is specifically designed to account for the one-amino acid insertion in VL kappa.

https://academic.oup.com/peds/article/doi/10.1093/protein/gzaf005/8102903

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just link the paper in the comment here?

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.

2 participants