Reading Growing Molecular Alphabets with Segment Queries

DNA data storage gets denser when each position in the molecule can hold one of more than four letters. With chemically modified bases, eleven or twelve letters give about 3.5 bits per position instead of 2. The bottleneck is reading the letters back. A nanopore sequencer pulls a strand through a tiny pore and records an electrical current. Each letter blocks the current slightly differently, and each letter stays in the pore for a random amount of time. Today's readers either assume the four natural bases or, for expanded alphabets, classify fixed-length chunks of current. That second approach reaches only 60.28% average accuracy on an eleven-letter alphabet. Every time a chemist adds a letter, the reader must be retrained from scratch on data that costs about 400 times more to synthesize than natural DNA.

This note proposes that reading a trace be split into two questions, the way modern image segmentation splits "where is an object" from "what is it." Where one letter ends and the next begins depends mostly on the physics of the strand moving through the pore, which is largely the same whichever letters are present. Which letter a stretch of current represents is the only part that grows with the alphabet. We would build a one-dimensional version of the mask-classification decoders used in vision. In those decoders, a set of learned "queries" each claim a segment of the input and label it. We would train the "where" part on abundant natural-DNA data and freeze it. Adding a letter would then mean adding one learned reference vector, estimated from a handful of labeled examples. The claim to test is concrete. On a fixed labeling budget, this decoupled reader should keep accuracy higher as the alphabet grows than readers that tie segmentation and identity together.

Core Claim and What Is New

In vision, Per-Pixel Classification is Not All You Need for Semantic Segmentation (MaskFormer) replaced per-pixel labeling with a fixed set of queries. Each query predicts a binary mask plus a class, or "no object." Masked-attention Mask Transformer for Universal Image Segmentation (Mask2Former) made this practical by restricting each query's attention to its own previously predicted region. It reports 57.8 panoptic quality on COCO and 57.7 mIoU on ADE20K with one architecture for three tasks. K-Net and CLUSTSEG reach similar unification with dynamic kernels and cluster centers, and FreeSeg shows that the class head can be swapped for embedding matching so new categories can be named without retraining. These papers supply the method. As the survey by Li et al. notes, all of them work on 2D or 3D spatial grids. None has been applied to 1D biophysical traces.

On the storage side, Expanding the Molecular Alphabet of DNA-Based Data Storage Systems with Neural Network Nanopore Readout Processing built the eleven-letter alphabet and classified pre-cut current windows into 66 tetramer classes with a 1D ResNet, reaching 60.28% (chance 1.52%, best tetramer 79%). It motivates this proposal. It shows that expanded letters are distinguishable, and its fixed-window design has no way to handle variable dwell times or to add letters cheaply. NanoBaseLib documents the other half of the fragmentation problem. Canonical nanopore analysis chains separate tools for basecalling, polyA detection, event segmentation (SegPore performs best) and modification detection (m6Anet performs best), and errors propagate between the stages. It covers only natural bases plus natural modifications. The non-canonical nucleic acid review reports about 99% accuracy for modification callers such as DeepMod and Rockfish. Those callers depend on aligning to a known reference sequence, which does not exist when decoding stored data from scratch. So the review constrains the proposal as well as motivating it: high accuracy on modified letters is achievable, but not by the reference-dependent route.

What is new here is not "a transformer for nanopore signals." It is a specific factorization with a testable consequence. Segment localization is learned once on canonical data. Letter identity is a nearest-reference-vector lookup that grows by one vector per letter. The error cost of each added letter should therefore be measurable and small.

The Model

A 1D convolutional encoder produces features at several time resolutions. A set of $N$ queries passes through a Mask2Former-style decoder. Each query outputs two things. The first is a soft temporal mask over the trace. The second is an embedding $e_q$, which is scored against one reference vector $w_m$ per letter $m$ and a reference for "no object," as $p(m \mid q) \propto \exp(\langle e_q, w_m \rangle / \tau)$ with temperature $\tau$. Queries are matched to ground-truth segments by bipartite matching, as in MaskFormer.

Stretches of trace that are not letters get their own classes. These include open-pore current, adapters, and polyA tails, and they play the role of vision's amorphous "stuff" classes such as sky or road. This folds NanoBaseLib's polyA-detection task into the same forward pass as segmentation and identity.

One design choice is forced by the physics. Correcting a Single Deletion in Reads from a Nanopore Sequencer models the pore as a sliding window: the current at any moment reflects $\ell$ neighboring letters, not one. Mask2Former's hard attention mask, which blocks everything outside a query's own region, would therefore hide exactly the neighboring context the reader needs. We replace it with a mask dilated by the expected dwell of $\ell - 1$ neighbors. We compare this against the hard mask directly. This is where the coding-theory paper constrains the design, even though its results are proven only for binary inputs and idealized integer outputs.

Research Program

Training has three stages. First, the encoder and decoder are trained on NanoBaseLib canonical reads, using SegPore event alignments as segment labels and the four bases as letters. Second, the encoder and decoder are frozen. For each new letter, a reference vector $w_m$ is fit from $k$ labeled segments, with $k$ ranging from 5 to 500. Third, an optional light fine-tuning of the whole model measures how much freezing costs.

