Skip to content

Add declarative multi-segment read grammar and decode_segments MCP tool - #190

Open
dnncha wants to merge 2 commits into
mainfrom
feat/multi-segment-grammar
Open

dnncha wants to merge 2 commits into
mainfrom
feat/multi-segment-grammar

Conversation

@dnncha

@dnncha dnncha commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Why

Perturb-seq (Cell Barcode + UMI + Guide), Pharma DNA-Encoded Chemical Libraries (DEL multi-tag + UMI), and dual-guide screens encode multiple structured short-DNA segments per read or R1/R2 pair. Today DotMatch assigns only a single fixed window per read, forcing downstream users into custom scripts that silently collapse UMI-to-target conflicts.

What changed

  • Added python/dotmatch/segments.py with typed domain models (SegmentSpec, ReadGrammar, SegmentOutcomeSummary, DecodedSegmentsReport) and decode_segments(...).
    • Supports single-end R1 and paired-end R1/R2 fixed-window grammars using the native C Matcher per target segment.
    • Preserves explicit four-way outcomes (unique, ambiguous, none, invalid) per segment and jointly across the read.
    • Supports explicit UMI scoping (for example scope=("cell",) for Perturb-seq or global scope=() for DELs) and excludes conflicted UMIs from unique_molecules while logging them in umi_conflicts.tsv.
    • Writes deterministic segment_counts.tsv, umi_conflicts.tsv, and segments_summary.json into a fresh directory without overwriting existing outputs.
  • Exposed decode_segments on the local MCP server (python/dotmatch/mcp_server.py) with strict JSON schema validation (SEGMENTS_SCHEMA).
  • Added vertical-slice TDD tests in python/tests/test_segments.py and python/tests/test_mcp_server.py.

Verification

  • make lint typecheck python-test on Linux worker (Agent37):
    • ruff check (typed sources and pyflakes): passed.
    • mypy --strict: passed (46 source files, 0 issues).
    • pyright: 0 errors, 0 warnings.
    • pytest python/tests: 2,203 passed, 3 skipped.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T01:16:10.812393Z
We couldn’t complete this review. Comment @codex review to try again.
b6a6326 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

This branch has not been deployed

No deployments
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