jbrowse-plugin-tview 2.2.0 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  import { alignToUnit, unitIdentity } from './align';
2
- const SPANNED_GAP = '-';
3
- const ABSENT = '.';
2
+ import { ABSENT, SPANNED_GAP } from './readLayout';
4
3
  /**
5
4
  * What one row has between two reference positions: its matched bases, plus
6
5
  * whatever it inserted inside, minus whatever it deleted.
@@ -35,98 +34,190 @@ export function extractAllele(read, start, end) {
35
34
  }
36
35
  return ret;
37
36
  }
38
- /** Reference positions an array owns, including the insertion slot at its right edge. */
39
- export function arrayInsertionKeys(array) {
40
- const ret = [];
41
- for (let pos = array.start; pos <= array.end; pos++) {
42
- ret.push(pos);
43
- }
44
- return ret;
45
- }
46
37
  /**
47
- * How far outside an array an insertion of its own unit can be anchored, in
48
- * copies. An indel made of repeat units has no unique placement inside the
49
- * array, and the flanking bases let the aligner carry it a little further still
50
- * — but only about a copy, because past that the sequence either side stops
51
- * matching. Every misplaced repeat allele in the trio sits within one copy of
52
- * the edge: ATXN3's at 1bp, FMR1's at 2bp of a 3bp unit, ABCA7's at 19bp of a
38
+ * How far outside an array an insertion is looked for, in reference bases.
39
+ *
40
+ * GIAB's adotto tandem repeat catalog buffers every interval by +/-25bp before
41
+ * merging, to leave room for the alignment ambiguity that comes with capturing
42
+ * variation inside a repeat, and measured what the buffer misses: re-expanding
43
+ * every region by a further 10bp would move only 0.2% of its boundaries
44
+ * (English et al., Nat Biotechnol 42, 2024, doi:10.1038/s41587-024-02225-z). A
45
+ * whole copy is the floor for a unit longer than that, since a copy is the
46
+ * aligner's room to slide a repeat indel. Both cover the misplacements measured
47
+ * in this trio: ATXN3 at 1bp, FMR1 at 2bp of a 3bp unit, ABCA7 at 19bp of a
53
48
  * 25bp one.
49
+ *
50
+ * It bounds the search, not the answer. Whether an insertion actually moves is
51
+ * decided exactly, by `shiftInsertion`, so this being generous costs nothing.
54
52
  */
55
- const ABSORB_COPIES = 1;
53
+ const FLANK_BP = 25;
54
+ /** the read's aligned base at a reference position, if it has one there */
55
+ function readBase(read, pos) {
56
+ const i = pos - read.start;
57
+ return i >= 0 && i < read.refChars.length ? read.refChars[i] : undefined;
58
+ }
56
59
  /**
57
- * How much of the inserted sequence the array's unit has to explain before the
58
- * insertion counts as part of the array. The repeat alleles the aligner
59
- * anchored just outside an array in the trio score 0.94-1.00 here and unrelated
60
- * sequence scores 0.67 or below, so this sits in open space rather than on a
61
- * boundary.
60
+ * How much of an insertion the array's unit has to explain before it counts as
61
+ * the array's. The repeat alleles the aligner anchored just outside an array in
62
+ * the trio score 0.9 and up, and unrelated sequence scores 0.67 or below, so
63
+ * this sits in open space rather than on a boundary.
62
64
  */
63
- const ABSORB_IDENTITY = 0.8;
65
+ const BELONGS_IDENTITY = 0.8;
64
66
  /**
65
- * Widen each array to cover the insertions the aligner anchored just outside it
66
- * that are made of the array's own unit.
67
+ * `ins`, inserted before reference position `from`, rewritten as an insertion
68
+ * before `to` — or undefined when the read's own bases do not allow it.
67
69
  *
68
- * An allele is measured over a reference interval, which fixes the "one array
69
- * reports as several sites" problem for indels the aligner placed *inside* the
70
- * interval. It does not fix the ones it placed just outside: an aligner is free
71
- * to anchor an expansion at the base before the array starts, and there the
72
- * insertion is not part of any allele — it is left to become its own run of
73
- * insertion columns, and the read it belongs to is measured as if it carried
74
- * the reference allele. Both halves of that are wrong, and they are not rare:
75
- * at ATXN3 the aligner anchored 60 of 162 reads' expansions one base outside
76
- * the array, and at ABCA7 a 1207bp allele 19 bases outside.
70
+ * An insertion has no unique position. `S` before a base `b` and `rotate(S)`
71
+ * after it spell the same read, so an aligner is free to anchor an expansion
72
+ * outside the array it belongs to, and at ATXN3 it did exactly that for most of
73
+ * the reads carrying one. Walking an indel through that equivalence class is
74
+ * the standard normalization for it (Tan, Abecasis & Kang, "Unified
75
+ * representation of genetic variants", Bioinformatics 31, 2015,
76
+ * doi:10.1093/bioinformatics/btv112, which walks left; this walks toward the
77
+ * array, the same operation with the array as the canonical anchor).
77
78
  *
78
- * What is absorbed is decided by the inserted sequence, not by the count of
79
- * reads carrying it — a single read's expansion is as real as fifty, and the
80
- * whole point of measuring over an interval is that it does not need a vote.
81
- * Widening the interval costs every row the few reference bases in between,
82
- * which they all pay equally, so the counts stay comparable.
79
+ * The step is tested against the **read's** aligned base rather than the
80
+ * reference's, which is what makes the rewrite exact: the row still renders
81
+ * base for base as it did, and the only thing that changes is the reference
82
+ * position the bases are filed under. A step onto a deletion has no base to
83
+ * swap with and stops.
84
+ *
85
+ * Being exact, it is also incomplete, and measurably so. An aligner does not
86
+ * only choose among equivalent placements — it chooses the highest-scoring one,
87
+ * which for a repeat allele carrying an interruption is often not equivalent to
88
+ * any placement inside the array. FMR1's misplaced read is exactly that: 32bp
89
+ * of the locus's own CGG anchored two bases early, starting on a `C` where the
90
+ * read has a `G`, so no rewrite of it exists. Hence `reanchorInsertions` treats
91
+ * this as the preferred spelling and not as the test of whether to move.
83
92
  */
84
- export function absorbAdjacentInsertions(reads, arrays) {
93
+ export function shiftInsertion(read, from, to, ins) {
94
+ let seq = ins;
95
+ for (let pos = from; pos < to; pos++) {
96
+ const head = seq[0];
97
+ if (readBase(read, pos) !== head) {
98
+ return undefined;
99
+ }
100
+ seq = seq.slice(1) + head;
101
+ }
102
+ for (let pos = from - 1; pos >= to; pos--) {
103
+ const tail = seq.at(-1);
104
+ if (readBase(read, pos) !== tail) {
105
+ return undefined;
106
+ }
107
+ seq = tail + seq.slice(0, -1);
108
+ }
109
+ return seq;
110
+ }
111
+ /**
112
+ * The window around each array that its insertions may be re-anchored from.
113
+ *
114
+ * Two arrays may not claim one position: `extractAllele` reads the slot at an
115
+ * array's `end`, so a shared slot would be counted into two alleles. Neighbours
116
+ * split the reference between them down the middle — a property of the
117
+ * reference alone, so unlike the interval it replaces, no read can move it.
118
+ */
119
+ export function flankWindows(arrays) {
85
120
  const ordered = [...arrays].sort((a, b) => a.start - b.start);
86
- // the widened end of the array to the left, which the next one may not reach
87
- let previousEnd = -Infinity;
88
121
  return ordered.map((array, i) => {
89
- const margin = ABSORB_COPIES * array.period;
90
- // Two arrays that met at a position would read the same insertion slot
91
- // twice — once as each one's allele — so they are held apart on both
92
- // sides: leftwards off whatever the previous array grew to, rightwards off
93
- // where the next one starts, which is as far left as that one can be
94
- // pushed in turn. Neither bound can cross the array's own edges, since
95
- // mergeArrays has already left a gap between every pair.
96
- const floor = Math.max(array.start - margin, previousEnd + 1);
97
- const ceiling = Math.min(array.end + margin, (ordered[i + 1]?.start ?? Infinity) - 1);
98
- let { start, end } = array;
99
- // memoized per distinct insert: one locus routinely has dozens of reads
100
- // carrying the same allele at the same site
101
- const belongs = new Map();
102
- const isUnit = (ins) => {
103
- let ret = belongs.get(ins);
104
- if (ret === undefined) {
105
- ret = unitIdentity(ins, array.unit) >= ABSORB_IDENTITY;
106
- belongs.set(ins, ret);
107
- }
108
- return ret;
122
+ const pad = Math.max(FLANK_BP, array.period);
123
+ const previous = ordered[i - 1];
124
+ const next = ordered[i + 1];
125
+ return {
126
+ array,
127
+ from: Math.max(array.start - pad, previous ? Math.floor((previous.end + array.start) / 2) + 1 : -Infinity),
128
+ to: Math.min(array.end + pad, next ? Math.floor((array.end + next.start) / 2) : Infinity),
109
129
  };
110
- for (const read of reads) {
111
- for (const [pos, ins] of read.insertions) {
112
- // a whole copy at least: a base or two of read error next to an array
113
- // says nothing about where the array ends, and moving the interval for
114
- // it would lay flanking sequence out as repeat copies
115
- if (ins.length < array.period ||
116
- pos < floor ||
117
- pos > ceiling ||
118
- (pos >= array.start && pos <= array.end) ||
119
- !isUnit(ins)) {
120
- continue;
121
- }
122
- start = Math.min(start, pos);
123
- // an insertion is keyed to the position it precedes, and extractAllele
124
- // reads the slot at `end`, so covering it means reaching that position
125
- end = Math.max(end, pos);
126
- }
130
+ });
131
+ }
132
+ /** the array whose window `pos` falls in, if any */
133
+ function windowAt(pos, windows) {
134
+ for (const window of windows) {
135
+ if (pos < window.from) {
136
+ return undefined;
137
+ }
138
+ if (pos <= window.to) {
139
+ return window;
140
+ }
141
+ }
142
+ return undefined;
143
+ }
144
+ /**
145
+ * Re-file each read's insertions under the array they belong to, one read at a
146
+ * time.
147
+ *
148
+ * Measuring an allele over a reference interval fixes the "one array reports as
149
+ * several sites" problem for indels the aligner placed *inside* the interval.
150
+ * It does not fix the ones placed just outside: there the insertion is part of
151
+ * no allele — it becomes its own run of insertion columns — and the read
152
+ * carrying it is measured as though it had the reference allele. Both halves of
153
+ * that are wrong, and neither is rare: at ATXN3 the aligner anchored 60 of 162
154
+ * reads' expansions one base outside the array.
155
+ *
156
+ * Doing this per read is the whole point. Widening the shared interval instead
157
+ * — which is what this replaces — made one read's misplacement everyone's: a
158
+ * single spurious copy anchored two bases early moved the array's left edge for
159
+ * every row, and the reference's own copy count with it. Re-anchoring touches
160
+ * only the read that carries the insertion, so a read can be wrong on its own.
161
+ *
162
+ * Nothing here consults the other reads, or how many of them agree. A single
163
+ * read's expansion is as real as fifty, which is what measuring over an
164
+ * interval buys and what a vote would give back. What decides an insertion is
165
+ * its own sequence: `unitIdentity` against the array's unit, since the aligner
166
+ * is free to place a repeat allele outside the array but is not free to make
167
+ * unrelated sequence out of the array's unit.
168
+ */
169
+ export function reanchorInsertions(reads, arrays) {
170
+ const windows = flankWindows(arrays);
171
+ if (!windows.length) {
172
+ return reads;
173
+ }
174
+ // memoized per array and distinct insert: one locus routinely has dozens of
175
+ // reads carrying the same allele at the same site
176
+ const belongs = new Map();
177
+ const isUnit = (window, ins) => {
178
+ const key = `${window.array.start}:${ins}`;
179
+ let ret = belongs.get(key);
180
+ if (ret === undefined) {
181
+ ret =
182
+ // a whole copy at least: a base or two of read error beside an array
183
+ // says nothing about where its allele ends, and the identity of a
184
+ // fragment shorter than the unit is not a measurement of anything
185
+ ins.length >= window.array.period &&
186
+ unitIdentity(ins, window.array.unit) >= BELONGS_IDENTITY;
187
+ belongs.set(key, ret);
188
+ }
189
+ return ret;
190
+ };
191
+ return reads.map(read => {
192
+ if (!read.insertions.size) {
193
+ return read;
194
+ }
195
+ let moved = false;
196
+ const next = new Map();
197
+ // Insertions are re-filed in genomic order of where the aligner put them,
198
+ // so two events landing in one slot keep their order along the read.
199
+ for (const [pos, ins] of [...read.insertions].sort((a, b) => a[0] - b[0])) {
200
+ const window = windowAt(pos, windows);
201
+ const { start, end } = window?.array ?? {};
202
+ const target = window === undefined || (pos >= start && pos <= end)
203
+ ? undefined
204
+ : isUnit(window, ins)
205
+ ? pos < start
206
+ ? start
207
+ : end
208
+ : undefined;
209
+ // an exact rewrite is preferred where one exists, so a row that can be
210
+ // re-spelled reads base for base as the aligner wrote it; where none
211
+ // exists the bases move as written, which preserves the length the
212
+ // measurement is made of
213
+ const at = target ?? pos;
214
+ moved ||= target !== undefined;
215
+ const seq = target === undefined
216
+ ? ins
217
+ : (shiftInsertion(read, pos, target, ins) ?? ins);
218
+ next.set(at, (next.get(at) ?? '') + seq);
127
219
  }
128
- previousEnd = end;
129
- return { ...array, start, end };
220
+ return moved ? { ...read, insertions: next } : read;
130
221
  });
131
222
  }
132
223
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"alleles.js","sourceRoot":"","sources":["../../src/LaunchTView/alleles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAkCnD,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,MAAM,GAAG,GAAG,CAAA;AAElB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,IAAgB,EAAE,KAAa,EAAE,GAAW;IACxE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA;IAC9C,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,IAAI,GAAG,GAAG,EAAE,CAAC;QACrC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD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AG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;gBAC9B,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAI,CAAC;YACP,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpD,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,SAAS;YACT,YAAY;YACZ,YAAY;SACb,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -6,7 +6,15 @@ export interface Tally {
6
6
  /** Each distinct value with how many rows carried it, smallest value first. */
7
7
  export declare function tally(values: number[]): Tally[];
8
8
  /**
9
- * The copy counts a sample carries, as the counts enough of its reads agree on.
9
+ * The copy counts a sample carries, each with the reads that fell on it or in
10
+ * its skirt.
11
+ *
12
+ * Reads scatter around an allele — slippage in the molecule, slippage in the
13
+ * aligner — so a rule that reported only exact agreement credited an allele
14
+ * with a fraction of the reads that actually support it, and left the rest
15
+ * looking like disagreement. Counts are gathered strongest first, so an allele
16
+ * is established before anything can be read as its shoulder, and a value joins
17
+ * one only if it is both near it and much weaker than it.
10
18
  *
11
19
  * This is a report of what the reads say, not a genotype call: it does not know
12
20
  * a ploidy, so a homozygote and a haploid locus both come back as one number,
@@ -17,11 +25,11 @@ export interface SampleArrayStats {
17
25
  sample: string;
18
26
  /** rows that reached both ends of the interval, i.e. that were measured */
19
27
  spanning: number;
20
- /** copy counts enough of them agreed on */
28
+ /** the alleles found, each with the reads counted into it */
21
29
  modes: Tally[];
22
30
  /** every copy count seen, with its support */
23
31
  copies: Tally[];
24
- /** rows whose copy count is not one of the modes */
32
+ /** rows counted into no allele at all */
25
33
  offMode: number;
26
34
  }
27
35
  export interface ArrayStats {
@@ -8,21 +8,47 @@
8
8
  * back counts, which is what makes it testable without the network.
9
9
  */
10
10
  import { ABSENT, SPANNED_GAP } from './readLayout';
11
+ import { newickSafe } from './sampleTree';
11
12
  import { renderRow } from './tview';
12
13
  /**
13
14
  * Least support an allele needs before it is reported as one of a sample's,
14
15
  * as a fraction of that sample's spanning reads.
15
- *
16
- * Reads scatter around an allele — slippage in the read, slippage in the
17
- * aligner — so the counts either side of a real allele are populated too, and
18
- * a rule that took the top two would report the shoulder of one allele as the
19
- * other. A fraction of coverage rather than a distance in copies is what lets
20
- * two alleles a single copy apart both be reported, which at FMR1 is the
21
- * mother's genotype and at ATXN3 the father's.
22
16
  */
23
17
  const MIN_ALLELE_FRACTION = 0.15;
24
18
  /** ...and never on one read, at any coverage. */
25
19
  const MIN_ALLELE_READS = 2;
20
+ /**
21
+ * How far from an allele a read's copy count may fall and still be counted as
22
+ * that allele's, as a fraction of the allele's own size.
23
+ *
24
+ * Proportional rather than fixed because slippage scales with the array: the
25
+ * reads either side of an 89-copy allele scatter further than those either side
26
+ * of an 8-copy one. cuteSV refines a cluster of structural-variant signatures
27
+ * the same way, by a bandwidth taken as a fraction of the cluster's own mean
28
+ * length (Jiang et al., Genome Biol 21, 2020, doi:10.1186/s13059-020-02107-y);
29
+ * its constants are fractions of a length in bases and do not carry over to a
30
+ * count of copies, so this one is measured here instead. At 0.1 no call in the
31
+ * trio moves, merges or is lost, and the reads left out of one drop by three
32
+ * quarters.
33
+ */
34
+ const SHOULDER_SPREAD = 0.1;
35
+ /**
36
+ * ...and how much support such a read may carry, relative to the allele it
37
+ * would join, before it is an allele of its own instead.
38
+ *
39
+ * This is the load-bearing half, and distance alone cannot replace it. At FMR1
40
+ * the mother carries two alleles one copy apart and at HTT a single allele has
41
+ * a shoulder one copy either side, so no bandwidth tells those two apart.
42
+ * Relative support does: a slippage shoulder in the trio runs at a fraction of
43
+ * its allele, and the mother's second allele runs at 87% of her first. The
44
+ * measured shelf is wide — 0.2 leaves reads uncounted, 0.4 starts merging the
45
+ * mother's two alleles into one.
46
+ *
47
+ * That shelf is 21 sample-locus calls in one trio, which is a shelf and not a
48
+ * proof: a locus carrying three real alleles within a copy of each other would
49
+ * defeat the rule, and this trio has none.
50
+ */
51
+ const SHOULDER_SUPPORT = 0.3;
26
52
  /** Each distinct value with how many rows carried it, smallest value first. */
27
53
  export function tally(values) {
28
54
  const counts = new Map();
@@ -34,7 +60,15 @@ export function tally(values) {
34
60
  .sort((a, b) => a.value - b.value);
35
61
  }
36
62
  /**
37
- * The copy counts a sample carries, as the counts enough of its reads agree on.
63
+ * The copy counts a sample carries, each with the reads that fell on it or in
64
+ * its skirt.
65
+ *
66
+ * Reads scatter around an allele — slippage in the molecule, slippage in the
67
+ * aligner — so a rule that reported only exact agreement credited an allele
68
+ * with a fraction of the reads that actually support it, and left the rest
69
+ * looking like disagreement. Counts are gathered strongest first, so an allele
70
+ * is established before anything can be read as its shoulder, and a value joins
71
+ * one only if it is both near it and much weaker than it.
38
72
  *
39
73
  * This is a report of what the reads say, not a genotype call: it does not know
40
74
  * a ploidy, so a homozygote and a haploid locus both come back as one number,
@@ -42,12 +76,42 @@ export function tally(values) {
42
76
  */
43
77
  export function alleleModes(copies) {
44
78
  const floor = Math.max(MIN_ALLELE_READS, MIN_ALLELE_FRACTION * copies.length);
45
- return tally(copies).filter(t => t.reads >= floor);
79
+ const peaks = [];
80
+ for (const t of tally(copies).sort((a, b) => b.reads - a.reads || a.value - b.value)) {
81
+ const distance = (peak) => Math.abs(t.value - peak.value);
82
+ const host = peaks
83
+ .filter(peak => distance(peak) <= Math.max(1, SHOULDER_SPREAD * peak.value) &&
84
+ t.reads <= SHOULDER_SUPPORT * peak.reads)
85
+ .sort((a, b) => distance(a) - distance(b))[0];
86
+ if (host) {
87
+ host.reads += t.reads;
88
+ }
89
+ else {
90
+ peaks.push({ ...t });
91
+ }
92
+ }
93
+ return peaks.filter(p => p.reads >= floor).sort((a, b) => a.value - b.value);
46
94
  }
47
95
  function sampleOfRow(name) {
48
96
  const i = name.indexOf('|');
49
97
  return i < 0 ? undefined : name.slice(0, i);
50
98
  }
99
+ /**
100
+ * Rows are prefixed with the Newick-safe form of their sample's name, so a
101
+ * caller naming the samples it wants reported has to be met there rather than
102
+ * taken at its word. A track called `HG004 (mother)` otherwise matched no row
103
+ * and came back with nought spanning reads and no alleles — which is what a
104
+ * locus nobody sequenced looks like, not what a misspelt name should.
105
+ *
106
+ * The name the caller gave is what gets reported back; only the matching is
107
+ * sanitized.
108
+ */
109
+ function rowsOfSample(copiesByName, sample) {
110
+ const key = newickSafe(sample);
111
+ return [...copiesByName]
112
+ .filter(([name]) => sampleOfRow(name) === key)
113
+ .map(([, n]) => n);
114
+ }
51
115
  function arrayStats(array, plan, samples) {
52
116
  return {
53
117
  start: array.start,
@@ -61,17 +125,17 @@ function arrayStats(array, plan, samples) {
61
125
  : undefined,
62
126
  subject: array === plan.subject,
63
127
  samples: samples.map(sample => {
64
- const copies = [...array.copiesByName]
65
- .filter(([name]) => sampleOfRow(name) === sample)
66
- .map(([, n]) => n);
128
+ const copies = rowsOfSample(array.copiesByName, sample);
67
129
  const modes = alleleModes(copies);
68
- const called = new Set(modes.map(m => m.value));
69
130
  return {
70
131
  sample,
71
132
  spanning: copies.length,
72
133
  modes,
73
134
  copies: tally(copies),
74
- offMode: copies.filter(c => !called.has(c)).length,
135
+ // an allele carries the reads in its skirt as well as those exactly on
136
+ // it, so what is left over is counted off the alleles rather than off
137
+ // the distinct values they were called at
138
+ offMode: copies.length - modes.reduce((a, m) => a + m.reads, 0),
75
139
  };
76
140
  }),
77
141
  };
@@ -1 +1 @@
1
- {"version":3,"file":"repeatStats.js","sourceRoot":"","sources":["../../src/LaunchTView/repeatStats.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OA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AA;YACtC,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,gBAAgB,GAAG,CAAC,CAAA;IACxB,IAAI,YAAY,GAAG,CAAC,CAAA;IACpB,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,YAAY,EAAE,CAAA;QAChB,CAAC;aAAM,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACvB,gBAAgB,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;IACD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACvB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;QACjC,gBAAgB;QAChB,YAAY;QACZ,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAC9B,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CACjD;KACF,CAAA;AACH,CAAC"}
@@ -174,15 +174,17 @@ const RIVAL_SPAN_FRACTION = 0.5;
174
174
  */
175
175
  export function mergeArrays(arrays, gap = 0) {
176
176
  const groups = [];
177
+ // how far right the open group reaches, which is not its last member's end:
178
+ // sorting by start lets a long array be followed by one that ends inside it
179
+ let reach = -Infinity;
177
180
  for (const array of [...arrays].sort((a, b) => a.start - b.start)) {
178
- const last = groups.at(-1);
179
- const end = last ? Math.max(...last.map(a => a.end)) : 0;
180
- if (last && array.start <= end + gap) {
181
- last.push(array);
181
+ if (array.start <= reach + gap) {
182
+ groups.at(-1).push(array);
182
183
  }
183
184
  else {
184
185
  groups.push([array]);
185
186
  }
187
+ reach = Math.max(reach, array.end);
186
188
  }
187
189
  return groups.map(group => {
188
190
  const span = (a) => a.end - a.start;
@@ -1 +1 @@
1
- {"version":3,"file":"repeats.js","sourceRoot":"","sources":["../../src/LaunchTView/repeats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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AAK,CAAC,IAAI;SACjB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -32,6 +32,16 @@ export interface ColumnLayout {
32
32
  */
33
33
  offsets: number[];
34
34
  totalColumns: number;
35
+ /** the array beginning at a position, for the positions one begins at */
36
+ arrayByStart: Map<number, ArrayBlock>;
37
+ /**
38
+ * Ascending, the positions a row cannot be laid out in bulk over: an array
39
+ * block starts here, or some read inserts here. Between two of them every
40
+ * position is one reference column, so that stretch of a row is a slice of
41
+ * the read's own bases rather than a walk over them — which is what keeps
42
+ * rendering proportional to the indels in a region rather than to its width.
43
+ */
44
+ breaks: number[];
35
45
  }
36
46
  /**
37
47
  * Each reference position contributes its insertion columns (widest across all
@@ -44,7 +54,9 @@ export declare function buildColumnLayout(start: number, end: number, insWidths:
44
54
  * Lays a single row out across the whole region. Rows are typically a tiny
45
55
  * fraction of the region, so the columns on either side are filled in one shot
46
56
  * from the offsets rather than walked position by position — which works over
47
- * array blocks too, since the offsets already carry their width.
57
+ * array blocks too, since the offsets already carry their width. Inside its own
58
+ * span a row is walked only at the layout's breaks, and copied straight out of
59
+ * `refChars` between them.
48
60
  */
49
61
  export declare function renderRow(read: ReadLayout, layout: ColumnLayout): string;
50
62
  /**