Skip to content

feat(eval): make the sink reachable from cafa_eval, not only from the kernels - #24

Merged
frapercan merged 1 commit into
mainfrom
feat/sink-reachable-from-cafa-eval
Aug 19, 2026
Merged

frapercan merged 1 commit into
mainfrom
feat/sink-reachable-from-cafa-eval

Conversation

@frapercan

Copy link
Copy Markdown
Owner

Follow-up to #23, which stopped one level short.

What was wrong

#23 wired PerProteinSink into the two sparse kernels and compute_metrics.
Nobody calls those. The consuming project calls cafa_eval:

cafa_eval -> evaluate_prediction -> compute_metrics -> kernel

So the feature existed and could not be reached from the only entry point that
uses this library. That is worse than not shipping it, because from outside it
reads as done.

I caught it while wiring the consumer, at the exact moment of writing the call
that would have silently collected nothing.

What this adds

per_protein_sink on evaluate_prediction and cafa_eval, and a namespace and
variant tag on every record.

The tags are not cosmetic. evaluate_prediction calls compute_metrics twice
per namespace, once unweighted and once weighted, so a full run hands the sink
six records. Untagged, a caller cannot tell the weighted BPO arrays from the
unweighted CCO ones, and the weighted variant is the one carrying
f_micro_w. An untagged record cannot serve the purpose the sink exists for.

Unchanged

Every default is still None. With no sink passed, no signature, no return type
and no number this library produces is different, and the existing tests still
assert exactly that.

Tests

Three added: that both public entry points expose the parameter, that a record
reports its namespace and variant, and that the context defaults to None rather
than to a guess.

pytest tests -q: 25 passed, 6 xfailed. ruff and mypy clean.

… kernels

#23 wired PerProteinSink into the two sparse kernels and compute_metrics
and stopped there. Consumers do not call those. PROTEA calls cafa_eval,
which calls evaluate_prediction, which calls compute_metrics, which calls
a kernel. So the feature existed and could not be used from the only
entry point that matters, which is worse than not existing because it
reads as done.

Threads per_protein_sink through evaluate_prediction and cafa_eval, and
tags each record with its namespace and variant. Without those a caller
holding six records cannot tell the weighted BPO arrays from the
unweighted CCO ones, and the weighted variant is the one carrying the
headline metric, so an untagged record cannot serve the purpose the sink
exists for.

Defaults stay None everywhere: with no sink passed nothing in this
library behaves differently, and the tests still assert it.
@frapercan
frapercan merged commit dd586b4 into main Aug 19, 2026
6 checks passed
@frapercan
frapercan deleted the feat/sink-reachable-from-cafa-eval branch August 19, 2026 08:16
frapercan added a commit that referenced this pull request Aug 19, 2026
Third and final piece of the per-protein sink. #23 emitted the arrays,
#24 made
them reachable from `cafa_eval`, and this makes them **usable**.

## The gap

The arrays were anonymous, indexed by an opaque row number. Every axis
the sink
exists to support is keyed by protein:

- sequence length
- identity to the nearest donor
- taxonomic relation to the nearest donor

None can be joined to a row number, so the feature as shipped could not
do the
one thing it was built for. I found this while writing the consumer, at
the point
of asking which protein row 0 was.

## Two numberings, which is why this is not one line

The NK/LK kernel receives every row, so array row `i` is matrix row `i`.
The PK
kernel can be handed a subset:

```python
pred_sub = pred[proteins_has_gt, :]
```

after which the array numbering and the `ids` numbering disagree.
`compute_metrics`
is what performs that subsetting, so it is what records the mapping,
rather than
leaving each caller to reconstruct it from state it does not have.

Getting this wrong would attribute one protein's score to another. That
is
exactly the failure the consuming project spent a week correcting in its
neighbour search, where a positional misalignment produced plausible
numbers for
a fortnight. So there is a test asserting `row_index` has one entry per
array
row, rather than a comment saying it should.

## Also

Identity is `None` when not supplied rather than guessed, and the id map
is
copied rather than aliased, with tests for both.

`pytest tests -q`: 29 passed, 6 xfailed. `ruff` and `mypy` clean.
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