Skip to content

feat(operations): link_protein_sequences links each protein to its photo's sequence - #1303

Merged
github-actions[bot] merged 1 commit into
developfrom
feat/link-protein-sequences-from-photos
Nov 24, 2026
Merged

github-actions[bot] merged 1 commit into
developfrom
feat/link-protein-sequences-from-photos

Conversation

@frapercan

Copy link
Copy Markdown
Owner

The gap

protein.sequence_id is empty for every protein in the store now serving the public site, and in dev too: 0 of 2,758,480. The instrument joins proteins to embeddings through that column, so it reports with_embeddings: 0 while the eight banks hold 20,191,896 vectors, and a protein page shows no sequence. The operation meant to fill it, resolve_protein_sequences, asks today's UniProt for every accession and had never run in either store.

The change

The author chose the photos over UniProt (2026-11-24). Every photo records each member's sequence at its cut by md5 (cut_photo_member.sequence_md5), and the embedding banks were built from exactly those sequences. link_protein_sequences:

  • sets protein.sequence_id for every protein that has none to the sequence recorded by the latest cut that records one for it, so a protein whose sequence changed between cuts takes the latest;
  • asks nothing of the network; the population is read when the job runs, and a protein already linked, by this operation or by resolve_protein_sequences, is left alone;
  • with dry_run, counts what it would link and writes nothing;
  • reports unlinked_before, linked and unlinked_after.

It is registered as a derived job on protea.jobs, and documented in the core reference and the operations page. It is also listed in the spec gate (71 operations), the payload negative matrix and the autodoc whitelist.

Checked against dev's data

The operation's own count query, run read-only on dev: 2,758,264 of the 2,758,480 proteins would be linked, and 216 have no sequence in any photo. Every one of the 2,523,987 distinct member md5 values is in sequence, and sequence.sequence_hash is the md5 of the sequence (2,000 of 2,000 sampled).

Tests

  • tests/test_link_protein_sequences.py: it links and reports what is left; a dry run counts and writes nothing; the statement takes the latest cut and only fills gaps.
  • tests/test_every_operation_declares_its_spec.py and tests/test_payload_validation.py pass with the new operation.
  • lint-gates.sh is green, and check_autodoc_coverage.py covers 59 of 59 patterns.

After merging

The plan is to run it on dev first and then on the public store through the desktop workers, comparing the two results as with every other step.

…oto's sequence

protein.sequence_id was empty for every protein in the clean store and in
dev (0 of 2,758,480), so the instrument counted no embeddings while the
eight banks held 20,191,896 vectors. The operation that fills it,
resolve_protein_sequences, asks today's UniProt and had never run.

The author chose the photos (2026-11-24). Every photo keeps each member's
sequence at its cut by md5, and the banks were built from exactly those
sequences. link_protein_sequences sets each unlinked protein's sequence_id
to the sequence of the latest cut that records one, with no network call.
The population is read when the job runs, a protein already linked is
left alone, and a dry run counts without writing.

Registered as a derived job on protea.jobs, documented in the reference
and the operations page, and listed in the spec, payload and autodoc gates.
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.65%. Comparing base (7edfb68) to head (ec791bc).
⚠️ Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
protea/core/operations/link_protein_sequences.py 96.96% 1 Missing ⚠️

❌ Your project check has failed because the head coverage (83.92%) is below the target coverage (85.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1303      +/-   ##
===========================================
- Coverage    85.69%   85.65%   -0.04%     
===========================================
  Files          471      472       +1     
  Lines        37374    37442      +68     
===========================================
+ Hits         32026    32070      +44     
- Misses        5348     5372      +24     
Files with missing lines Coverage Δ
protea/core/operation_catalog.py 100.00% <100.00%> (ø)
protea/core/operations/link_protein_sequences.py 96.96% <96.96%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@frapercan
frapercan marked this pull request as ready for review November 24, 2026 16:57
@github-actions
github-actions Bot merged commit 2af5a0c into develop Nov 24, 2026
21 of 22 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 24, 2026
…rom its entry metadata (#1304)

## The gap

In the store now serving the public site, and in dev, `entry_name`,
`organism`, `taxonomy_id`, `length` and `reviewed` are NULL in `protein`
for all 2,758,480 proteins. No operation fills them there;
`resolve_protein_metadata` writes them to `protein_uniprot_metadata`. So
a protein page showed empty top-level fields next to a `metadata` object
holding the values, and `/proteins/stats` reported 0 reviewed proteins.

## The change

The author chose that the API read the metadata (2026-11-24).

- **Detail and listing:** each field is the protein's own, else its
canonical entry's metadata. An isoform takes the entry's name, organism
and review status, never its length.
- **The `reviewed` filter and the stats:** a protein counts as reviewed
when its own row or its entry's metadata says so. On dev's data this
counts 574,058 reviewed proteins, matching the 573,661 Swiss-Prot
entries of cut 227 within the gap between the two releases.
- **The search** also matches the entry's name and organism.
- **The listing** reads the metadata of its page in one query.
- `_matches` and `_metadata_of` keep `list_proteins` under the 60-line
smells limit.

A store that does fill the columns, as the previous one did, keeps
showing them, because the protein's own value wins.

## Tests

- `test_empty_core_fields_come_from_the_entry_metadata`: a protein with
every core field empty shows its entry's name, organism, taxon, length
and review status.
- Locally, `tests/test_proteins_router.py`,
`tests/test_proteins_stats_router.py` and
`tests/test_endpoint_gating_sweep.py` pass. `lint-gates.sh` is green.

## Not in this PR

The instrument's statistics sections in `proteins_stats.py` (the top
organisms and the length histogram) still read `protein.organism` and
`protein.length`. Once `link_protein_sequences` (#1303) has run, the
length can come from the linked sequence.
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