---
title: Colinear Chaining in Sequence Alignment
url: https://www.emergentmind.com/topics/colinear-chaining
type: topic
---

# Colinear Chaining in Sequence Alignment

Colinear chaining is a classical optimization problem in sequence comparison and sequence alignment in which one selects an ordered subset of fragments or anchors between two sequences so that their order is consistent in both sequences and an objective is optimized. In the classical fragment-chaining formulation, compatibility requires non-overlap in both sequences; in modern overlap-aware formulations, anchors may overlap provided they satisfy a precedence relation that does not move backward in the edit graph. The problem is a standard backbone step in whole-genome comparison, cDNA/EST mapping, conserved synteny detection, alignment of genomic regions, and a main component of many state-of-the-art read mappers based on seed-chain-extend [1506.07458] [2606.03929].

## 1. Formal problem setting

A classical formulation uses two sequences \(t\) and \(u\) of lengths \(n\) and \(m\), together with a set \(\mathcal{S}\) of \(k\) fragments. A fragment is represented by five fields,
\[
s = (s.\ell, s.r, s.t, s.b, s.s),
\]
where \(t[s.\ell, s.r]\) and \(u[s.b, s.t]\) are the corresponding substrings and \(s.s\) is the fragment score. Geometrically, each fragment is viewed as a rectangle in the quarter plane, with \(x\)-coordinates in \(t\), \(y\)-coordinates in \(u\), and borders \((s.\ell, s.b)\) and \((s.r, s.t)\). A chain is a set of fragments \(\{s_1,\dots,s_\ell\}\) such that
\[
s_i.r < s_{i+1}.\ell \quad\text{and}\quad s_i.t < s_{i+1}.b
\qquad \text{for } i=1,\dots,\ell-1,
\]
so fragments are ordered and non-overlapping in both sequences. The score of the chain is \(\sum_{i=1}^{\ell} s_i.s\), and the computational objective is the maximum chain score [1506.07458].

Modern formulations usually replace fragments by anchors, that is, exact matches between a query \(Q\) and a target \(T\). One presentation uses
\[
a = ([q_s..q_e],[t_s..t_e]),
\]
with
\[
q_e-q_s+1 = t_e-t_s+1,
\]
and studies chains under strict precedence, weak precedence, or a stricter “ChainX precedence” in which all start and end coordinates are strictly increasing [2506.11750]. Another presentation uses 0-indexed, right-open intervals,
\[
a = ([t_s..t_e), [q_s..q_e)),
\]
with startpoint \(\anchorstart(a) = (t_s, q_s)\), endpoint \(\anchorend(a) = (t_e, q_e)\), and diagonal
\[
\diag(a) = t_s - q_s,
\]
equivalently \(t_e-q_e\) because the anchor is an exact match [2606.03929].

These formalisms encode the same central idea: a chain is an increasing sequence of local exact correspondences that serves as a one-dimensional backbone for a global comparison. This suggests that “colinear” refers not to Euclidean colinearity, but to compatibility with a common left-to-right order in both sequences.

## 2. Objective functions and the anchored edit-distance connection

In the classical fragment model, the optimization target is additive reward: one maximizes the sum of fragment scores subject to compatibility. This is the formulation treated by the dynamic programming and line-sweep algorithms in the fragment-chaining literature [1506.07458].

