DRAFT: CHEBI-route related_ingredients suggester (issue #30, pending MIM#119)#215
Closed
realmarcin wants to merge 1 commit into
Closed
DRAFT: CHEBI-route related_ingredients suggester (issue #30, pending MIM#119)#215realmarcin wants to merge 1 commit into
realmarcin wants to merge 1 commit into
Conversation
…MIM#119) The ingredient analog of the media suggester, ready to finalize once MIM confirms the CHEBI route (MediaIngredientMech#119 ask c). For each community, matches environment_term against MIM environmental_context and emits RelatedIngredient blocks via the ingredient's CHEBI term — no MediaIngredientMech:NNNNNN id needed. - cross_repo_environment.py: IngredientHit + mim_ingredients_by_environment() (chebi_id set only when the MIM identifier is a CHEBI CURIE); get_chebi_adapter() and a shared _cached_oak_adapter() helper. - scripts/suggest_related_ingredients.py + `just suggest-related-ingredients`: emits chebi_term + shared_environment_term (+ preferred_term); resolves the CANONICAL ChEBI label (not MIM's free-text name) so the id-label gate stays green; skips/reports records with an unresolvable label; supports --subsumption; skips already-linked CHEBI ids and generic environments. Suggestion-only. Prints a DRAFT banner. - tests/test_suggest_related_ingredients.py + a mim_ingredients_by_environment case. Verified an emitted block LinkML-validates in a real record (Sulfur CHEBI:26833 for a hot-spring mat community, keyed on ENVO:00000051). Current yield is tiny (~3 CHEBI-identified MIM env ingredients today); scales as MIM populates environmental_context. Held as a DRAFT PR — do not merge until MIM#119 confirms the CHEBI route. 229 tests pass; lint clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
realmarcin
force-pushed
the
feat/draft-ingredient-suggester
branch
from
July 19, 2026 23:26
046a482 to
5eda920
Compare
This was referenced Jul 20, 2026
realmarcin
added a commit
that referenced
this pull request
Jul 20, 2026
MIM#119 (now closed as answered) settled the two blockers: MediaIngredientMech:NNNNNN is vestigial (drop it), and the equivalence-safe join is the ingredient's CHEBI term from MIM's SSSOM skos:exactMatch rows — NOT the record identifier field, NOT close/narrowMatch (which would generalise). Coverage is 10 environmental_context records, not ~44. Rebuilt the suggester (supersedes draft PR #215) on that basis: - cross_repo_environment.py: mim_exactmatch_chebi() parses the SSSOM (skipping the # preamble; keeps only skos:exactMatch → CHEBI:); mim_ingredients_by_environment() joins each environmental_context record (MIM:<file-stem> subject) to it and scans data/ingredients/ (not the repo root — MIM keeps multi-MB aggregate dumps under data/curated/ that would blow up YAML parsing). + get_chebi_adapter/_cached_oak_adapter. - scripts/suggest_related_ingredients.py + `just suggest-related-ingredients`: emits RelatedIngredient with chebi_term (CANONICAL ChEBI label, not MIM's free-text name, so the id-label gate stays green) + shared_environment_term; env keys are environment_term + modeled_environment; --subsumption supported; skips already-linked CHEBI ids, generic envs, and unresolved labels (reported). Not a draft. - tests: SSSOM join (exactMatch/narrowMatch/non-CHEBI filtering) + suggester helpers. Verified: real run emits Sulfur (CHEBI:26833, "sulfur atom") for the hot-spring mat community (exact ENVO:00000051 match); block LinkML-validates. Yield is 1 today — data-limited by MIM's 10 context records, correct and scales. 254 tests pass; lint clean. Follow-up (NEXT_TASKS): drop the vestigial ^MediaIngredientMech:\d{6}$ pattern from RelatedIngredient.mediaingredientmech_id. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Superseded by #220, which rebuilds the ingredient suggester on MIM#119's resolution (CHEBI route via SSSOM skos:exactMatch, not the record identifier field). Closing this draft. |
realmarcin
added a commit
that referenced
this pull request
Jul 20, 2026
…#220) MIM#119 (now closed as answered) settled the two blockers: MediaIngredientMech:NNNNNN is vestigial (drop it), and the equivalence-safe join is the ingredient's CHEBI term from MIM's SSSOM skos:exactMatch rows — NOT the record identifier field, NOT close/narrowMatch (which would generalise). Coverage is 10 environmental_context records, not ~44. Rebuilt the suggester (supersedes draft PR #215) on that basis: - cross_repo_environment.py: mim_exactmatch_chebi() parses the SSSOM (skipping the # preamble; keeps only skos:exactMatch → CHEBI:); mim_ingredients_by_environment() joins each environmental_context record (MIM:<file-stem> subject) to it and scans data/ingredients/ (not the repo root — MIM keeps multi-MB aggregate dumps under data/curated/ that would blow up YAML parsing). + get_chebi_adapter/_cached_oak_adapter. - scripts/suggest_related_ingredients.py + `just suggest-related-ingredients`: emits RelatedIngredient with chebi_term (CANONICAL ChEBI label, not MIM's free-text name, so the id-label gate stays green) + shared_environment_term; env keys are environment_term + modeled_environment; --subsumption supported; skips already-linked CHEBI ids, generic envs, and unresolved labels (reported). Not a draft. - tests: SSSOM join (exactMatch/narrowMatch/non-CHEBI filtering) + suggester helpers. Verified: real run emits Sulfur (CHEBI:26833, "sulfur atom") for the hot-spring mat community (exact ENVO:00000051 match); block LinkML-validates. Yield is 1 today — data-limited by MIM's 10 context records, correct and scales. 254 tests pass; lint clean. Follow-up (NEXT_TASKS): drop the vestigial ^MediaIngredientMech:\d{6}$ pattern from RelatedIngredient.mediaingredientmech_id. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The ingredient analog of the media suggester (#211), built now so it lands the
moment MIM confirms. It links via the ingredient's CHEBI term
(
RelatedIngredient.chebi_term) — the "CHEBI route" — which needs noMediaIngredientMech:NNNNNNid (the schema pattern MIM doesn't use; see MIM#119).What
cross_repo_environment.py:IngredientHit+mim_ingredients_by_environment()(byte-prefiltered;
chebi_idset only when the MIMidentifieris a CHEBI CURIE),plus
get_chebi_adapter()and a shared_cached_oak_adapter()helper.scripts/suggest_related_ingredients.py+just suggest-related-ingredients:for each community, matches
environment_termagainst MIMenvironmental_contextand emits
related_ingredientsblocks:chebi_termwith the canonical ChEBI label (resolved from the local ChEBIsqlite — not MIM's free-text name) so the id↔label gate stays green;
shared_environment_term(the ENVO join key);canonical label can't be resolved (reported, not silently dropped);
--subsumptionsupported; suggestion-only, prints a DRAFT banner.test_suggest_related_ingredients.py+ amim_ingredients_by_environmentcase (fake OAK adapters, offline).
Verified
An emitted block LinkML-validates in a real record — Sulfur (CHEBI:26833, label
"sulfur atom") for a hot-spring phototrophic mat community, keyed on shared
ENVO:00000051.
Honest yield
~3 CHEBI-identified MIM env-context ingredients today, so immediate output is tiny.
The tool scales as MIM populates
environmental_context(the field it committed toin MIM#1). This PR is about having the capability ready, not bulk output.
Before finalizing
CHEBI:id is an acceptablecross-repo link. If yes → mark ready, merge. If MIM prefers
MIM:<name>→ add amim_idfield and emit that instead (small change).Verification
just test— 229 passed (+6)just lint— black + ruff + mypy clean🤖 Generated with Claude Code