jbrowse-plugin-graphgenomeviewer 7.1.11 → 7.1.13
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.
- package/dist/chunks/GbzBaseSyntenyAdapter-NB6WBBZH.js +2 -0
- package/dist/chunks/GbzBaseSyntenyAdapter-NB6WBBZH.js.map +7 -0
- package/dist/chunks/WalkTabixSyntenyAdapter-WBHOZLAN.js +2 -0
- package/dist/chunks/WalkTabixSyntenyAdapter-WBHOZLAN.js.map +7 -0
- package/dist/chunks/chunk-JLGPQO5L.js +4 -0
- package/dist/chunks/{chunk-U4U5ZOCH.js.map → chunk-JLGPQO5L.js.map} +4 -4
- package/dist/chunks/{chunk-OBQFV4NL.js → chunk-LXCMWL7B.js} +2 -2
- package/dist/chunks/chunk-M2D7NUOY.js +2 -0
- package/dist/chunks/{chunk-T4HOC6O3.js.map → chunk-M2D7NUOY.js.map} +4 -4
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +3 -3
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +2 -2
- package/package.json +1 -1
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +2 -4
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +9 -8
- package/src/RgfaTabixAdapter/test_data/walks3_lanepairs.GRCh38.walks.bed.gz +0 -0
- package/src/RgfaTabixAdapter/test_data/walks3_lanepairs.GRCh38.walks.bed.gz.tbi +0 -0
- package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +128 -3
- package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +4 -10
- package/src/WalkTabixSyntenyAdapter/walkLanes.ts +60 -0
- package/src/synteny/clipFeatureToRegion.test.ts +23 -0
- package/src/synteny/clipFeatureToRegion.ts +4 -1
- package/src/synteny/laneZoomNotice.test.ts +55 -0
- package/src/synteny/laneZoomNotice.ts +34 -0
- package/src/version.ts +1 -1
- package/dist/chunks/GbzBaseSyntenyAdapter-2MA3I6BM.js +0 -2
- package/dist/chunks/GbzBaseSyntenyAdapter-2MA3I6BM.js.map +0 -7
- package/dist/chunks/WalkTabixSyntenyAdapter-AIC3W7FL.js +0 -2
- package/dist/chunks/WalkTabixSyntenyAdapter-AIC3W7FL.js.map +0 -7
- package/dist/chunks/chunk-PJ43KEV6.js +0 -2
- package/dist/chunks/chunk-PJ43KEV6.js.map +0 -7
- package/dist/chunks/chunk-T4HOC6O3.js +0 -2
- package/dist/chunks/chunk-U4U5ZOCH.js +0 -4
- /package/dist/chunks/{chunk-OBQFV4NL.js.map → chunk-LXCMWL7B.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jbrowse-plugin-graphgenomeviewer",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.13",
|
|
4
4
|
"description": "JBrowse 2 graph genome (pangenome) view: rGFA reference-anchored layouts, the Bandage force-directed engine, and haplotype lanes read from a gbz-base database",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -366,15 +366,13 @@ test('the graph lists its haplotypes with their contigs, and a fetch can be narr
|
|
|
366
366
|
)
|
|
367
367
|
})
|
|
368
368
|
|
|
369
|
-
test('the node limit fails lanes
|
|
369
|
+
test('the node limit fails lanes as a zoom-in notice naming how far to zoom, and a graph cut naming a span that fits', async () => {
|
|
370
370
|
const adapter = makeAdapter({ nodeLimit: 2 })
|
|
371
371
|
const lanes: unknown = await feats(adapter, window).catch((e: unknown) => e)
|
|
372
372
|
expect(lanes).toMatchObject({
|
|
373
373
|
name: 'NodeLimitError',
|
|
374
374
|
regionTooLarge: true,
|
|
375
|
-
message: expect.stringMatching(
|
|
376
|
-
/^Zoom in to about [\d.]+[KM]?bp to see lanes$/,
|
|
377
|
-
),
|
|
375
|
+
message: expect.stringMatching(/^Zoom in about [\d.]+× to see lanes$/),
|
|
378
376
|
})
|
|
379
377
|
const graph: unknown = await adapter
|
|
380
378
|
.getSubgraph(window)
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
lanePairsStatus,
|
|
32
32
|
requestedPairs,
|
|
33
33
|
} from '../synteny/lanePairs.ts'
|
|
34
|
+
import { laneZoomNotice } from '../synteny/laneZoomNotice.ts'
|
|
34
35
|
import { matchFeature } from '../synteny/matchFeature.ts'
|
|
35
36
|
|
|
36
37
|
import type { GbzBaseSyntenyAdapterConfig } from './configSchema.ts'
|
|
@@ -223,6 +224,12 @@ function zoomInNotice(error: unknown, what: string) {
|
|
|
223
224
|
return error
|
|
224
225
|
}
|
|
225
226
|
|
|
227
|
+
const laneLimitNotice = (error: unknown, nodeLimit: number, windowBp: number) =>
|
|
228
|
+
laneZoomNotice(
|
|
229
|
+
zoomInNotice(nodeLimitError(error, nodeLimit, windowBp) ?? error, 'lanes'),
|
|
230
|
+
windowBp,
|
|
231
|
+
)
|
|
232
|
+
|
|
226
233
|
// gbz-base reads whole bp; a view asks at fractional ones
|
|
227
234
|
const wholeBp = (region: Region) => ({
|
|
228
235
|
...region,
|
|
@@ -489,10 +496,7 @@ export default class GbzBaseSyntenyAdapter extends ComparativeAdapterBase<GbzBas
|
|
|
489
496
|
keep,
|
|
490
497
|
})
|
|
491
498
|
.catch((error: unknown) => {
|
|
492
|
-
throw
|
|
493
|
-
nodeLimitError(error, nodeLimit, end - start) ?? error,
|
|
494
|
-
'lanes',
|
|
495
|
-
)
|
|
499
|
+
throw laneLimitNotice(error, nodeLimit, end - start)
|
|
496
500
|
}),
|
|
497
501
|
)
|
|
498
502
|
: []
|
|
@@ -562,10 +566,7 @@ export default class GbzBaseSyntenyAdapter extends ComparativeAdapterBase<GbzBas
|
|
|
562
566
|
// a cut past the node limit for the wider context keeps the first one
|
|
563
567
|
const bridged = async (path: PathQuery) => {
|
|
564
568
|
const subgraphs = await cut(path, baseContext).catch((error: unknown) => {
|
|
565
|
-
throw
|
|
566
|
-
nodeLimitError(error, nodeLimit, end - start) ?? error,
|
|
567
|
-
'lanes',
|
|
568
|
-
)
|
|
569
|
+
throw laneLimitNotice(error, nodeLimit, end - start)
|
|
569
570
|
})
|
|
570
571
|
const gap = widestWalkGap(subgraphs, kept)
|
|
571
572
|
const context = Math.ceil(gap / 2) + 2000
|
|
@@ -9,10 +9,15 @@ import { toArray } from 'rxjs/operators'
|
|
|
9
9
|
import Adapter from './WalkTabixSyntenyAdapter.ts'
|
|
10
10
|
import configSchema from './configSchema.ts'
|
|
11
11
|
import WalkTabixSyntenyAdapterF from './index.ts'
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
bubblesAsMismatches,
|
|
14
|
+
referenceAligner,
|
|
15
|
+
walkAligner,
|
|
16
|
+
} from './walkLanes.ts'
|
|
13
17
|
import { walkRowsOf } from '../RgfaTabixAdapter/walkRowRuns.ts'
|
|
14
18
|
import { PairTargetError } from '../synteny/lanePairs.ts'
|
|
15
19
|
|
|
20
|
+
import type { PairChain } from '@gmod/gbz-base/pairAlignment'
|
|
16
21
|
import type { SyntenyMate } from '@jbrowse/synteny-core'
|
|
17
22
|
|
|
18
23
|
// Four walks over a 3.6 kb reference of six 600 bp nodes, in 1 kb chunks
|
|
@@ -166,6 +171,66 @@ test('a batch of lane pairs answers each pair what it answers alone', async () =
|
|
|
166
171
|
expect(batch).toHaveLength(2)
|
|
167
172
|
})
|
|
168
173
|
|
|
174
|
+
// walks3_lanepairs, a 5.5 kb reference of 2 kb flanks around three 500 bp
|
|
175
|
+
// nodes, in 1 kb chunks:
|
|
176
|
+
// W GRCh38 0 chr1 >1>2>3>4>5
|
|
177
|
+
// W HG002 1 chr1 >1>2>3>4>5
|
|
178
|
+
// W HG002 2 chr1 >1<4<3<2>5 the middle three inverted
|
|
179
|
+
// W HG00097 1 chr1 >1>2>6>2>6>2>3>4>5 2 three times, 6 a 30 bp spacer
|
|
180
|
+
test('a lane pair matches through a copy-number array, and draws an inversion between the lanes as a reverse-strand record', async () => {
|
|
181
|
+
const found = await firstValueFrom(
|
|
182
|
+
makeAdapter({}, 'walks3_lanepairs')
|
|
183
|
+
.getFeatures(
|
|
184
|
+
{ ...window, end: 5500 },
|
|
185
|
+
{
|
|
186
|
+
lanePairs: [
|
|
187
|
+
{ queryAssemblyName: 'HG002#1', targetAssemblyName: 'HG002#2' },
|
|
188
|
+
{ queryAssemblyName: 'HG002#1', targetAssemblyName: 'HG00097#1' },
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
)
|
|
192
|
+
.pipe(toArray()),
|
|
193
|
+
)
|
|
194
|
+
expect(
|
|
195
|
+
found.map(f => ({
|
|
196
|
+
...summary(f),
|
|
197
|
+
strand: f.get('strand'),
|
|
198
|
+
matches: f.get('numMatches'),
|
|
199
|
+
})),
|
|
200
|
+
).toEqual([
|
|
201
|
+
{
|
|
202
|
+
lane: 'HG002#2',
|
|
203
|
+
refName: 'chr1',
|
|
204
|
+
start: 0,
|
|
205
|
+
end: 5500,
|
|
206
|
+
mate: 'chr1:0-5500',
|
|
207
|
+
cigar: '2000=1500I1500D2000=',
|
|
208
|
+
strand: 1,
|
|
209
|
+
matches: 4000,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
lane: 'HG002#2',
|
|
213
|
+
refName: 'chr1',
|
|
214
|
+
start: 2000,
|
|
215
|
+
end: 3500,
|
|
216
|
+
mate: 'chr1:2000-3500',
|
|
217
|
+
cigar: '1500=',
|
|
218
|
+
strand: -1,
|
|
219
|
+
matches: 1500,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
lane: 'HG00097#1',
|
|
223
|
+
refName: 'chr1',
|
|
224
|
+
start: 0,
|
|
225
|
+
end: 5500,
|
|
226
|
+
mate: 'chr1:0-6560',
|
|
227
|
+
cigar: '2500=1060I3000=',
|
|
228
|
+
strand: 1,
|
|
229
|
+
matches: 5500,
|
|
230
|
+
},
|
|
231
|
+
])
|
|
232
|
+
})
|
|
233
|
+
|
|
169
234
|
test('a lane pair without its target lane is refused', async () => {
|
|
170
235
|
await expect(
|
|
171
236
|
feats(makeAdapter(), { queryAssemblyName: 'HG002#1' }),
|
|
@@ -228,12 +293,12 @@ test('getSubgraph cuts the window with the reference walk first', async () => {
|
|
|
228
293
|
expect(walks).toEqual(['GRCh38#0#chr1', 'HG002#1#chr1'])
|
|
229
294
|
})
|
|
230
295
|
|
|
231
|
-
test('a window past the step budget fails as a zoom-in notice for lanes', async () => {
|
|
296
|
+
test('a window past the step budget fails as a zoom-in notice for lanes naming how far to zoom', async () => {
|
|
232
297
|
await expect(
|
|
233
298
|
feats(makeAdapter({ walkStepBudget: 20 })),
|
|
234
299
|
).rejects.toMatchObject({
|
|
235
300
|
name: 'NodeLimitError',
|
|
236
|
-
message: expect.stringMatching(
|
|
301
|
+
message: expect.stringMatching(/^Zoom in about [\d.]+×.* to see lanes$/),
|
|
237
302
|
})
|
|
238
303
|
})
|
|
239
304
|
|
|
@@ -387,6 +452,66 @@ test('a haplotype running against the reference is a reverse-strand record', ()
|
|
|
387
452
|
expect(cigar(chain!.edits)).toBe('1000=30I500=')
|
|
388
453
|
})
|
|
389
454
|
|
|
455
|
+
// Two lanes over 2 kb flanks and three 500 bp nodes, the second lane running
|
|
456
|
+
// the middle three backwards: >1>2>3>4>5 against >1<4<3<2>5
|
|
457
|
+
const inversionNodes = new Map(
|
|
458
|
+
[1, 2, 3, 4, 5].map(id => [
|
|
459
|
+
id,
|
|
460
|
+
{
|
|
461
|
+
refName: 'ref',
|
|
462
|
+
start: id * 10_000,
|
|
463
|
+
end: id * 10_000 + (id === 1 || id === 5 ? 2000 : 500),
|
|
464
|
+
rank: 0,
|
|
465
|
+
onWindow: true,
|
|
466
|
+
},
|
|
467
|
+
]),
|
|
468
|
+
)
|
|
469
|
+
const upperLane = fragment('HG002#1#chr1', [
|
|
470
|
+
[1, 0],
|
|
471
|
+
[2, 0],
|
|
472
|
+
[3, 0],
|
|
473
|
+
[4, 0],
|
|
474
|
+
[5, 0],
|
|
475
|
+
])
|
|
476
|
+
const invertedLane = fragment('HG002#2#chr1', [
|
|
477
|
+
[1, 0],
|
|
478
|
+
[4, 1],
|
|
479
|
+
[3, 1],
|
|
480
|
+
[2, 1],
|
|
481
|
+
[5, 0],
|
|
482
|
+
])
|
|
483
|
+
const drawn = (chains: PairChain[]) =>
|
|
484
|
+
chains.map(
|
|
485
|
+
({ queryStart, queryEnd, targetStart, targetEnd, strand, edits }) => ({
|
|
486
|
+
query: `${queryStart}-${queryEnd}`,
|
|
487
|
+
target: `${targetStart}-${targetEnd}`,
|
|
488
|
+
strand,
|
|
489
|
+
cigar: cigar(edits),
|
|
490
|
+
}),
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
test('an inversion between two lanes is a reverse-strand record of its own when chained, and an insertion beside a deletion in the subsequence', () => {
|
|
494
|
+
expect(drawn(walkAligner(inversionNodes)(invertedLane, upperLane))).toEqual([
|
|
495
|
+
{
|
|
496
|
+
query: '0-5500',
|
|
497
|
+
target: '0-5500',
|
|
498
|
+
strand: '+',
|
|
499
|
+
cigar: '2000=1500I1500D2000=',
|
|
500
|
+
},
|
|
501
|
+
{ query: '2000-3500', target: '2000-3500', strand: '-', cigar: '1500=' },
|
|
502
|
+
])
|
|
503
|
+
expect(
|
|
504
|
+
drawn(referenceAligner(inversionNodes)(invertedLane, upperLane)),
|
|
505
|
+
).toEqual([
|
|
506
|
+
{
|
|
507
|
+
query: '0-5500',
|
|
508
|
+
target: '0-5500',
|
|
509
|
+
strand: '+',
|
|
510
|
+
cigar: '2000=1500I1500D2000=',
|
|
511
|
+
},
|
|
512
|
+
])
|
|
513
|
+
})
|
|
514
|
+
|
|
390
515
|
test.each([
|
|
391
516
|
['the whole reference', window],
|
|
392
517
|
['a window inside it', { ...window, start: 1300, end: 2300 }],
|
|
@@ -10,9 +10,8 @@ import { updateStatus } from '@jbrowse/core/util'
|
|
|
10
10
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
11
11
|
import { walksKept } from '@jbrowse/graph-walks'
|
|
12
12
|
|
|
13
|
-
import { chainFeature,
|
|
13
|
+
import { chainFeature, lanePairAligner, referenceAligner } from './walkLanes.ts'
|
|
14
14
|
import { WalkIndex } from '../RgfaTabixAdapter/walkReader.ts'
|
|
15
|
-
import { isNodeLimitError } from '../nodeLimitError.ts'
|
|
16
15
|
import { PanSNRefNames, openTabixSlot } from '../panSNTabix.ts'
|
|
17
16
|
import { ComparativeAdapterBase } from '../synteny/ComparativeAdapterBase.ts'
|
|
18
17
|
import {
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
lanePairsStatus,
|
|
21
20
|
requestedPairs,
|
|
22
21
|
} from '../synteny/lanePairs.ts'
|
|
22
|
+
import { laneZoomNotice } from '../synteny/laneZoomNotice.ts'
|
|
23
23
|
|
|
24
24
|
import type { WalkTabixSyntenyAdapterConfig } from './configSchema.ts'
|
|
25
25
|
import type { SubgraphAdapterOptions } from '../GetSubgraph.ts'
|
|
@@ -128,13 +128,7 @@ export default class WalkTabixSyntenyAdapter extends ComparativeAdapterBase<Walk
|
|
|
128
128
|
links: false,
|
|
129
129
|
})
|
|
130
130
|
.catch((error: unknown) => {
|
|
131
|
-
|
|
132
|
-
error.message = error.message.replace(
|
|
133
|
-
'to see the graph',
|
|
134
|
-
'to see lanes',
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
throw error
|
|
131
|
+
throw laneZoomNotice(error, region.end - region.start)
|
|
138
132
|
}),
|
|
139
133
|
)
|
|
140
134
|
}
|
|
@@ -228,7 +222,7 @@ export default class WalkTabixSyntenyAdapter extends ComparativeAdapterBase<Walk
|
|
|
228
222
|
opts,
|
|
229
223
|
lanePairsStatus(pairs),
|
|
230
224
|
)
|
|
231
|
-
const align =
|
|
225
|
+
const align = lanePairAligner(graph.nodes)
|
|
232
226
|
const walksOf = (prefix: string) =>
|
|
233
227
|
fragments.filter(f => panSNMatchesPrefix(f.name, prefix))
|
|
234
228
|
return sides.flatMap(({ pair, featurePrefix, matePrefix }) =>
|
|
@@ -156,6 +156,66 @@ export function referenceAligner(nodes: Map<number, WalkNode>) {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
// Each node a walk visits once, with the direction it passes it
|
|
160
|
+
function singleVisits(fragment: WalkFragment) {
|
|
161
|
+
const rev = new Map<number, number>()
|
|
162
|
+
const twice = new Set<number>()
|
|
163
|
+
fragment.ids.forEach((id, i) => {
|
|
164
|
+
if (rev.has(id)) {
|
|
165
|
+
twice.add(id)
|
|
166
|
+
} else {
|
|
167
|
+
rev.set(id, fragment.rev[i]!)
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
for (const id of twice) {
|
|
171
|
+
rev.delete(id)
|
|
172
|
+
}
|
|
173
|
+
return rev
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Aligns one lane's walk fragment to another's. The weighted subsequence
|
|
178
|
+
* (`referenceAligner`) is the fast route and matches through copy-number
|
|
179
|
+
* arrays, but it reads one direction per pair, so an inversion between the
|
|
180
|
+
* lanes comes out as an insertion beside a deletion. A pair sharing 100 bp
|
|
181
|
+
* (MIN_MATCH_BP) or more of singly visited nodes in each direction goes to
|
|
182
|
+
* pair chaining (`walkAligner`) instead, which answers the inverted stretch as
|
|
183
|
+
* a reverse-strand record of its own. Chaining leaves out every node a walk
|
|
184
|
+
* passes twice, so counting singly visited nodes misses no inversion it could
|
|
185
|
+
* draw.
|
|
186
|
+
*/
|
|
187
|
+
export function lanePairAligner(nodes: Map<number, WalkNode>) {
|
|
188
|
+
const subsequence = referenceAligner(nodes)
|
|
189
|
+
const chained = walkAligner(nodes)
|
|
190
|
+
const visits = new Map<WalkFragment, Map<number, number>>()
|
|
191
|
+
const visitsOf = (fragment: WalkFragment) => {
|
|
192
|
+
let found = visits.get(fragment)
|
|
193
|
+
if (found === undefined) {
|
|
194
|
+
found = singleVisits(fragment)
|
|
195
|
+
visits.set(fragment, found)
|
|
196
|
+
}
|
|
197
|
+
return found
|
|
198
|
+
}
|
|
199
|
+
const inverted = (query: WalkFragment, target: WalkFragment) => {
|
|
200
|
+
const theirs = visitsOf(target)
|
|
201
|
+
let same = 0
|
|
202
|
+
let opposite = 0
|
|
203
|
+
for (const [id, rev] of visitsOf(query)) {
|
|
204
|
+
const other = theirs.get(id)
|
|
205
|
+
if (other === rev) {
|
|
206
|
+
same += nodeLength(nodes, id)
|
|
207
|
+
} else if (other !== undefined) {
|
|
208
|
+
opposite += nodeLength(nodes, id)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return same >= MIN_MATCH_BP && opposite >= MIN_MATCH_BP
|
|
212
|
+
}
|
|
213
|
+
return (query: WalkFragment, target: WalkFragment) =>
|
|
214
|
+
inverted(query, target)
|
|
215
|
+
? chained(query, target)
|
|
216
|
+
: subsequence(query, target)
|
|
217
|
+
}
|
|
218
|
+
|
|
159
219
|
/**
|
|
160
220
|
* One record of a walk aligned to another, with its short balanced bubbles as
|
|
161
221
|
* mismatches
|
|
@@ -366,3 +366,26 @@ test('the two regions are fetched at once and emitted in region order', async ()
|
|
|
366
366
|
expect(adapter.completed).toEqual([1, 0])
|
|
367
367
|
expect(features.map(f => f.id())).toEqual(['region0', 'region1'])
|
|
368
368
|
})
|
|
369
|
+
|
|
370
|
+
test('the runs of one record share its recordId, and two records do not', () => {
|
|
371
|
+
const runs = clipFeatureToRegion(
|
|
372
|
+
record({ CIGAR: '100M50D100M50I150M' }),
|
|
373
|
+
{ start: 1000, end: 1400 },
|
|
374
|
+
40,
|
|
375
|
+
)
|
|
376
|
+
expect(runs.length).toBeGreaterThan(1)
|
|
377
|
+
expect(new Set(runs.map(r => r.get('recordId')))).toEqual(new Set(['r1']))
|
|
378
|
+
const other = clipFeatureToRegion(record({ uniqueId: 'r2', CIGAR }), {
|
|
379
|
+
start: 1000,
|
|
380
|
+
end: 1400,
|
|
381
|
+
})[0]!
|
|
382
|
+
expect(other.get('recordId')).toBe('r2')
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
test('a recordId the source already carries stays', () => {
|
|
386
|
+
const [piece] = clipFeatureToRegion(record({ recordId: 919 }), {
|
|
387
|
+
start: 1000,
|
|
388
|
+
end: 1400,
|
|
389
|
+
})
|
|
390
|
+
expect(piece!.get('recordId')).toBe(919)
|
|
391
|
+
})
|
|
@@ -125,6 +125,7 @@ function clippedFeature(
|
|
|
125
125
|
const data: SimpleFeatureSerialized = {
|
|
126
126
|
...source,
|
|
127
127
|
uniqueId: `${feature.id()}${suffix}`,
|
|
128
|
+
recordId: source.recordId ?? feature.id(),
|
|
128
129
|
start: clipped.start,
|
|
129
130
|
end: clipped.end,
|
|
130
131
|
mate: { ...mate, start: clipped.mateStart, end: clipped.mateEnd },
|
|
@@ -146,7 +147,9 @@ function clippedFeature(
|
|
|
146
147
|
* the record misses the window, one otherwise, and with `splitAtGapBp` one per
|
|
147
148
|
* gap-free run of its alignment, numbered after the window suffix so each run
|
|
148
149
|
* is its own feature and its own `syntenyId` group. A piece keeps every field
|
|
149
|
-
* of the record except the alignment strings
|
|
150
|
+
* of the record except the alignment strings, and a `recordId` that names the
|
|
151
|
+
* record the piece was cut from, so a display can tell two runs of one record
|
|
152
|
+
* from two records; `keepAlignment` hands back its
|
|
150
153
|
* own stretch of them as packed ops in `alignmentOps`. A feature with no
|
|
151
154
|
* `mate` is not a pairwise record and passes through whole.
|
|
152
155
|
*
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { keptStepsError } from '@jbrowse/graph-walks'
|
|
2
|
+
|
|
3
|
+
import { laneZoomFold, laneZoomNotice } from './laneZoomNotice.ts'
|
|
4
|
+
|
|
5
|
+
const BUDGET = 4_000_000
|
|
6
|
+
|
|
7
|
+
// A lane fetch over `fetchBp` keeping steps at a density whose fitting span
|
|
8
|
+
// is `fitsBp`, refused as @jbrowse/graph-walks refuses it
|
|
9
|
+
function refusal(fetchBp: number, fitsBp: number) {
|
|
10
|
+
const kept = Math.round((BUDGET * fetchBp) / fitsBp)
|
|
11
|
+
const fragment = { ids: new Int32Array(kept) }
|
|
12
|
+
return keptStepsError(
|
|
13
|
+
[fragment] as never,
|
|
14
|
+
BUDGET,
|
|
15
|
+
{ start: 0, end: fetchBp },
|
|
16
|
+
false,
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// On a 1,000 px canvas the display fetches the 800 px blocks the view touches:
|
|
21
|
+
// a 5 Mb view three 4 Mb blocks, a 500 kb view three 400 kb ones
|
|
22
|
+
test.each([
|
|
23
|
+
['5 Mb', 12_000_000, 7_290_000, '7.29Mbp', '1.7'],
|
|
24
|
+
['500 kb', 1_200_000, 762_000, '762Kbp', '1.6'],
|
|
25
|
+
])(
|
|
26
|
+
'a %s view over the step budget is told how far to zoom in, not a span wider than it',
|
|
27
|
+
(_, fetchBp, fitsBp, span, fold) => {
|
|
28
|
+
const error = refusal(fetchBp, fitsBp)!
|
|
29
|
+
expect(error.message).toBe(
|
|
30
|
+
`Zoom in to about ${span}, or choose fewer haplotypes, to see the graph`,
|
|
31
|
+
)
|
|
32
|
+
expect(laneZoomNotice(error, fetchBp)).toMatchObject({
|
|
33
|
+
name: 'NodeLimitError',
|
|
34
|
+
message: `Zoom in about ${fold}×, or choose fewer haplotypes, to see lanes`,
|
|
35
|
+
})
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
test('the fold rounds up, to a tenth below 10 and a whole number above, and asks for at least 1.1', () => {
|
|
40
|
+
expect(laneZoomFold(1_010, 1_000)).toBe(1.1)
|
|
41
|
+
expect(laneZoomFold(1_100, 1_000)).toBe(1.1)
|
|
42
|
+
expect(laneZoomFold(9_910, 1_000)).toBe(10)
|
|
43
|
+
expect(laneZoomFold(32_100, 1_000)).toBe(33)
|
|
44
|
+
expect(laneZoomFold(1_000, 1_200)).toBe(1.1)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('a refusal naming no span keeps its message', () => {
|
|
48
|
+
const error = Object.assign(new Error('Too many haplotype steps here'), {
|
|
49
|
+
name: 'NodeLimitError',
|
|
50
|
+
fitsBp: 1,
|
|
51
|
+
})
|
|
52
|
+
expect(laneZoomNotice(error, 1000)).toMatchObject({
|
|
53
|
+
message: 'Too many haplotype steps here',
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isNodeLimitError } from '../nodeLimitError.ts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How many times over the view must zoom in for a lane fetch of `windowBp`
|
|
5
|
+
* to fit, where `fitsBp` is the widest fetch that would: rounded up to a
|
|
6
|
+
* tenth, to a whole number past 10, and never under 1.1.
|
|
7
|
+
*/
|
|
8
|
+
export function laneZoomFold(windowBp: number, fitsBp: number) {
|
|
9
|
+
const fits = Math.max(1, fitsBp)
|
|
10
|
+
return windowBp >= 10 * fits
|
|
11
|
+
? Math.ceil(windowBp / fits)
|
|
12
|
+
: Math.max(11, Math.ceil((10 * windowBp) / fits)) / 10
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A budget refusal for lanes, naming how far to zoom rather than a span. The
|
|
17
|
+
* display fetches lanes over the 800 px static blocks its view touches, up to
|
|
18
|
+
* a block past each edge, and never tells the adapter the view, so a span that
|
|
19
|
+
* fits the fetch can be wider than the view. The fetch narrows with the view,
|
|
20
|
+
* so a fold holds for both.
|
|
21
|
+
*/
|
|
22
|
+
export function laneZoomNotice(error: unknown, windowBp: number) {
|
|
23
|
+
if (isNodeLimitError(error) && error instanceof Error) {
|
|
24
|
+
const { fitsBp } = error as { fitsBp?: unknown }
|
|
25
|
+
error.message = error.message.replace('to see the graph', 'to see lanes')
|
|
26
|
+
if (typeof fitsBp === 'number') {
|
|
27
|
+
error.message = error.message.replace(
|
|
28
|
+
/^Zoom in to about [\d.,]*\d[KM]?bp/,
|
|
29
|
+
`Zoom in about ${laneZoomFold(windowBp, fitsBp)}×`,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return error
|
|
34
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '7.1.
|
|
1
|
+
export const version = '7.1.13'
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as ae,b as re,c as de,d as oe,e as ie,f as H,g as se}from"./chunk-U4U5ZOCH.js";import{a as te}from"./chunk-KOB7YIMR.js";import{a as j,b as W,c as Z,d as u,e as M,f as $,g as U,h as k,i as z,k as X}from"./chunk-OBQFV4NL.js";import"./chunk-O7Y7LYN6.js";import{b as E,c as O}from"./chunk-N4WBX2OS.js";import"./chunk-BWP3XYKD.js";import"./chunk-T4HOC6O3.js";import{a as ne}from"./chunk-PFAHNHMM.js";import"./chunk-VDHDEEMF.js";import{a as V,c as L,m as ee}from"./chunk-EDSIYH4H.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{g as F,h as P,i as C}from"./chunk-GUXZESDR.js";import"./chunk-T4R3ZVEM.js";import{d as G,g as Y,h as J,i as K}from"./chunk-IKJZPPOA.js";import"./chunk-7WIBGKBU.js";import{a as N}from"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{e as D,o as I}from"./chunk-TENPGIPX.js";function A(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function he(n){return J(n)&&A(Y(n))?K(n,i=>A(i)):void 0}function ue(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function ce(n,i){let t=he(n);if(!t)return{};try{return await N(t,i).stat(),{location:t}}catch(e){return ue(e)?{}:{unreadable:String(e)}}}var ge=5e3,ye=50*2**20,q=class extends Error{constructor(t){super(`this GAF is ${(t/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function be(n,i){if(n.length<=i)return n;let t=n.length/i;return Array.from({length:i},(e,a)=>n[Math.floor(a*t)])}var pe=(n,i)=>n.path.some(t=>i.has(t.name)),v=class{constructor(i,t){this.file=i;this.tabix=t;this.whole=L({setup:async({signal:i})=>{let{size:t}=await this.file.stat();if(t>ye)throw new q(t);let e=await this.file.readFile({signal:i}),a=new TextDecoder().decode(e[0]===31&&e[1]===139?await V(e):e);return O(a)}})}async readIndexed(i,t,e){let a=1/0,r=-1/0;for(let s of t){let c=Number(s);Number.isInteger(c)&&(a=Math.min(a,c),r=Math.max(r,c))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:e,lineCallback:s=>{let c=E(s);c&&pe(c,t)&&o.push(c)}}),o}async readsOver(i,{signal:t}={}){let e=this.tabix?await this.readIndexed(this.tabix,i,t):(await this.whole({signal:t})).filter(a=>pe(a,i));return{records:be(e,ge),total:e.length}}};var B=class extends Error{constructor(t){super(t===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${t}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},_=class extends Error{constructor(t,e){super(`the graph is cut on its reference, ${e}; a window on ${t} has no reference coordinates to cut at. Open the graph from a ${e} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function we(n,i){return`${u(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function xe({alignment:n,assemblyName:i,refName:t,lane:e}){let{refStart:a,refEnd:r,strand:o,cigar:s}=n;if(!(r<=a)){let{name:c,hapStart:p,hapEnd:l}=n,d=we(c,n),g={uniqueId:d,assemblyName:i,refName:t,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:s,syntenyId:d,mate:{refName:c.contig,start:p,end:l,assemblyName:e}};return new ae(g)}}function Se({pair:n,lane:i,mateLane:t}){return se({target:{name:`${u(n.target)}#${n.target.contig}`,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd},query:{name:`${u(n.query)}#${n.query.contig}`,assemblyName:t,refName:n.query.contig,start:n.queryStart,end:n.queryEnd},strand:n.strand,cigar:n.cigar,matches:n.matches,columns:n.columns})}var Pe=12e4;function Ne(n,i){let t=new Map;for(let a of n)for(let{name:r,start:o,end:s}of a.walkSpans()){let c=u(r);if(i.has(c)){let p=`${c}#${r.contig}`,l=t.get(p);l?l.push([o,s]):t.set(p,[[o,s]])}}let e=0;for(let a of t.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Pe&&(e=Math.max(e,o))}}return e}function T(n,i){return n instanceof Z&&(n.message=`Zoom in to about ${D(n.fitsBp)} to see ${i}`),n}var le=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),Q=class extends re{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let t=this.getConf("gbzDbLocation"),e=this.getConf("haplotypeIndexLocation"),a=G(e)?{location:e}:await ce(t,this.pluginManager),r=a.location,o=await W.open({source:N(t,this.pluginManager),haplotypeIndex:r?N(r,this.pluginManager):void 0}),s=this.getConf("assemblyNames")[0];if(s===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let c=await $(o),p=U({configured:this.getConf("referenceSample"),anchorPrefix:P(this,s),referenceSamples:c});return{db:o,anchor:s,referenceSample:p,referenceSamples:c,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let t=this.getConf("readsLocation"),e=this.getConf(["readsIndex","location"]);return G(t)?new v(N(t,this.pluginManager),G(e)?ee(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(t,e){let{db:a,referenceSample:r}=await this.graph(e);return k(a,r,t)}async getHaplotypes(t={}){let{db:e,referenceSamples:a}=await this.graph(t),r=new Map;for(let o of await e.paths()){let s=u(o.name),c=r.get(s);c?c.contigs.includes(o.name.contig)||c.contigs.push(o.name.contig):r.set(s,{prefix:s,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(t={}){let{anchor:e,referenceSample:a}=await this.graph(t),r=C(this),o=[];for(let s of await this.getHaplotypes(t))s.sample!==a&&o.push({name:H(r,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:e,lanes:o}}async getRefNames(t={}){let{db:e,anchor:a,referenceSample:r}=await this.graph(t),{assemblyName:o}=t,s=o===a?void 0:P(this,o),c=(await e.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:F(u(p.name),s)).map(p=>p.name.contig);return[...new Set(c)]}keepPredicate(t,e){let a=t===void 0||t.length===0?void 0:t.map(r=>P(this,r));return a===void 0&&e===void 0?void 0:r=>M(r,a)&&(e===void 0||F(u(r),e))}async getSubgraph(t,e={}){let{signal:a}=e,{db:r,anchor:o,referenceSample:s,unreadableIndex:c}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:d,end:g}=le(t);if(p!==o)throw new _(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${s} has no indexed path ${l} in this graph`);let w=this.keepPredicate(e.haplotypes);if(w!==void 0&&!r.hasHaplotypeIndex)throw new B(c);let f=await X(r,y,d,g,{context:this.getConf("context"),snarls:e.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:e.signal,keep:w}).catch(x=>{throw T(x,"the graph")});return typeof f=="string"?f:ne(f,{start:d,end:g},e.walkRows)}async getReads(t,e={}){let a=await this.gaf(e);return a?a.readsOver(new Set(t),e):{records:[],total:0}}async laneHaplotypes(t,e){let a=P(this,t);return(await this.getHaplotypes(e)).filter(r=>F(r.prefix,a))}async anchorFeatures(t,e){let{db:a}=await this.graph(e),{assemblyName:r,refName:o,start:s,end:c}=t,p=P(this,e.targetAssemblyName),l=C(this),d=this.keepPredicate(e.haplotypes,p),g=await this.referenceQuery(o,e),y=this.getConf("nodeLimit");return(g?await I(`Reading graph ${o}:${s.toLocaleString()}-${c.toLocaleString()}`,e.statusCallback,()=>a.getAlignments({path:g,start:s,end:c,context:this.getConf("context"),haplotypes:"all",limit:y,signal:e.signal,keep:d}).catch(f=>{throw T(z(f,y,c-s)??f,"lanes")})):[]).flatMap(f=>{let x=f.resolved?xe({alignment:f,assemblyName:r,refName:o,lane:H(l,u(f.name))}):void 0;return x===void 0?[]:[x]})}async pairFeatures(t,e,a){let{db:r}=await this.graph(a),{refName:o,start:s,end:c}=t,l=(await Promise.all(e.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),d=new Set(l.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),w=this.getConf("context"),f=(m,h)=>r.getSubgraphs({path:m,start:s,end:c,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:S=>d.has(u(S))}),x=async m=>{let h=await f(m,w).catch(b=>{throw T(z(b,y,c-s)??b,"lanes")}),S=Ne(h,d),R=Math.ceil(S/2)+2e3;return S>0&&R>w?f(m,R).catch(b=>{if(b instanceof j)return h;throw b}):h};return(g&&l.length>0?await I(ie(e),a.statusCallback,()=>x(g)):[]).flatMap(m=>l.flatMap(({pair:h,featureSide:S,mateSide:R})=>S.flatMap(b=>R.flatMap(me=>m.pairAlignments({target:b,query:me,bases:!1}).map(fe=>Se({pair:fe,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(t,e={}){let a=le(t);return te(async r=>{let{db:o,anchor:s,unreadableIndex:c}=await this.graph(e);if(!o.hasHaplotypeIndex)throw new B(c);if(a.assemblyName===s){let p=oe(e),l=p.length>0?await this.pairFeatures(a,p,e):await this.anchorFeatures(a,e);for(let d of l)r.next(d)}r.complete()},e.signal)}};export{B as NoHaplotypeIndexError,de as PairTargetError,Q as default,Ne as widestWalkGap};
|
|
2
|
-
//# sourceMappingURL=GbzBaseSyntenyAdapter-2MA3I6BM.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@11.0.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-TUQKGAK3.js", "../../src/GbzBaseSyntenyAdapter/companion.ts", "../../src/gaf/gafFile.ts", "../../src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n GBZ_CUT_DEFAULTS,\n NoReferenceSampleError,\n aliasedSample,\n cutWindowGFA,\n haplotypeWanted,\n referencePathQuery,\n referenceSamplesOf\n} from \"./chunk-NMWQUFPF.js\";\nimport {\n panSNSample\n} from \"./chunk-4XWZNPQ2.js\";\n\n// src/gbzCut.ts\nimport { GBZBase } from \"@gmod/gbz-base\";\nvar HPRC_GBZ = {\n db: \"https://s3-us-west-2.amazonaws.com/human-pangenomics/pangenomes/freeze/release2/minigraph-cactus/v2.1/hprc-v2.1-mc-grch38/hprc-v2.1-mc-grch38.gbz.db\",\n index: \"https://jbrowse.org/demos/hprc/hprc-v2.1-mc-grch38.haplotype-index.f3.db\"\n};\nfunction gbzLocations({ db, index }) {\n return db === \"hprc\" ? { db: HPRC_GBZ.db, index: index ?? HPRC_GBZ.index } : { db, index };\n}\nfunction haplotypeIndexBeside(db) {\n const GBZ_DB = /\\.gbz\\.db$/i;\n return GBZ_DB.test(db) ? db.replace(GBZ_DB, \".haplotype-index.db\") : void 0;\n}\nfunction parseRegion(text) {\n const m = /^\\s*([^:\\s]+):([\\d,]+)-([\\d,]+)\\s*$/.exec(text);\n if (!m) {\n throw new Error(\n `\"${text}\" is not a region like chr6:160,614,798-160,647,758`\n );\n }\n const n = (s) => Number(s.replaceAll(\",\", \"\"));\n const region = { refName: m[1], start: n(m[2]), end: n(m[3]) };\n if (region.end <= region.start) {\n throw new Error(`\"${text}\" ends at or before it starts`);\n }\n return region;\n}\nasync function openGbz(db, index) {\n const base = await GBZBase.open({ source: db, haplotypeIndex: index });\n return { base, referenceSamples: await referenceSamplesOf(base) };\n}\nfunction referenceSample(ref, samples) {\n if (ref) {\n return aliasedSample(panSNSample(ref), samples) ?? ref;\n }\n const first = samples[0];\n if (first === void 0) {\n throw new NoReferenceSampleError(\"\", samples);\n }\n return first;\n}\nasync function cutGbzRegion({ base, referenceSamples }, src, signal) {\n const region = parseRegion(src.region);\n const sample = referenceSample(src.referenceSample, referenceSamples);\n const query = await referencePathQuery(base, sample, region.refName);\n if (!query) {\n throw new Error(`${sample} has no indexed path named ${region.refName}`);\n }\n signal?.throwIfAborted();\n const wanted = src.haplotypes?.length ? src.haplotypes : void 0;\n const text = await cutWindowGFA(base, query, region.start, region.end, {\n context: src.context ?? GBZ_CUT_DEFAULTS.context,\n snarls: src.snarls ?? GBZ_CUT_DEFAULTS.snarls,\n limit: GBZ_CUT_DEFAULTS.limit,\n signal,\n keep: wanted ? (name) => haplotypeWanted(name, wanted) : void 0\n });\n return { text, region, sample };\n}\n\nexport {\n HPRC_GBZ,\n gbzLocations,\n haplotypeIndexBeside,\n parseRegion,\n openGbz,\n cutGbzRegion\n};\n", "import { haplotypeIndexBeside } from '@jbrowse/bandage-core/gbzCut'\nimport { openLocation } from '@jbrowse/core/util/io'\n\nimport { locationName, readsSiblings, renamed } from '../locationName'\n\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { FileLocation } from '@jbrowse/core/util/types'\n\nexport function siblingCompanion(gbzDb: FileLocation) {\n return readsSiblings(gbzDb) && haplotypeIndexBeside(locationName(gbzDb))\n ? renamed(gbzDb, name => haplotypeIndexBeside(name)!)\n : undefined\n}\n\n// 404 is a missing file, and so is 403 from a bucket that does not let a\n// reader list it; anything else leaves the file's presence unknown\nfunction isMissing(error: unknown) {\n return (\n error instanceof Error &&\n (/\\bHTTP 40[34]\\b/.test(error.message) ||\n (error as { code?: unknown }).code === 'ENOENT')\n )\n}\n\n// `unreadable` is why a companion that may be there could not be checked, such\n// as a network error, or a server that answers a missing file without CORS\nexport async function findCompanion(\n gbzDb: FileLocation,\n pluginManager?: PluginManager,\n): Promise<{ location?: FileLocation; unreadable?: string }> {\n const candidate = siblingCompanion(gbzDb)\n if (!candidate) {\n return {}\n }\n try {\n await openLocation(candidate, pluginManager).stat()\n return { location: candidate }\n } catch (error) {\n return isMissing(error) ? {} : { unreadable: String(error) }\n }\n}\n", "import { unzip } from '@gmod/bgzf-filehandle'\nimport { parseGaf, parseGafLine } from '@jbrowse/bandage-core/gaf/parseGaf'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\n\nimport type { TabixIndexedFile } from '@gmod/tabix'\nimport type { GafRecord } from '@jbrowse/bandage-core/gaf/parseGaf'\n\ninterface WholeFile {\n stat(): Promise<{ size: number }>\n readFile(opts?: { signal?: AbortSignal }): Promise<Uint8Array>\n}\n\nexport interface GafReads {\n records: GafRecord[]\n // reads over the nodes before sampling\n total: number\n}\n\n// The tube map lays reads out on the main thread at about 40 ms per thousand\nexport const MAX_READS = 5000\n\n// An unindexed GAF is read whole, once, into the worker\nconst MAX_UNINDEXED_BYTES = 50 * 2 ** 20\n\nexport class UnindexedGafTooLargeError extends Error {\n override name = 'UnindexedGafTooLargeError'\n\n constructor(size: number) {\n super(\n `this GAF is ${(size / 2 ** 20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`,\n )\n }\n}\n\n// Evenly spaced, so a pileup thins out rather than losing its right half\nfunction sample(records: GafRecord[], max: number) {\n if (records.length <= max) {\n return records\n }\n const stride = records.length / max\n return Array.from({ length: max }, (_, k) => records[Math.floor(k * stride)]!)\n}\n\nconst touches = (record: GafRecord, names: ReadonlySet<string>) =>\n record.path.some(step => names.has(step.name))\n\n// A GAF over a graph's segments: bgzipped and indexed with `tabix -p gaf`,\n// which keys each line by its lowest and highest node id and so needs numeric\n// segment names, or plain or gzipped and read whole.\nexport class GafFile {\n // Shared by every window, so the signal is cachedSetup's own, which aborts\n // once no caller is left waiting\n private whole = cachedSetup({\n setup: async ({ signal }) => {\n const { size } = await this.file.stat()\n if (size > MAX_UNINDEXED_BYTES) {\n throw new UnindexedGafTooLargeError(size)\n }\n const bytes = await this.file.readFile({ signal })\n const text = new TextDecoder().decode(\n bytes[0] === 0x1f && bytes[1] === 0x8b ? await unzip(bytes) : bytes,\n )\n return parseGaf(text)\n },\n })\n\n constructor(\n private file: WholeFile,\n private tabix?: TabixIndexedFile,\n ) {}\n\n private async readIndexed(\n tabix: TabixIndexedFile,\n names: ReadonlySet<string>,\n signal?: AbortSignal,\n ) {\n let lo = Infinity\n let hi = -Infinity\n for (const name of names) {\n const id = Number(name)\n if (Number.isInteger(id)) {\n lo = Math.min(lo, id)\n hi = Math.max(hi, id)\n }\n }\n const records: GafRecord[] = []\n if (lo <= hi) {\n // a GAF index ignores the refName, and getLines keeps a read whose node\n // ids span min..max when min < end && max >= start, hence hi + 1\n await tabix.getLines('{node}', lo, hi + 1, {\n signal,\n lineCallback: line => {\n const record = parseGafLine(line)\n if (record && touches(record, names)) {\n records.push(record)\n }\n },\n })\n }\n return records\n }\n\n async readsOver(\n names: ReadonlySet<string>,\n { signal }: { signal?: AbortSignal } = {},\n ): Promise<GafReads> {\n const records = this.tabix\n ? await this.readIndexed(this.tabix, names, signal)\n : (await this.whole({ signal })).filter(r => touches(r, names))\n return { records: sample(records, MAX_READS), total: records.length }\n }\n}\n", "import { GBZBase, SubgraphLimitError } from '@gmod/gbz-base'\nimport {\n NodeLimitError,\n cutWindowTables,\n haplotypePrefix,\n haplotypeWanted,\n nodeLimitError,\n referencePathQuery,\n referenceSamplesOf,\n resolveReferenceSample,\n} from '@jbrowse/bandage-core/gbzWindow'\nimport {\n assemblyByPanSNPrefix,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n} from '@jbrowse/bandage-core/pansn'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { getBpDisplayStr, updateStatus } from '@jbrowse/core/util'\nimport { openLocation } from '@jbrowse/core/util/io'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { findCompanion } from './companion.ts'\nimport { walkCutFor } from '../RgfaTabixAdapter/walkRowRuns.ts'\nimport { GafFile } from '../gaf/gafFile.ts'\nimport { locationIsSet } from '../locationName.ts'\nimport { openTabixSlot } from '../panSNTabix.ts'\nimport { ComparativeAdapterBase } from '../synteny/ComparativeAdapterBase.ts'\nimport SyntenyFeature from '../synteny/SyntenyFeature.ts'\nimport {\n laneAssemblyName,\n lanePairsStatus,\n requestedPairs,\n} from '../synteny/lanePairs.ts'\nimport { matchFeature } from '../synteny/matchFeature.ts'\n\nimport type { GbzBaseSyntenyAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions } from '../GetSubgraph.ts'\nimport type { GafReads } from '../gaf/gafFile.ts'\nimport type { LaneFeatureOptions, LanePair } from '../synteny/lanePairs.ts'\nimport type {\n HaplotypeAlignment,\n HaplotypeRef,\n PairAlignment,\n PathName,\n PathQuery,\n Subgraph,\n} from '@gmod/gbz-base'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util'\nimport type { FileLocation, Region } from '@jbrowse/core/util/types'\n\nexport class NoHaplotypeIndexError extends Error {\n override name = 'NoHaplotypeIndexError'\n\n constructor(unreadable?: string) {\n super(\n unreadable === undefined\n ? 'no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation'\n : `the haplotype index beside the graph database could not be checked (${unreadable}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`,\n )\n }\n}\n\ninterface GbzHaplotype {\n prefix: string\n sample: string\n haplotype: number\n contigs: string[]\n isReference: boolean\n}\n\n/**\n * One lane the header declares, in the shape MultiWaySyntenyDisplay's lane\n * picker reads: `name` is the lane's assembly name, the same string the\n * fetched features' mates carry, `label` its PanSN prefix and `group` its\n * sample, so a diploid sample's two lanes sit together\n */\ninterface GbzHeaderLane {\n name: string\n label: string\n group: string\n}\n\nexport { PairTargetError } from '../synteny/lanePairs.ts'\n\nclass HaplotypeWindowError extends Error {\n override name = 'HaplotypeWindowError'\n\n constructor(assemblyName: string, anchor: string) {\n super(\n `the graph is cut on its reference, ${anchor}; a window on ${assemblyName} has no reference coordinates to cut at. Open the graph from a ${anchor} view, and find this haplotype's lane there`,\n )\n }\n}\n\ntype ResolvedAlignment = Extract<HaplotypeAlignment, { resolved: true }>\n\n/**\n * The id of one haplotype fragment: the walk's GBWT position at its first node\n * in the window, which is a property of the graph, so the same fragment gets\n * the same id on a refetch of the same window and the display's hover and\n * selection survive it. `clipToRegion` suffixes the window.\n */\nfunction fragmentId(name: PathName, alignment: ResolvedAlignment) {\n return `${haplotypePrefix(name)}#${name.contig}@${alignment.start.node}.${alignment.start.offset}`\n}\n\nfunction fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane,\n}: {\n alignment: ResolvedAlignment\n assemblyName: string\n refName: string\n lane: string\n}) {\n const { refStart, refEnd, strand, cigar } = alignment\n if (refEnd <= refStart) {\n return undefined\n } else {\n const { name, hapStart, hapEnd } = alignment\n const id = fragmentId(name, alignment)\n const data: SimpleFeatureSerialized = {\n uniqueId: id,\n assemblyName,\n refName,\n start: refStart,\n end: refEnd,\n type: 'match',\n strand: strand === '-' ? -1 : 1,\n CIGAR: cigar,\n syntenyId: id,\n mate: {\n refName: name.contig,\n start: hapStart,\n end: hapEnd,\n assemblyName: lane,\n },\n }\n return new SyntenyFeature(data)\n }\n}\n\n// gbz-base writes the CIGAR along the target, which is the side a JBrowse\n// feature is, so it passes through unchanged\nfunction pairFeature({\n pair,\n lane,\n mateLane,\n}: {\n pair: PairAlignment\n lane: string\n mateLane: string\n}) {\n return matchFeature({\n target: {\n name: `${haplotypePrefix(pair.target)}#${pair.target.contig}`,\n assemblyName: lane,\n refName: pair.target.contig,\n start: pair.targetStart,\n end: pair.targetEnd,\n },\n query: {\n name: `${haplotypePrefix(pair.query)}#${pair.query.contig}`,\n assemblyName: mateLane,\n refName: pair.query.contig,\n start: pair.queryStart,\n end: pair.queryEnd,\n },\n strand: pair.strand,\n cigar: pair.cigar,\n matches: pair.matches,\n columns: pair.columns,\n })\n}\n\n// The longest detour a pair cut widens its context to take in\nconst BRIDGE_MAX_BP = 120_000\n\n/**\n * The widest gap, up to `BRIDGE_MAX_BP`, between two pieces of one kept walk:\n * a haplotype that left the cut's nodes for sequence the reference lacks and\n * came back. Two kept haplotypes that share that sequence only align across it\n * once its nodes are in the cut.\n */\nexport function widestWalkGap(subgraphs: Subgraph[], kept: Set<string>) {\n const byPath = new Map<string, [number, number][]>()\n for (const subgraph of subgraphs) {\n for (const { name, start, end } of subgraph.walkSpans()) {\n const prefix = haplotypePrefix(name)\n if (kept.has(prefix)) {\n const key = `${prefix}#${name.contig}`\n const spans = byPath.get(key)\n if (spans) {\n spans.push([start, end])\n } else {\n byPath.set(key, [[start, end]])\n }\n }\n }\n }\n let widest = 0\n for (const spans of byPath.values()) {\n spans.sort((a, b) => a[0] - b[0])\n for (let i = 1; i < spans.length; i++) {\n const gap = spans[i]![0] - spans[i - 1]![1]\n if (gap > 0 && gap <= BRIDGE_MAX_BP) {\n widest = Math.max(widest, gap)\n }\n }\n }\n return widest\n}\n\n// A window past the node limit fails as a zoom-in notice naming a span that\n// fits\nfunction zoomInNotice(error: unknown, what: string) {\n if (error instanceof NodeLimitError) {\n error.message = `Zoom in to about ${getBpDisplayStr(error.fitsBp)} to see ${what}`\n }\n return error\n}\n\n// gbz-base reads whole bp; a view asks at fractional ones\nconst wholeBp = (region: Region) => ({\n ...region,\n start: Math.floor(region.start),\n end: Math.ceil(region.end),\n})\n\nexport default class GbzBaseSyntenyAdapter extends ComparativeAdapterBase<GbzBaseSyntenyAdapterConfig> {\n private graph = cachedSetup({\n label: 'Opening pangenome database',\n setup: async () => {\n const gbzDb: FileLocation = this.getConf('gbzDbLocation')\n const configured: FileLocation = this.getConf('haplotypeIndexLocation')\n const companion = locationIsSet(configured)\n ? { location: configured }\n : await findCompanion(gbzDb, this.pluginManager)\n const indexLocation = companion.location\n const db = await GBZBase.open({\n source: openLocation(gbzDb, this.pluginManager),\n haplotypeIndex: indexLocation\n ? openLocation(indexLocation, this.pluginManager)\n : undefined,\n })\n const anchor = this.getConf('assemblyNames')[0]\n if (anchor === undefined) {\n throw new Error(\n 'GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as',\n )\n }\n const referenceSamples = await referenceSamplesOf(db)\n const referenceSample = resolveReferenceSample({\n configured: this.getConf('referenceSample'),\n anchorPrefix: resolvePanSNPrefix(this, anchor),\n referenceSamples,\n })\n return {\n db,\n anchor,\n referenceSample,\n referenceSamples,\n unreadableIndex: companion.unreadable,\n }\n },\n })\n\n /**\n * The indexed reference path a window on `refName` resolves against, or\n * undefined when the reference sample has no indexed path by that contig.\n */\n private async referenceQuery(\n refName: string,\n opts: BaseOptions,\n ): Promise<PathQuery | undefined> {\n const { db, referenceSample } = await this.graph(opts)\n return referencePathQuery(db, referenceSample, refName)\n }\n\n /**\n * Every haplotype the graph carries a walk for, `sample#haplotype` with its\n * contigs, from the Paths scan the adapter already makes; the lane picker's\n * source list. Reference samples are included and flagged.\n */\n async getHaplotypes(opts: BaseOptions = {}): Promise<GbzHaplotype[]> {\n const { db, referenceSamples } = await this.graph(opts)\n const byPrefix = new Map<string, GbzHaplotype>()\n for (const path of await db.paths()) {\n const prefix = haplotypePrefix(path.name)\n const entry = byPrefix.get(prefix)\n if (entry) {\n if (!entry.contigs.includes(path.name.contig)) {\n entry.contigs.push(path.name.contig)\n }\n } else {\n byPrefix.set(prefix, {\n prefix,\n sample: path.name.sample,\n haplotype: path.name.haplotype,\n contigs: [path.name.contig],\n isReference: referenceSamples.includes(path.name.sample),\n })\n }\n }\n return [...byPrefix.values()]\n }\n\n /**\n * `lanes` is every haplotype but the reference sample's own, which is the\n * anchor rather than a lane, declared up front so the display can offer the\n * whole graph's haplotypes before a fetch has placed any of them.\n */\n async getHeader(opts: BaseOptions = {}) {\n const { anchor, referenceSample } = await this.graph(opts)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const lanes: GbzHeaderLane[] = []\n for (const haplotype of await this.getHaplotypes(opts)) {\n if (haplotype.sample !== referenceSample) {\n lanes.push({\n name: laneAssemblyName(asmByPrefix, haplotype.prefix),\n label: haplotype.prefix,\n group: haplotype.sample,\n })\n }\n }\n return {\n hasCoarseTier: false,\n anchorAssemblyName: anchor,\n lanes,\n }\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n const { db, anchor, referenceSample } = await this.graph(opts)\n const { assemblyName } = opts\n const prefix =\n assemblyName === anchor\n ? undefined\n : resolvePanSNPrefix(this, assemblyName)\n const contigs = (await db.paths())\n .filter(path =>\n assemblyName === anchor\n ? path.isIndexed && path.name.sample === referenceSample\n : panSNMatchesPrefix(haplotypePrefix(path.name), prefix),\n )\n .map(path => path.name.contig)\n return [...new Set(contigs)]\n }\n\n /**\n * The predicate gbz-base builds a window for, from the lanes a fetch asks\n * for. With a companion whose stray rows cover the window gbz-base walks\n * only the wanted haplotypes; otherwise it names every walk and keeps the\n * ones the predicate accepts, and throws rather than guess when a walk has\n * no name. Either way a cut holds those walks, the reference, and the nodes\n * they visit. Undefined when every haplotype is wanted.\n */\n //\n // `targetPrefix` is a pairwise view's one lane, and it belongs in here: left\n // to filter what came back, it handed gbz-base no predicate, and every\n // haplotype in the graph was walked for one to be kept.\n private keepPredicate(\n haplotypes: string[] | undefined,\n targetPrefix?: string,\n ) {\n const wantedPrefixes =\n haplotypes === undefined || haplotypes.length === 0\n ? undefined\n : haplotypes.map(lane => resolvePanSNPrefix(this, lane))\n return wantedPrefixes === undefined && targetPrefix === undefined\n ? undefined\n : (name: PathName) =>\n haplotypeWanted(name, wantedPrefixes) &&\n (targetPrefix === undefined ||\n panSNMatchesPrefix(haplotypePrefix(name), targetPrefix))\n }\n\n /**\n * The graph view's cut of the window, as tables: the reference walk, every\n * top-level snarl contained in it, and one walk per haplotype, PanSN-named\n * when the database (or its companion) carries the haplotype index and\n * `unknown#N` otherwise. The reference walk is the first, which is the one\n * the view anchors on by default. With `haplotypes` the walks are that\n * set's and the nodes those walks visit, the reference walk kept. With\n * `walkRows` the rows' runs come along, as on a walk-file cut.\n *\n * Only a window on the anchor can be cut: a haplotype lane's coordinates\n * are its own contig's, and the graph is indexed for random access on the\n * reference sample's paths alone.\n */\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const { signal } = opts\n const { db, anchor, referenceSample, unreadableIndex } = await this.graph({\n signal,\n })\n const { assemblyName, refName, start, end } = wholeBp(region)\n if (assemblyName !== anchor) {\n throw new HaplotypeWindowError(assemblyName, anchor)\n }\n const query = await this.referenceQuery(refName, { signal })\n if (!query) {\n throw new Error(\n `${referenceSample} has no indexed path ${refName} in this graph`,\n )\n }\n const keep = this.keepPredicate(opts.haplotypes)\n if (keep !== undefined && !db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n const cut = await cutWindowTables(db, query, start, end, {\n context: this.getConf('context'),\n snarls: opts.snarls ?? this.getConf('subgraphSnarls'),\n limit: this.getConf('nodeLimit'),\n signal: opts.signal,\n keep,\n }).catch((error: unknown) => {\n throw zoomInNotice(error, 'the graph')\n })\n return typeof cut === 'string'\n ? cut\n : walkCutFor(cut, { start, end }, opts.walkRows)\n }\n\n private gaf = cachedSetup({\n label: 'Opening reads',\n setup: async () => {\n const location: FileLocation = this.getConf('readsLocation')\n const index: FileLocation = this.getConf(['readsIndex', 'location'])\n return locationIsSet(location)\n ? new GafFile(\n openLocation(location, this.pluginManager),\n locationIsSet(index)\n ? openTabixSlot(this, ['readsLocation'], ['readsIndex'])\n : undefined,\n )\n : undefined\n },\n })\n\n /**\n * The reads over a cut's segments, from `readsLocation`, sampled down to\n * what the tube map lays out at interactive speed\n */\n async getReads(\n nodeNames: string[],\n opts: BaseOptions = {},\n ): Promise<GafReads> {\n const gaf = await this.gaf(opts)\n return gaf\n ? gaf.readsOver(new Set(nodeNames), opts)\n : { records: [], total: 0 }\n }\n\n private async laneHaplotypes(\n assemblyName: string,\n opts: BaseOptions,\n ): Promise<HaplotypeRef[]> {\n const prefix = resolvePanSNPrefix(this, assemblyName)\n return (await this.getHaplotypes(opts)).filter(haplotype =>\n panSNMatchesPrefix(haplotype.prefix, prefix),\n )\n }\n\n private async anchorFeatures(region: Region, opts: LaneFeatureOptions) {\n const { db } = await this.graph(opts)\n const { assemblyName, refName, start, end } = region\n const targetPrefix = resolvePanSNPrefix(this, opts.targetAssemblyName)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const keep = this.keepPredicate(opts.haplotypes, targetPrefix)\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const alignments = query\n ? await updateStatus(\n `Reading graph ${refName}:${start.toLocaleString()}-${end.toLocaleString()}`,\n opts.statusCallback,\n () =>\n db\n .getAlignments({\n path: query,\n start,\n end,\n context: this.getConf('context'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep,\n })\n .catch((error: unknown) => {\n throw zoomInNotice(\n nodeLimitError(error, nodeLimit, end - start) ?? error,\n 'lanes',\n )\n }),\n )\n : []\n return alignments.flatMap(alignment => {\n const feature = alignment.resolved\n ? fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane: laneAssemblyName(\n asmByPrefix,\n haplotypePrefix(alignment.name),\n ),\n })\n : undefined\n return feature === undefined ? [] : [feature]\n })\n }\n\n /**\n * Each pair's two lanes cut out of the anchor window alone, all pairs in one\n * cut, and each walk of a pair's query lane aligned to each walk of its\n * target lane on the nodes both visit, with no base compared. A pair's\n * records sit on its query lane's contigs, the lane the display draws on top.\n *\n * Whether the index has anchor rows changes only how fast gbz-base finds\n * the walks: both routes cut the same pieces.\n */\n private async pairFeatures(\n region: Region,\n pairs: LanePair[],\n opts: LaneFeatureOptions,\n ) {\n const { db } = await this.graph(opts)\n const { refName, start, end } = region\n const sides = await Promise.all(\n pairs.map(async pair => ({\n pair,\n featureSide: await this.laneHaplotypes(pair.queryAssemblyName, opts),\n mateSide: await this.laneHaplotypes(pair.targetAssemblyName, opts),\n })),\n )\n const answerable = sides.filter(\n ({ featureSide, mateSide }) =>\n featureSide.length > 0 && mateSide.length > 0,\n )\n const kept = new Set(\n answerable.flatMap(({ featureSide, mateSide }) =>\n [...featureSide, ...mateSide].map(haplotypePrefix),\n ),\n )\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const baseContext: number = this.getConf('context')\n const cut = (path: PathQuery, context: number) =>\n db.getSubgraphs({\n path,\n start,\n end,\n context,\n snarls: this.getConf('subgraphSnarls'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep: name => kept.has(haplotypePrefix(name)),\n })\n // a cut past the node limit for the wider context keeps the first one\n const bridged = async (path: PathQuery) => {\n const subgraphs = await cut(path, baseContext).catch((error: unknown) => {\n throw zoomInNotice(\n nodeLimitError(error, nodeLimit, end - start) ?? error,\n 'lanes',\n )\n })\n const gap = widestWalkGap(subgraphs, kept)\n const context = Math.ceil(gap / 2) + 2000\n return gap > 0 && context > baseContext\n ? cut(path, context).catch((error: unknown) => {\n if (error instanceof SubgraphLimitError) {\n return subgraphs\n }\n throw error\n })\n : subgraphs\n }\n const subgraphs =\n query && answerable.length > 0\n ? await updateStatus(lanePairsStatus(pairs), opts.statusCallback, () =>\n bridged(query),\n )\n : []\n return subgraphs.flatMap(subgraph =>\n answerable.flatMap(({ pair, featureSide, mateSide }) =>\n featureSide.flatMap(target =>\n mateSide.flatMap(mate =>\n subgraph\n .pairAlignments({ target, query: mate, bases: false })\n .map(alignment =>\n pairFeature({\n pair: alignment,\n lane: pair.queryAssemblyName,\n mateLane: pair.targetAssemblyName,\n }),\n ),\n ),\n ),\n ),\n )\n }\n\n getFeatures(asked: Region, opts: LaneFeatureOptions = {}) {\n const region = wholeBp(asked)\n return ObservableCreate<Feature>(async observer => {\n const { db, anchor, unreadableIndex } = await this.graph(opts)\n if (!db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n // the graph is indexed on its reference alone, so a window on a\n // haplotype lane has no answer: a lane pair is read inside the anchor's\n if (region.assemblyName === anchor) {\n const pairs = requestedPairs(opts)\n const features =\n pairs.length > 0\n ? await this.pairFeatures(region, pairs, opts)\n : await this.anchorFeatures(region, opts)\n for (const feature of features) {\n observer.next(feature)\n }\n }\n observer.complete()\n }, opts.signal)\n }\n}\n"],
|
|
5
|
-
"mappings": "6zBAsBA,SAASA,EAAqBC,EAAI,CAChC,IAAMC,EAAS,cACf,OAAOA,EAAO,KAAKD,CAAE,EAAIA,EAAG,QAAQC,EAAQ,qBAAqB,EAAI,MACvE,CCjBO,SAASC,GAAiBC,EAAqB,CACpD,OAAOC,EAAcD,CAAK,GAAKE,EAAqBC,EAAaH,CAAK,CAAC,EACnEI,EAAQJ,EAAOK,GAAQH,EAAqBG,CAAI,CAAE,EAClD,MACN,CAIA,SAASC,GAAUC,EAAgB,CACjC,OACEA,aAAiB,QAChB,kBAAkB,KAAKA,EAAM,OAAO,GAClCA,EAA6B,OAAS,SAE7C,CAIA,eAAsBC,GACpBR,EACAS,EAC2D,CAC3D,IAAMC,EAAYX,GAAiBC,CAAK,EACxC,GAAI,CAACU,EACH,MAAO,CAAC,EAEV,GAAI,CACF,aAAMC,EAAaD,EAAWD,CAAa,EAAE,KAAK,EAC3C,CAAE,SAAUC,CAAU,CAC/B,OAASH,EAAO,CACd,OAAOD,GAAUC,CAAK,EAAI,CAAC,EAAI,CAAE,WAAY,OAAOA,CAAK,CAAE,CAC7D,CACF,CCrBO,IAAMK,GAAY,IAGnBC,GAAsB,GAAK,GAAK,GAEzBC,EAAN,cAAwC,KAAM,CAGnD,YAAYC,EAAc,CACxB,MACE,gBAAgBA,EA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Beside", "db", "GBZ_DB", "siblingCompanion", "gbzDb", "readsSiblings", "haplotypeIndexBeside", "locationName", "renamed", "name", "isMissing", "error", "findCompanion", "pluginManager", "candidate", "openLocation", "MAX_READS", "MAX_UNINDEXED_BYTES", "UnindexedGafTooLargeError", "size", "sample", "records", "max", "stride", "_", "k", "touches", "record", "names", "step", "GafFile", "file", "tabix", "cachedSetup", "signal", "bytes", "text", "unzip", "parseGaf", "lo", "hi", "name", "id", "line", "parseGafLine", "r", "NoHaplotypeIndexError", "unreadable", "HaplotypeWindowError", "assemblyName", "anchor", "fragmentId", "name", "alignment", "haplotypePrefix", "fragmentFeature", "refName", "lane", "refStart", "refEnd", "strand", "cigar", "hapStart", "hapEnd", "id", "data", "SyntenyFeature", "pairFeature", "pair", "mateLane", "matchFeature", "BRIDGE_MAX_BP", "widestWalkGap", "subgraphs", "kept", "byPath", "subgraph", "start", "end", "prefix", "key", "spans", "widest", "a", "b", "i", "gap", "zoomInNotice", "error", "what", "NodeLimitError", "getBpDisplayStr", "wholeBp", "region", "GbzBaseSyntenyAdapter", "ComparativeAdapterBase", "cachedSetup", "gbzDb", "configured", "companion", "locationIsSet", "findCompanion", "indexLocation", "db", "GBZBase", "openLocation", "referenceSamples", "referenceSamplesOf", "referenceSample", "resolveReferenceSample", "resolvePanSNPrefix", "location", "index", "GafFile", "openTabixSlot", "opts", "referencePathQuery", "byPrefix", "path", "entry", "asmByPrefix", "assemblyByPanSNPrefix", "lanes", "haplotype", "laneAssemblyName", "contigs", "panSNMatchesPrefix", "haplotypes", "targetPrefix", "wantedPrefixes", "haplotypeWanted", "signal", "unreadableIndex", "query", "keep", "cut", "cutWindowTables", "walkCutFor", "nodeNames", "gaf", "nodeLimit", "updateStatus", "nodeLimitError", "feature", "pairs", "answerable", "featureSide", "mateSide", "baseContext", "context", "bridged", "SubgraphLimitError", "lanePairsStatus", "target", "mate", "asked", "ObservableCreate", "observer", "requestedPairs", "features"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as G}from"./chunk-ZNT7TQLN.js";import{a as z}from"./chunk-PJ43KEV6.js";import{b as j,d as H,e as D,f as E,g as X}from"./chunk-U4U5ZOCH.js";import{a as $}from"./chunk-KOB7YIMR.js";import{p as W,q as R,r as I}from"./chunk-T4HOC6O3.js";import"./chunk-PFAHNHMM.js";import"./chunk-VDHDEEMF.js";import{e as q,m as T,o as _}from"./chunk-EDSIYH4H.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{a as F,c as v,d as S,g as P,h as k,i as x}from"./chunk-GUXZESDR.js";import"./chunk-T4R3ZVEM.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{o as C}from"./chunk-TENPGIPX.js";var ee=50;function te(i){let o=[];for(let e=0;e<i.length;e++){let[t,s]=i[e],[n,a]=i[e+1]??[];s===a&&s<=ee&&(t==="I"&&n==="D"||t==="D"&&n==="I")?(o.push(["X",s]),e++):o.push([t,s])}return o}function M(i){return Array.from(i.ids,(o,e)=>2*o+i.rev[e])}function K(i,o){let e=i.get(o);return e===void 0?0:e.end-e.start}function U(i){let o=new Map,e=n=>{let a=K(i,n),r=o.get(a);return r===void 0&&(r="N".repeat(a),o.set(a,r)),r},t=new Map,s=n=>{let a=t.get(n);return a===void 0&&(a=M(n),t.set(n,a)),a};return(n,a)=>R({query:s(n),target:s(a),sequenceOf:e,bases:!1})}var ae=100;function O(i,o,e){let t=i.at(-1);e>0&&(t?.[0]===o?t[1]+=e:i.push([o,e]))}function J(i){let o=t=>K(i,t>>1),e=t=>{let s=new Float64Array(t.length+1);return t.forEach((n,a)=>{s[a+1]=s[a]+o(n)}),s};return(t,s)=>{let n=M(s),a=M(t),[r,f]=W(a,n,o),[g,y]=W(a.map(u=>u^1).reverse(),n,o),l=y>f,p=l?g:r,N=Math.max(f,y);if(N<ae)return[];let h=e(n),c=e(a),b=u=>l?a.length-1-p[u][0]:p[u][0],m=[];p.forEach(([,u],w)=>{if(w>0){let[Q,V]=[b(w-1),b(w)].sort((Y,Z)=>Y-Z);O(m,"I",c[V]-c[Q+1]),O(m,"D",h[u]-h[p[w-1][1]+1])}O(m,"=",o(n[u]))});let[d,A]=[b(0),b(p.length-1)].sort((u,w)=>u-w);return[{queryStart:c[d],queryEnd:c[A+1],targetStart:h[p[0][1]],targetEnd:h[p.at(-1)[1]+1],strand:l?"-":"+",edits:m,sharedBases:N}]}}function B({chain:i,target:o,query:e,assemblyName:t,refName:s,mateAssemblyName:n}){let a=te(i.edits);return X({target:{name:o.name,assemblyName:t,refName:s,start:o.hapStart+i.targetStart,end:o.hapStart+i.targetEnd},query:{name:e.name,assemblyName:n,refName:S(e.name),start:e.hapStart+i.queryStart,end:e.hapStart+i.queryEnd},strand:i.strand,cigar:I(a),matches:a.reduce((r,[f,g])=>r+(f==="="?g:0),0),columns:a.reduce((r,[,f])=>r+f,0)})}var ne=i=>v(i.name)??i.name,L=class extends j{constructor(){super(...arguments);this.walks=new G(T(this,["walksLocation"],["walksIndex"]),this);this.refNames=new _(this.walks.file,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let{haplotypes:t}=await this.walks.reader.header(e),{anchor:s}=this,n=k(this,s),a=x(this);return{hasCoarseTier:!1,anchorAssemblyName:s,lanes:t.filter(r=>r!==n&&F(r)!==n).map(r=>({name:E(a,r),label:r,group:F(r)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let s=await this.refNames.resolve(e,{signal:t.signal});if(s===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; the graph is cut on ${this.anchor}, mapped to its PanSN prefix in assemblyNameToPanSN`);return this.walks.subgraph(s,e,t)}async laneWalks(e,t,s,n,a){return C(a,n.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:n.signal,keep:q(s,e),links:!1}).catch(r=>{throw z(r)&&r instanceof Error&&(r.message=r.message.replace("to see the graph","to see lanes")),r}))}async anchorFeatures(e,t,s){let n=s.haplotypes?.length?s.haplotypes.map(m=>k(this,m)):void 0,a=k(this,s.targetAssemblyName),r=a===void 0?n:n===void 0||n.some(m=>P(a,m)||P(m,a))?[a]:[];if(r?.length===0)return[];let{start:f,end:g}=t,{graph:y,fragments:l}=await this.laneWalks(e,t,r,s,`Reading walks ${t.refName}:${f.toLocaleString()}-${g.toLocaleString()}`),p=J(y.nodes),N=x(this),h=l.filter(m=>m.name===e),c=m=>r===void 0?0:r.findIndex(d=>P(m.name,d));return l.filter(m=>m.name!==e&&c(m)>=0).sort((m,d)=>c(m)-c(d)).flatMap(m=>h.flatMap(d=>p(m,d).map(A=>B({chain:A,target:d,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:E(N,ne(m))}))))}async pairFeatures(e,t,s,n){let a=s.map(l=>({pair:l,featurePrefix:k(this,l.queryAssemblyName),matePrefix:k(this,l.targetAssemblyName)})),{graph:r,fragments:f}=await this.laneWalks(e,t,a.flatMap(l=>[l.featurePrefix,l.matePrefix]),n,D(s)),g=U(r.nodes),y=l=>f.filter(p=>P(p.name,l));return a.flatMap(({pair:l,featurePrefix:p,matePrefix:N})=>y(p).flatMap(h=>y(N).flatMap(c=>g(c,h).map(b=>B({chain:b,target:h,query:c,assemblyName:l.queryAssemblyName,refName:S(h.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return $(async s=>{let n=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(n!==void 0){let a=H(t),r=a.length>0?await this.pairFeatures(n,e,a,t):await this.anchorFeatures(n,e,t);for(let f of r)s.next(f)}s.complete()},t.signal)}};export{L as default};
|
|
2
|
-
//# sourceMappingURL=WalkTabixSyntenyAdapter-AIC3W7FL.js.map
|