Skip to content

drugchemical: record dropped conflation pairs to a retained exclusion report (#754) - #874

Draft
gaurav wants to merge 3 commits into
mainfrom
issue-754
Draft

drugchemical: record dropped conflation pairs to a retained exclusion report (#754)#874
gaurav wants to merge 3 commits into
mainfrom
issue-754

Conversation

@gaurav

@gaurav gaurav commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

What this does

Makes DrugChemical conflation regressions diagnosable from retained build artifacts, motivated by
#754 (the Carbidopa clique fragmenting between the 2024oct24 and 2025sep1 runs).

Previously, every reason build_conflation() dropped a subject/object pair existed only as a
logger.warning on STDERR, which Snakemake discards once the rule succeeds. So a past run left no
trace of why a cross-reference was dropped, and (because 2024oct24 published no intermediate/
tree) there was no way to diff inputs after the fact.

Changes

  • ConflationExclusionRecorder (src/createcompendia/drugchemical.py) streams one row per
    dropped pair — source, reason, subject, object, subject_type, object_type, detail — to a gzipped
    TSV that is now a declared output of the drugchemical_conflation rule:
    babel_outputs/reports/drugchemical/excluded_pairs.tsv.gz. Lands under reports/, so it is
    published and retained every run. Diagnosing "why was CHEBI:3395 dropped?" becomes one zgrep.
  • Instrumented every drop site: the previously-silent RXNORM/UMLS else branch (the most
    likely place a bridge vanishes), all six PubChem-path filters, both manual-concord rejections, and
    the post-glom single-identifier collapse. A per-(source, reason) summary is logged and folded
    into metadata/DrugChemical.yaml under an Exclusions block.
  • Tests: offline unit tests for the recorder round-trip and the two manual-concord exclusion
    paths.
  • Docs: new docs/debugging/Conflation.md (full diagnosis procedure, including the deferred
    root-cause steps that depend on Export intermediate concords, identifiers, and metadata as Parquet files #704's intermediate Parquet export), cross-linked from
    docs/Conflation.md. Corrected the stars.renci.org guidance in CLAUDE.md to use
    /var/babel_outputs/ (full identifiers) for debugging, not /var/babel/ (shareable subset).

Scope / not in this PR

This is the "do-now" instrumentation only. The actual #754 root-cause fix is deferred until the
intermediate-concord Parquet export (#704) lands, so the new exclusion report can be diffed against
the raw upstream edges; the procedure is documented in docs/debugging/Conflation.md. Related TODOs
were filed on #704. Also noted there: a separate duplicate-CURIE write bug observed in the 2025sep1
output, and instrumenting build_rxnorm_relationships()'s concord-build-time drops.

Testing

uv run pytest tests/createcompendia/test_drugchemical.py -q (9 passed). ruff, snakefmt, and rumdl
all clean.

🤖 Generated with Claude Code

gaurav and others added 3 commits June 24, 2026 15:47
…tput

Every reason build_conflation() dropped a subject/object pair previously
existed only as a logger.warning on STDERR, which Snakemake discards once the
rule succeeds. That made regressions like #754 (the Carbidopa clique
fragmenting between runs) impossible to diagnose after the fact.

Add ConflationExclusionRecorder, which streams one row per dropped pair
(source, reason, subject, object, subject_type, object_type, detail) to a
gzipped TSV that is now a declared output of the drugchemical_conflation rule:
reports/drugchemical/excluded_pairs.tsv.gz. Because it lands under reports/ it
is published and retained every run, so "why was CHEBI:3395 dropped?" becomes a
single zgrep against a past run.

Instrument every drop site: the previously-silent RXNORM/UMLS else branch (the
most likely place a bridge vanishes), all six PubChem-path filters, both
manual-concord rejections, and the post-glom single-identifier collapse. A
per-(source, reason) summary is logged and folded into metadata/DrugChemical.yaml.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add offline unit tests covering the recorder round-trip (header, one row per
dropped pair, per-(source, reason) counts) and the two manual-concord exclusion
paths (CURIE not in any compendium, and self-pair after normalization).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Document how to investigate "these identifiers used to be conflated and now
aren't" regressions, using #754 (Carbidopa) as the worked example: the
confirmed 2024oct24 -> 2025sep1 regression, where conflation drops pairs, the
new excluded_pairs.tsv.gz report, the deferred root-cause procedure (pending the
PR #704 intermediate-concord Parquet export), and local-repro instructions.
Cross-link from docs/Conflation.md.

Also correct the stars.renci.org guidance in CLAUDE.md: use /var/babel_outputs/
(full identifiers; versions 2024oct24 and 2025sep1) for debugging, not
/var/babel/ (externally-shareable subset only).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant