Skip to content

Fix UniProt TrEMBL parsing, fetcher error chaining and id_mapping - #102

Merged
haeussma merged 2 commits into
mainfrom
fix/uniprot-trembl-and-id-mapping
Oct 9, 2026
Merged

haeussma merged 2 commits into
mainfrom
fix/uniprot-trembl-and-id-mapping

Conversation

@haeussma

@haeussma haeussma commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

UniProt fetcher

  • fetch_uniprot("Q7DDU0") failed with recommendedName Field required: unreviewed (TrEMBL) entries only have submissionNames. The name, ID and EC number now fall back to the first submission name. The Optional model fields had no default, so Pydantic v2 still required them; they now default to None.
  • A 4xx response (unknown ID, isoform) is now a ValueError ("invalid or not found"), not a misleading ConnectionError. Inactive (deleted/merged) entries get a clear message instead of a parse error. Surrounding whitespace in the ID is stripped.

Composer

  • _fetch_with_fetchers chains the last fetcher exception (raise ... from), so the real cause shows up in the traceback.
  • id_mapping now also renames species_id in reaction reactants/products/modifiers. Before, compose(reactions=["RHEA:19273"], id_mapping={"CHEBI:63153": "ManNAc"}) produced a reaction referring to an undeclared species.
  • id_mapping keys match whole IDs, case-insensitively, instead of by substring: "CHEBI:1" used to rename water (CHEBI:15377). "CHEBI:63153", "chebi:63153", "63153" and "OBO:CHEBI_63153" all work.
  • A mapping that gives two species the same ID now raises a ValueError instead of producing duplicate IDs.

Behaviour change: a mapping key that only matched as a substring of an ID no longer matches.

Tests

  • Offline unit tests (stubbed HTTP/fetchers) in tests/unit/test_uniprot.py and tests/unit/test_composer.py; each fails against the previous code.
  • Remote tests for Q7DDU0 and the RHEA:19273 mapping in tests/integration/.
  • Unit suite and -m remote fetcher/composer tests pass locally.

🤖 Generated with Claude Code


This change is Reviewable

- fetch_uniprot: parse unreviewed (TrEMBL) entries that only carry
  submissionNames; fall back to the first submission name for name, id
  and EC number. Optional model fields now have real defaults.
- fetch_uniprot: report 4xx responses as ValueError (invalid/unknown ID)
  instead of ConnectionError, give a clear message for inactive
  (deleted/merged) entries, and strip surrounding whitespace.
- compose: chain the last fetcher exception so the real cause shows up
  in the traceback.
- compose: id_mapping now also updates species_id in reaction
  reactants/products/modifiers, so mapped reactions no longer refer to
  undeclared species.
- compose: id_mapping keys match whole IDs, case-insensitively
  ("CHEBI:1" no longer renames CHEBI:15377), and mappings that give two
  species the same ID raise a ValueError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
py-enzyme Ready Ready Preview Oct 9, 2026 12:38pm UTC

The lint workflow installed the latest ruff, which reports hundreds of
pre-existing issues across the codebase. Pin it to 0.15.22, the version
.pre-commit-config.yaml already uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@haeussma
haeussma merged commit e0d6b00 into main Oct 9, 2026
8 checks passed
@haeussma
haeussma deleted the fix/uniprot-trembl-and-id-mapping branch October 9, 2026 12:48

This branch was successfully deployed

1 active deployment
Preview — 6987f6f2 Deployed Oct 9, 2026 by vercel[bot]
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