This yields an alphabet-growth curve that no current reader produces: per-letter accuracy as a function of alphabet size $M$ and labels per new letter $k$. We also track whether accuracy on the original letters degrades as letters are added. This is the stability–plasticity question that Towards Continual Universal Segmentation studies for images.

The evaluation has two arms. The extension arm uses only NanoBaseLib. It treats its natural modifications (m6A, m5C, hm5C, inosine, pseudouridine) as new letters added one at a time on top of the four bases, taking $M$ from 4 to 9. The labels come from NanoBaseLib's synthetic-control datasets, where modification positions are known by design. The expanded-chemistry arm transfers the frozen reader to the 77-tetramer eleven-letter GridION library from Tabatabaei et al. Per-letter segment predictions are composed into tetramer calls so that the results are comparable with the 66-class task. The second arm depends on obtaining that raw signal data. If the data cannot be obtained, the extension arm stands on its own and the transfer arm becomes future work. The eight-level DNA Tails system is an interesting later target, because there the symbol is a segment length, which a mask output encodes directly. No nanopore signal data for it appears in the file, so it is out of scope here.

Baselines

The naive reference point is the fixed-window 1D ResNet of Tabatabaei et al. It reports 60.28% average accuracy over 66 tetramer classes, against 1.52% chance. We would retrain it on the same windows and the same labeled budget. In the extension arm it is retrained per alphabet size. Any reader that does not clearly exceed it in the expanded arm has no case.

The strongest competitor is a CTC basecaller with its output layer widened to $M$ letters. CTC (connectionist temporal classification) is the alignment-free, per-frame labeling loss used by Dorado- and Guppy-style basecallers, which NanoBaseLib reports at roughly 93–95% accuracy on canonical DNA. It is the strongest threat because CTC already handles variable dwell times without explicit boundaries, and its encoder can also be pretrained on canonical data and frozen. For fairness it gets the same encoder architecture, the same canonical pretraining, and the same per-letter label budget $k$. New letters are added by extending its softmax, trained either with a frozen or with a fine-tuned encoder. Hyperparameter search budgets are matched. No reported result was found on Lacuna for a CTC basecaller on an expanded (M>4) synthetic alphabet. Beating it means higher per-letter accuracy on newly added letters at small $k$ (≤50 labeled segments). Canonical-letter accuracy must stay no worse, and the gap must be consistent across the five modification-letter additions in the extension arm.

The third baseline is the fragmented two-stage pipeline: SegPore segmentation, then a classifier on pooled segment features, with the same reference-vector head. NanoBaseLib names SegPore as the best segmenter but gives no number. This baseline isolates whether joint, iterative refinement of segments by the queries matters, or whether decoupling alone explains any gain.

Two ablations isolate the key ingredients. The hard-versus-dilated attention mask tests the sliding-window argument. A reference-vector head versus an ordinary softmax head tests whether embedding matching is what makes letter addition cheap.

Why not just…?

Why not just widen the output layer of an existing CTC basecaller? This is a real threat, and it may work nearly as well. Our argument for segment queries is that pooling a whole segment into one embedding gives a cleaner per-letter signal than per-frame scores. This matters most when a new letter's current level sits close to an existing one's, which is exactly the regime of few labels. That is a hypothesis, not established evidence. The matched-budget comparison settles it. If frozen-encoder CTC matches our reader within seed variance at every $k$, we drop the claim that segment queries matter. What remains is the weaker, still useful claim that canonical pretraining plus cheap head extension beats training from scratch.

Why not just keep the pipeline and run a good segmenter, then a classifier? NanoBaseLib itself reports that errors cascade across its pipeline stages. The two-stage baseline measures the cost of that cascade directly. If it matches the joint decoder, the lesson is that decoupling "where" from "which" is what matters and the query decoder is unnecessary machinery. That would be an informative and publishable negative.

Why not just train a bigger fixed-window classifier on more expanded-alphabet data? More data is exactly what is expensive: modified building blocks cost about 400 times more than natural ones, according to the ncNA review. A fixed-window classifier also has to learn boundary handling anew for every alphabet. The growth curve shows whether its accuracy per labeled example lags behind a reader whose segmentation was learned on free canonical data.

Decisive Checks

The central experiment is the alphabet-growth curve on NanoBaseLib, comparing new-letter accuracy at $k \in \{5, 50, 500\}$ for the three readers. It succeeds if our reader's accuracy on each newly added letter drops less as $M$ grows than the CTC baseline's, while its canonical accuracy stays within one point of its $M = 4$ level. Second, dilated masks must beat hard masks on boundary error (mean absolute offset of predicted segment edges) and on letter accuracy. If they do not, the sliding-window argument is wrong for real currents. Third, in the expanded-chemistry arm, the frozen reader with a few labeled segments per modified letter must exceed the reported 60.28% tetramer accuracy. Exceeding it without full retraining would be the clearest evidence that reading, like image segmentation, need not be rebuilt every time the label set changes.