In overlap-aware chaining for alignment, the objective is instead a minimum total connection cost. For a chain \(A=a_1,\dots,a_c\), one presentation introduces sentinels
\[
a_0 = \text{start} = ([0..0],[0..0]), \qquad
a_{c+1} = \text{end} = ([|Q|+1..|Q|+1],[|T|+1..|T|+1]),
\]
and defines
\[
\gscost(A)=\sum_{i=0}^{c}\connect(a_i,a_{i+1}),
\]
where
\[
\connect(a,a')=\maxgap(a,a')+\diffoverlap(a,a').
\]
Here
\[
\maxgap(a, a') = \max\!\big( 0,\; q'_s - q_e - 1,\; t'_s - t_e - 1 \big)
\]
measures the insertion/deletion-like gap between consecutive anchors, while
\[
\diffoverlap(a, a')=
\bigg| \max\!\big(0,\; q_e-q'_s+1\big) -
\max\!\big(0,\; t_e-t'_s+1\big) \bigg|
\]
penalizes inconsistent overlaps [2506.11750].

A second presentation, tailored to anchored edit distance, decomposes the same phenomenon into gap and diagonal terms. For anchors \(a \prec a'\),
\[
\Delta_T(a,a') := \max(0, t_s' - t_e), \qquad
\Delta_Q(a,a') := \max(0, q_s' - q_e),
\]
\[
L_\infty(a,a') := \max(\Delta_T(a,a'), \Delta_Q(a,a')),
\]
and
\[
\Delta_{\text{diag}}(a,a') := |\Delta_T(a,a') - \Delta_Q(a,a')|
= |\diag(a)-\diag(a')|.
\]
The connection cost is then
\[
\connect(a,a') = \max(L_\infty(a,a'), \Delta_{\text{diag}}(a,a')),
\]
equivalently
\[
\connect(a,a')= \begin{cases}
L_\infty(a,a') & \text{if } \text{gap-gap case},\\
\Delta_{\text{diag}}(a,a') & \text{otherwise (overlap case)}.
\end{cases}
\]
This formulation distinguishes true inter-anchor gaps from overlap configurations, in which cost is driven by diagonal mismatch rather than by a simple spatial separation [2606.03929].

The key theoretical link is that optimal overlap-aware colinear chaining is not merely heuristic. The 2025 paper restates the result of Jain et al. that
\[
\text{anchored edit distance} =
\text{optimal colinear chaining cost under strict precedence} =
\text{optimal colinear chaining cost under weak precedence},
\]
and adds that if the anchors are all maximal exact matches, then the optimal chaining cost is exactly the ordinary unit-cost edit distance between the two strings [2506.11750]. The 2026 paper formulates the same point for global and semi-global variants: the minimum-cost chain under the \(L_\infty\)/\(\Delta_{\text{diag}}\) model equals anchored edit distance, and the semi-global analogue equals semi-global anchored edit distance [2606.03929].

A frequent misconception is that colinear chaining is intrinsically a non-overlap problem. The overlap-aware literature shows otherwise: allowing overlaps is essential in current chaining formulations, and in long-read mapping overlaps improve sensitivity and avoid restrictions on the fragment class considered [2606.03929].

## 3. Classical algorithmic foundations

The standard dynamic programming formulation for fragment chaining defines
\[
M[i][j] = \text{score of an optimal chain for prefixes } t[0,i] \text{ and } u[0,j],
\]
together with a fragment-local state
\[
S[s] = \text{optimal score of a chain whose last fragment is } s.
\]
When the begin border \((s.\ell, s.b)\) of a fragment is reached,
\[
S[s] = s.s + \texttt{leftDown},
\]
where \(\texttt{leftDown}\) is the best score strictly before the fragment in both dimensions. When the end border \((s.r, s.t)\) is reached, the algorithm updates
\[
\maxC = \max(\maxC, S[s]),
\]
and the current column by
\[
M[j] = \max(M[j], M[j-1], \texttt{maxC}).
\]
The worst-case running time is \(O(k + n m)\) [1506.07458].

The line-sweep alternative is asymptotically better on sparse instances. It processes fragment borders in increasing order along sequence \(t\) and maintains a data structure \(A\) storing pairs \((p,v)\), where \(v\) is the best chaining score among partial chains in the rectangle from \((0,0)\) to \((pos,p)\), and the chain ends at a fragment whose top border is exactly \(p\). At a begin event for fragment \(s\),
\[
S[s] = s.s + v,
\]
where \((p,v)\) is the best score in \(A\) with \(p < s.b\). At the end event, if \(S[s]\) improves the frontier, one inserts \((s.t, S[s])\) and deletes dominated entries. With a balanced-tree-like structure supporting search, insertion, and deletions in logarithmic time, this yields \(O(k \log k)\) time [1506.07458].

The hybrid dynamic programming/line-sweep algorithm combines both principles. It first reduces the input to a compact instance \((t',u',\mathcal{S}')\), in which every position of \(t'\) and every position of \(u'\) contains at least one fragment border. This reduction preserves the chaining problem and can be computed in
\[
O\!\left(k + \min(k\log k,m) + \min(k\log k,n)\right)
\]
time and
\[
O(k+n+m)
\]
space. The decision to use dynamic programming or line sweep is then made per column using the border density
\[
\mathcal{K}_p = \text{number of fragment borders located at } t'[p].
\]
Positions with
\[
\mathcal{K}_p > \frac{m'}{\log m' - 1}
\]
belong to a dense set \(P^1\), and the remainder to a sparse set \(P^2\). The data structure \(B\) consists of an array \(\mathcal{B}\) of size \(m'\), augmented with a balanced binary tree \(\mathcal{C}\), and supports \(\texttt{setScore}(B,p,score)\) and \(\texttt{getBestScore}(B,p)\) in \(O(\log m')\) time. The resulting running time is
\[
O\left( k + \min(k\log k,m) + \min(k\log k,n) + \sum_{p \in P^1} (m' + \mathcal{K}_p) + \log m' \sum_{p \in P^2} \mathcal{K}_p \right),
\]
with space \(O(k+n+m)\). The paper argues that this hybrid is asymptotically never worse than either pure dynamic programming or pure line sweep [1506.07458].

## 4. Practical optimal chaining in modern aligners

Jain et al. gave an exact overlap-aware algorithm running in
\[
O(n\log^3 n)
\]
time for colinear chaining with overlap and gap costs, and proposed a practical implementation, \(\mathtt{ChainX}\), intended to run in
\[
O(n \cdot \mathrm{SOL} + n\log n)
\]
average-case time, where \(\mathrm{SOL}\) is the cost of the output chain. The practical idea is to guess an upper bound \(B\) on the optimal cost and only consider predecessor anchors that are close enough to the current anchor under a sparse and uniform anchor model [2506.11750].

The 2025 revisit shows that \(\mathtt{ChainX}\) is not guaranteed to be optimal. Its pruning rule requires only
\[
q_s^i - q_s^j \le B,
\]
and this does not ensure that every pair with \(\connect(a_j,a_i)\le B\) is considered. The paper exhibits a counterexample with anchors \(a_1,a_2,a_3,a_4\), where the optimal chain is \(a_1,a_4\) with cost \(3\), but \(\mathtt{ChainX}\) with \(B_{\text{start}}=9\) skips that transition and instead considers suboptimal chains of cost \(4\). A modified condition such as
\[
q_s^i - q_s^j - 1 \le B
\]
still fails because it misses overlapping-anchor cases [2506.11750].

The proposed correction introduces the anchor diagonal
\[
\diag(a)=q_s - t_s.
\]
Its central lemma states that if two anchors are in a gap-gap configuration, then
\[
\connect(a,a') = \maxgap(a,a'),
\]
whereas in all other overlap cases,
\[
\connect(a,a') = |\diag(a)-\diag(a')|.
\]
This yields a revised recurrence
\[
C[i] = \min(\mathrm{gap}_Q(i), \mathrm{overlap}_Q(i)),
\]
where \(\mathrm{gap}_Q(i)\) handles non-overlapping predecessors in \(Q\) and \(\mathrm{overlap}_Q(i)\) scans only diagonals within distance \(B\) of \(\diag(a_i)\). The implementation uses sorting by positions in \(Q\), bucketing by diagonal, and an active-anchor array \(\mathtt{D}\). It assumes, after preprocessing by merging perfect chains, that if two anchors have the same diagonal, then they do not overlap in \(Q\) or in \(T\); this preprocessing can be done in
\[
O(n\log n)
\]
time [2506.11750].

The resulting algorithm is optimal and runs in
\[
O(n \cdot \mathrm{OPT} + n \log n)
\]
average-case time, where \(\mathrm{OPT}\le \mathrm{SOL}\) is the optimal chaining cost. Empirically, the paper reports minimal computational slowdown relative to \(\mathtt{ChainX}\). On a real long-read dataset consisting of the T2T-CHM13 reference and 100k PacBio HiFi reads, \(\mathtt{ChainX}\) took about \(1610\) seconds, \(\mathtt{ChainX}\)-opt\(^*\) took about \(1631\) seconds, memory usage was about \(49\) GB for both, the average number of iterations was reduced from \(4.39\) to \(2.61\), and \(\mathtt{ChainX}\)-opt\(^*\) improved the chaining cost for
\[
2297 / 100000 = 2.29\%
\]
of the reads, with an average improvement ratio of \(515x\) on those improved cases [2506.11750]. This directly refutes the assumption that practical pruning is automatically harmless on realistic data.

## 5. Near-linear and sublogarithmic-time developments

The 2026 work revisits a different algorithmic lineage, beginning with the \(O(n \log \log n)\) algorithms of Eppstein et al. for fragment chaining without overlaps. Those classical methods minimized a gap cost based on diagonal distance between consecutive fragments, but they forbade fragment overlaps. The paper argues that overlaps are essential in current chaining formulations because, in long-read mapping, overlaps improve sensitivity and avoid restrictions on the fragment class considered [2606.03929].

Its main result is an asymptotic improvement for the overlap-aware anchored edit-distance model: the earlier
\[
O(n \log^3 n)
\]
exact algorithm is reduced to
\[
O(n \log \log n)
\]
time in
\[
O(n)
\]
space. The method combines the gap-cost computation of Chao and Miller with the overlap-cost computation of Baker and Giancarlo. The dynamic program is
\[
C[j] = \min_{i<j,\ a_i \prec a_j} \left(C[i] + \connect(a_i,a_j)\right),
\]
and the recurrence is partitioned into four mutually exclusive cases:
1. overlap, bigger \(T\)-overlap;
2. overlap, bigger \(Q\)-overlap;
3. gap-gap, bigger \(Q\)-gap;
4. gap-gap, bigger \(T\)-gap [2606.03929].

The difficult case is the fourth, handled by adapting the Eppstein et al. space-partitioning idea. Each anchor defines a triangular region of influence, and the best predecessor for a point on the sweep line is stored in an owner array \(R_t[q]\). The owner array is compressed as a doubly linked list of dividing lines, consisting of horizontal lines and diagonal lines; changes in ownership occur only at those lines, the total number of lines is \(O(n)\), and delayed intersection updates preserve \(O(n)\) space and \(O(n\log\log n)\) time [2606.03929].

The same paper also presents a simpler \(O(n \log n)\)-time implementation, **llchain**, which replaces specialized \(O(\log\log n)\)-time predecessor structures with a standard ordered map. Despite the weaker asymptotic bound, llchain is reported to scale competitively to millions of fragments and large genomes: on average it is \(10\times\) faster than other methods on instances with \(3{,}000{,}000\) anchors, over \(3\times\) faster on MEMs between HiFi reads and a reference human genome, and about \(3\times\) faster overall on the tested dataset. Reported average timings are seeding \(0.052\)s, ChainX \(0.19\)s, ChainX-opt \(0.33\)s, and llchain \(0.059\)s [2606.03929]. A plausible implication is that older chaining machinery, once adapted to overlap-aware cost models, remains highly competitive for modern genomics workloads.

## 6. Related chain formalisms and terminological scope

Outside sequence alignment, the word “chaining” denotes distinct technical constructions. In high-dimensional probability and Banach-space geometry, "Chaining, Interpolation, and Convexity" develops an interpolation-based chaining principle in which multiscale approximation is generated by Peetre’s \(K\)-functional rather than by Talagrand’s adaptive net construction. For a penalty \(f\) and metric \(d\),
\[
K(t,x):=\inf_{y\in X}\{f(y)+t\,d(x,y)\},
\]
with minimizer \(T_t(x)\), and \(A_t:=\{T_t(x):x\in A\}\). Proposition 2.3 states that for every \(p>0\),
\[
Y_p(A)\lesssim \sum_{n>0} 2^{n/p} e_n\!\big(A_{a2^{n/p}}\big).
\]
For symmetric compact convex \(B\subset X\), the thin subsets
\[
B_t=\{y\in B:\exists z\in X^*\text{ such that }(z,y)=|y|_B,\ |z|_{B}^{*}\le 1,\ |z|^*<t\}
\]
replace entropy numbers of the whole set by entropy numbers of smaller subsets. The paper does not use the term “colinear chaining,” but it explicitly describes the mechanism as chaining along a structured one-parameter family \(T_t\) produced by interpolation [1508.05906].

In discrete geometry, "Chains, Koch Chains, and Point Sets with many Triangulations" defines a chain as an \(x\)-ordered sequence of points
\[
C = p_0,p_1,\dots,p_n
\]
such that every consecutive segment \(p_{i-1}p_i\) is unavoidable in every triangulation. The visibility triangle
\[
V(C)_{i,j} =
\begin{cases}
+1, & \text{if } p_ip_j \text{ lies above the chain curve},\\
-1, & \text{if } p_ip_j \text{ lies below the chain curve},\\
0, & \text{if } p_ip_j \text{ is a chain edge } (j=i+1)
\end{cases}
\]
fully determines the order type of the chain. The paper proves a unique algebra of convex sums, concave sums, and flips; derives a quadratic-time dynamic program for the number of triangulations; and uses recursively defined Koch chains to obtain
\[
\Omega(9.083095^n)
\]
triangulations, improving the previous lower bound \(\Omega(8.65^n)\) [2203.07584]. The authors explicitly note that this notion of chain is analogous to ordering constraints in colinear chaining problems, but it is a different subject.

Taken together, these works delimit the technical scope of colinear chaining. In sequence algorithms, it is the optimization of an order-consistent backbone of fragments or anchors, with modern formulations tightly linked to anchored edit distance. In other areas, “chaining” refers either to multiscale approximation generated by interpolation or to combinatorial structures defined by unavoidable edges. The shared theme is a constrained, scale- or order-respecting decomposition, but the objects, objectives, and algorithms are domain-specific.

Source: https://www.emergentmind.com/topics/colinear-chaining