Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
Created September 24, 2026 16:10
Show Gist options
  • Select an option

  • Save cmdcolin/aeda3eae2542ba2f9907dca140ff6225 to your computer and use it in GitHub Desktop.

Select an option

Save cmdcolin/aeda3eae2542ba2f9907dca140ff6225 to your computer and use it in GitHub Desktop.
seqviewspec claude code review

Sequence ↔ structure interop: the Mol* harness prototype

Kept out of the react-msaview repo on purpose. The prototype is somebody else's unreleased work — the demo is up but the source repo does not resolve, so nothing here is published. A reverse-engineered critique of it does not belong in a public repo's history. What this argues for our own code lives in react-msaview/agent-docs/ideas/alignment-structure-mapping-layer.md, written to stand on its own without any of the below.

Read 2026-09-10 at https://dsehnal.github.io/molstar-harness-proto/. David Sehnal (Mol* lead) is prototyping a message-bus harness — it calls itself seqstar — for wiring independent bio viewers together: a sequence renderer, a Nightingale renderer, and a Mol* structure view, none of which know about each other. One of its six case studies is /alignment-structure, an MSA linked to four protein structures. This doc records what the prototype specifies, what is worth taking, and where the specification is thin, so nobody re-reads the bundles to find out.

Reading it again. The page is a client-rendered SPA, so fetching the HTML gives a shell and nothing else, and the source repo does not resolve publicly. The content is in the deployed bundles under assets/. The route stubs (alignment-structure-*.js and friends, listed as modulepreloads in index.html) name the real chunks in their __vite__mapDeps array. The ones that matter are the harness core (~115 kb, the fabric, spaces, translators and message schemas), the integration plugins (~173 kb, every case's wiring plus the SeqViewSpec documents), and the case chunk itself, which inlines its fixtures as string literals. Prettier makes all of them readable. Hashes change per build, so re-derive the names rather than reusing these.

The architecture

Components are viewers: seqstar.reference-viewer, seqstar.nightingale, seqstar.molstar-mvs. A component factory returns {capabilities, start({fabric, translators, signal, reportCapabilities, reportCoordinateSpaces}), dispose()}. Components declare capability strings (seqstar:interaction/native-hover) and report the coordinate spaces they currently hold ({kind: 'structure-residue', authority: 'molstar', context: {entry: '1A3N'}}). Messages published before a component reaches ready are replayed once it does. A component can be hot-swapped at runtime, which is what the renderer-portability case demonstrates.

Plugins hold every piece of integration logic — {id, requires, provides, setup(ctx)} — and register translators, message schemas and processors ({id, types, async process(msg, ctx, signal)}). No viewer contains a line of code about any other viewer.

The fabric is a validated message bus. The envelope is {id, type, version, source: {component|plugin}, target?, correlationId, causationId?, timestamp, payload}, with UUID and ISO-8601 patterns enforced by JSON Schema and a bad envelope raising harness.message.invalid rather than throwing. target is one of {component}, {plugin}, {capability} or {broadcast: true}.

Coordinate spaces and translators are the core. A space is {id, kind, authority?, context?, length?}; a locus is point | interval | boundary carrying its space inline, with positions as index (0-based integer) or label (string plus insertionCode, i.e. PDB auth numbering). A translator is {id, source, target, map()} returning associations tagged exact | partial | ambiguous | unmapped. A planner does DFS over registered translators (≤4 hops, ranked by caller-preferred ids, then summed cost, then length), so alignment column → row sequence → UniProt → structure residue composes without anyone writing the composition, and the demo prints the resulting path as translatorIds.join(' -> '). Degradations are typed events on the bus — harness.translation.unmapped, .cap, .timeout, .aborted, .intermediate — never a silent guess. Hover-rate translation is abort-controlled per (direction, interaction), so a new hover cancels the in-flight mapping of the previous one.

Interaction is split in two, which is the sharpest idea in the design:

  • A viewer emits interaction.native — {interactionId, interaction: hover|select|focus|track-activate|viewport, phase: set|clear, origin: {componentId, trackId?, alignmentMemberId?, …}, loci} — strictly in its own coordinates, addressed to nobody.
  • A viewer receives interaction.highlight.apply / .selection.apply / .focus.apply and their .clear counterparts, each carrying owner: {correlationId, sourceComponent}. Ownership makes every source its own highlight layer, and only that source can clear it.

Rendering is declarative. Plugins publish visualization.mvs.request (MolViewSpec) or visualization.seqviewspec.request with {format, requestId, mode: 'replace', document, viewId?}, and components answer with lifecycle.visualization: {requestId, generation, status: accepted | rendered | degraded | superseded | failed, previousView: retained | cleared, capabilities, diagnostics}.

SeqViewSpec is a MolViewSpec analogue for sequence panels: sequences, annotations (either loci items or values with dense/sparse encoding and a number/category type), and views → axis (segments plus ruler) → sections → tracks → layers. A layer names a representation, a color spec (categorical or continuous), and — the good part — a fallback representation for renderers that cannot draw the first choice, which then report seqviewer.representation.fallback instead of dropping it.

Every input is frozen and hashed. Fixtures are canonical JSON (sorted keys, deep-frozen), each with a sha256, and the whole deck runs offline.

The alignment → structure case

The alignment is PF00042.29, 32 rows, 118 columns, query P69905 positions 27–137, shown against one experimental structure (1A3N chain A) and three AlphaFold DB v6 models, each labeled as predicted in its own provenance string.

Two artifacts carry the biology.

A correspondence table per member, one TSV row per alignment column:

alignment_column_1based  alignment_index_0based  member_row  uniprot_accession
aligned_residue  uniprot_position_1based  model_id  model_entity_id
label_asym_id  auth_asym_id  label_entity_id  label_seq_id  auth_seq_id
model_residue_three_letter  observed_ca  sequence_status  status
source_alignment_column_0based  source_aligned_residue

status is exact_observed or alignment_gap or not_applicable. source_alignment_column_0based maps back to the column in the source alignment, since the displayed alignment is a re-columned subset.

A superposition transform per predicted model, as a checked-in JSON with a 16-value column-major matrix and this rule:

Ordered one-to-one C-alpha pairs from columns where both the frozen P69905 query row and the frozen member row have exact observed mappings; no sequence or structure alignment is performed.

plus pairCount, rmsdAngstrom, the algorithm and package version (molstar@5.11.0, MinimizeRmsd.compute), and a sha256 of every input — the two mmCIFs, the frozen alignment, and both mapping tables.

Colors come from the alignment: clicking the consensus, conservation or subgroup track publishes an intent, and the plugin rebuilds an MVS document that colors every mapped structure by that profile.

What is right

The correspondence is data, computed once, with provenance. No sequence matching at view time, no service call, no heuristic. The viewer's only job is to look positions up and refuse when there is no entry.

Refusing is a first-class outcome. "Gap columns retain their alignment locus and never invent a sequence or structure position" is the load-bearing sentence of the whole design, and the status vocabulary exists to make refusal legible rather than invisible.

Superposition from alignment columns. The MSA already asserts which residues correspond; fitting on exactly those pairs needs no structural aligner and no service, and it makes the resulting overlay an honest consequence of the alignment rather than an independent claim about it.

Owner-keyed interaction layers. Every highlight belongs to whoever applied it, so two sources cannot clobber each other and neither can clear the other's state.

Per-layer fallback representations. A renderer that cannot draw bars draws a heatmap and says so, instead of silently rendering nothing.

What is wrong

The rigor is on the transport, not the biology. The bus is pinned to the JSON-Schema level — UUID patterns, an ISO-8601 regex with a hand-rolled leap-year check, additionalProperties: false throughout. The artifact carrying the actual biological claim is a 19-column TSV with no schema, no version field, and no digest travelling with it in any message. Two implementations would agree perfectly on envelope shape and disagree about what not_applicable means. The correspondence table is the interoperability surface and it is the one thing not specified.

Three status vocabularies for one concept. The TSV carries observed_ca (bool), sequence_status (exact/not_applicable) and status (exact_observed/alignment_gap), with no stated precedence, and none of the three is the message-level exact | partial | ambiguous | unmapped.

The planner ranks by cost, which is not correctness. map() enumerates paths, sorts, and takes the first. cost is a hand-set integer, so nothing distinguishes SIFTS from a sequence-identity shortcut. Candidate paths that would give different answers are never reported — ambiguous means "more than one target from the winning path", never "more than one path". Registering a cheaper translator silently changes existing answers app-wide. And the reference integration does not trust any of it: the CDS processor pins {preferredTranslatorIds: [...], maxSteps: 1}. When every caller must pin the path to be correct, the planner is a lookup with extra steps.

Status conflates cardinality with confidence. Zero targets is unmapped, any degraded hop taints the whole path to partial, exactly one target is exact, more than one is ambiguous. So a column selection that legitimately maps to 30 residues across 30 rows reports as ambiguous, a single target through a shaky hop reports as exact, and partial never says which hop degraded.

The expansion cap truncates arbitrarily. Each hop slices to a cap in whatever order the translator emitted and raises harness.translation.cap. An over-cap fan-out therefore highlights an arbitrary subset, and because the cap applies per hop, early truncation prunes branches later hops would have used. For a design built on never inventing a position, an unordered subset is worse than a refusal.

Space identity is too loose, and the reference plugin proves it. Spaces match on kind, comparing id and authority only when both sides define them, and ignoring context keys present on only one side. So a translator declaring {kind: 'structure-residue'} matches every structure-residue space in the application. The alignment-structure plugin works around this by hand: filter on kind and authority, derive an id by splitting a member id on -, then substring-match it against context.entry. The spec's own showcase integration routes by string sniffing.

Conventions live in error messages. Intervals are {start, end} integers with no half-open/closed statement in the type — the convention appears only inside a CDS diagnostic string, "non-empty zero-based half-open interval". Loci are 0-based while the shipped TSV is 1-based, and nothing says which side owns the conversion. For a project that exists because coordinate conventions are where bio tools break, that is the wrong place to keep one.

boundary loci are declared but undefined. The variant carries no side field, left-inside/right-inside appear in the core but not in the schema, and no translator maps a boundary. Insertion points between residues are exactly where indel semantics get hard; naming the case without defining it invites every translator to invent something.

interaction.native is three messages in one schema. hover|select|focus are loci-bearing pointer events; track-activate is a UI command; viewport is a scroll report with a different payload and no loci, yet loci is required. Every processor opens by filtering the enum. The action path is worse: the plugin injects button definitions into the renderer's config, the renderer echoes back a trackId, and the plugin maps that id to an intent through a hardcoded {consensus, conservation, subgroups} dictionary — the intent round-trips through a string the renderer chose, even though intent.* message types already exist elsewhere in the same codebase.

Capabilities are decorative. Plugins declare requires, components report capabilities, the envelope supports target: {capability} — and then the alignment-structure plugin publishes everything to hardcoded component ids. Nothing refuses to start a plugin whose requirements no component satisfies.

Frozen inputs hide the failures that matter. Offline, digest-pinned fixtures are right for tests, but the interesting failures here are live: SIFTS revisions, obsoleted entries, UniProt sequence version bumps, AlphaFold model bumps (already at model_v6), chimeric entities. No message lets a component say "these loci were computed against a sequence revision I am not displaying", even though SeqViewSpec identifiers already carry {namespace: 'uniprot', value: 'P04637', version: '4'}. The digest discipline stops at the fixture boundary and never rides on the wire.

The superposition gets the least per-position accounting. It is the one derived assertion in a system that otherwise refuses to summarize, and it is reported as a single 0.54 Å rmsd over 110 pairs — tight in the helices, loose in the loops, and the schema cannot say so.

Smaller. A subscriber that throws is deleted permanently, so one bad render takes a panel off the bus for the session with a diagnostic as the only trace. Timeouts are classified by e.message === 'timeout'. Two unrelated mode fields exist: a literal 'replace' on render requests and a real replace|add|remove|toggle on interactions.

What we take

The correspondence table, the refusal rule, and owner-keyed interaction layers. Those are the parts that are both right and load-bearing, and ideas/alignment-structure-mapping-layer.md works them into this repo — keyed by row residue rather than by alignment column, because our columns move under hideGaps and theirs are frozen.

We skip the translator graph, which looks the most like architecture and delivers the least at three spaces and one consumer, and we skip SeqViewSpec, which solves the inverse of our problem: it exists so PDBe can swap renderers, where our value is one renderer drawn deeply. Two details from it are worth folding into columnTracks anyway — a per-layer fallback representation, and a diagnostic when a layer cannot be drawn as asked instead of dropping it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment