jbrowse-plugin-tview 2.2.1 → 3.0.0

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.
Files changed (113) hide show
  1. package/README.md +349 -69
  2. package/dist/AddHighlightModel/index.js +2 -13
  3. package/dist/AddHighlightModel/index.js.map +1 -1
  4. package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.d.ts +44 -64
  5. package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js +57 -81
  6. package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js.map +1 -1
  7. package/dist/LaunchTView/TviewGetPlanRpc/index.d.ts +1 -1
  8. package/dist/LaunchTView/align.d.ts +18 -17
  9. package/dist/LaunchTView/align.js +198 -151
  10. package/dist/LaunchTView/align.js.map +1 -1
  11. package/dist/LaunchTView/alleles.d.ts +14 -0
  12. package/dist/LaunchTView/alleles.js +51 -3
  13. package/dist/LaunchTView/alleles.js.map +1 -1
  14. package/dist/LaunchTView/fetchTviewPlan.d.ts +5 -37
  15. package/dist/LaunchTView/fetchTviewPlan.js +7 -28
  16. package/dist/LaunchTView/fetchTviewPlan.js.map +1 -1
  17. package/dist/LaunchTView/index.js +45 -16
  18. package/dist/LaunchTView/index.js.map +1 -1
  19. package/dist/LaunchTView/launch.d.ts +50 -0
  20. package/dist/LaunchTView/launch.js +48 -0
  21. package/dist/LaunchTView/launch.js.map +1 -0
  22. package/dist/LaunchTView/launchView.d.ts +3 -8
  23. package/dist/LaunchTView/launchView.js +18 -12
  24. package/dist/LaunchTView/launchView.js.map +1 -1
  25. package/dist/LaunchTView/modifications.d.ts +64 -0
  26. package/dist/LaunchTView/modifications.js +131 -0
  27. package/dist/LaunchTView/modifications.js.map +1 -0
  28. package/dist/LaunchTView/readLayout.d.ts +35 -39
  29. package/dist/LaunchTView/readLayout.js +44 -24
  30. package/dist/LaunchTView/readLayout.js.map +1 -1
  31. package/dist/LaunchTView/repeatStats.d.ts +1 -1
  32. package/dist/LaunchTView/repeatStats.js +6 -6
  33. package/dist/LaunchTView/repeatStats.js.map +1 -1
  34. package/dist/LaunchTView/repeats.js +6 -4
  35. package/dist/LaunchTView/repeats.js.map +1 -1
  36. package/dist/LaunchTView/tview.d.ts +47 -24
  37. package/dist/LaunchTView/tview.js +188 -99
  38. package/dist/LaunchTView/tview.js.map +1 -1
  39. package/dist/TViewPanel/components/TViewPanel.js +9 -4
  40. package/dist/TViewPanel/components/TViewPanel.js.map +1 -1
  41. package/dist/TViewPanel/genome.d.ts +11 -0
  42. package/dist/TViewPanel/genome.js +32 -0
  43. package/dist/TViewPanel/genome.js.map +1 -0
  44. package/dist/TViewPanel/init.d.ts +38 -19
  45. package/dist/TViewPanel/init.js +66 -39
  46. package/dist/TViewPanel/init.js.map +1 -1
  47. package/dist/TViewPanel/initMenu.d.ts +28 -0
  48. package/dist/TViewPanel/initMenu.js +79 -0
  49. package/dist/TViewPanel/initMenu.js.map +1 -0
  50. package/dist/TViewPanel/model.d.ts +1178 -383
  51. package/dist/TViewPanel/model.js +298 -87
  52. package/dist/TViewPanel/model.js.map +1 -1
  53. package/dist/TViewPanel/modifications.d.ts +25 -0
  54. package/dist/TViewPanel/modifications.js +89 -0
  55. package/dist/TViewPanel/modifications.js.map +1 -0
  56. package/dist/index.d.ts +0 -1
  57. package/dist/index.js +0 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/jbrowse-plugin-tview.umd.production.min.js +125 -89
  60. package/dist/jbrowse-plugin-tview.umd.production.min.js.map +4 -4
  61. package/dist/version.d.ts +1 -1
  62. package/dist/version.js +1 -1
  63. package/package.json +21 -18
  64. package/src/AddHighlightModel/index.tsx +8 -14
  65. package/src/LaunchTView/TviewGetPlanRpc/TviewGetPlan.ts +119 -157
  66. package/src/LaunchTView/TviewGetPlanRpc/index.ts +0 -1
  67. package/src/LaunchTView/align.ts +233 -177
  68. package/src/LaunchTView/alleles.ts +70 -4
  69. package/src/LaunchTView/fetchTviewPlan.ts +11 -54
  70. package/src/LaunchTView/index.ts +74 -16
  71. package/src/LaunchTView/launch.ts +98 -0
  72. package/src/LaunchTView/launchView.ts +28 -20
  73. package/src/LaunchTView/modifications.ts +200 -0
  74. package/src/LaunchTView/readLayout.ts +65 -41
  75. package/src/LaunchTView/repeatStats.ts +7 -7
  76. package/src/LaunchTView/repeats.ts +6 -4
  77. package/src/LaunchTView/tview.ts +228 -112
  78. package/src/TViewPanel/components/TViewPanel.tsx +33 -4
  79. package/src/TViewPanel/genome.ts +41 -0
  80. package/src/TViewPanel/init.ts +104 -51
  81. package/src/TViewPanel/initMenu.ts +126 -0
  82. package/src/TViewPanel/model.ts +350 -97
  83. package/src/TViewPanel/modifications.ts +127 -0
  84. package/src/index.ts +0 -2
  85. package/src/version.ts +1 -1
  86. package/dist/AddHighlightModel/GenomeMouseoverHighlight.d.ts +0 -6
  87. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +0 -23
  88. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js.map +0 -1
  89. package/dist/AddHighlightModel/HighlightComponents.d.ts +0 -7
  90. package/dist/AddHighlightModel/HighlightComponents.js +0 -11
  91. package/dist/AddHighlightModel/HighlightComponents.js.map +0 -1
  92. package/dist/LaunchTView/components/ArrayReport.d.ts +0 -10
  93. package/dist/LaunchTView/components/ArrayReport.js +0 -59
  94. package/dist/LaunchTView/components/ArrayReport.js.map +0 -1
  95. package/dist/LaunchTView/components/LaunchTViewDialog.d.ts +0 -6
  96. package/dist/LaunchTView/components/LaunchTViewDialog.js +0 -124
  97. package/dist/LaunchTView/components/LaunchTViewDialog.js.map +0 -1
  98. package/dist/LaunchTView/sampleTree.d.ts +0 -37
  99. package/dist/LaunchTView/sampleTree.js +0 -65
  100. package/dist/LaunchTView/sampleTree.js.map +0 -1
  101. package/dist/LaunchTView/useTviewMsa.d.ts +0 -18
  102. package/dist/LaunchTView/useTviewMsa.js +0 -24
  103. package/dist/LaunchTView/useTviewMsa.js.map +0 -1
  104. package/dist/TViewPanel/coords.d.ts +0 -25
  105. package/dist/TViewPanel/coords.js +0 -56
  106. package/dist/TViewPanel/coords.js.map +0 -1
  107. package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +0 -46
  108. package/src/AddHighlightModel/HighlightComponents.tsx +0 -25
  109. package/src/LaunchTView/components/ArrayReport.tsx +0 -64
  110. package/src/LaunchTView/components/LaunchTViewDialog.tsx +0 -212
  111. package/src/LaunchTView/sampleTree.ts +0 -73
  112. package/src/LaunchTView/useTviewMsa.ts +0 -39
  113. package/src/TViewPanel/coords.ts +0 -65
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.2.1";
1
+ export declare const version = "3.0.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '2.2.1';
1
+ export const version = '3.0.0';
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.1",
2
+ "version": "3.0.0",
3
3
  "license": "MIT",
4
4
  "name": "jbrowse-plugin-tview",
5
5
  "repository": {
@@ -35,34 +35,37 @@
35
35
  "preversion": "pnpm lint && pnpm build",
36
36
  "version": "node scripts/version.mjs",
37
37
  "postversion": "git push --follow-tags",
38
- "figures:repeats": "node scripts/repeat-figures.mjs",
39
- "prefigures:repeats": "pnpm pretest:e2e",
38
+ "figures:giab": "node scripts/giab-figures.mjs",
39
+ "prefigures:giab": "pnpm pretest:e2e",
40
40
  "report:repeats": "tsx scripts/repeat-report.mjs",
41
- "readme:repeats": "tsx scripts/repeat-readme.mjs"
41
+ "readme:repeats": "tsx scripts/repeat-readme.mjs",
42
+ "demos": "node scripts/demo-links.mjs",
43
+ "demos:upload": "node scripts/demo-upload.mjs",
44
+ "predemos:upload": "pnpm build && pnpm demos"
42
45
  },
43
46
  "jbrowse-plugin": {
44
47
  "name": "TView"
45
48
  },
46
49
  "dependencies": {
47
- "@emotion/styled": "^11.14.1",
48
- "swr": "^2.5.0"
50
+ "@emotion/styled": "^11.14.1"
49
51
  },
50
52
  "devDependencies": {
51
53
  "@emotion/react": "^11.14.0",
52
54
  "@eslint/js": "^10.0.1",
53
55
  "@fal-works/esbuild-plugin-global-externals": "^2.1.2",
54
- "@gmod/bam": "^8.3.0",
55
- "@gmod/indexedfasta": "^5.0.9",
56
- "@jbrowse/core": "^4.3.0",
56
+ "@gmod/bam": "^8.11.1",
57
+ "@gmod/indexedfasta": "^5.0.11",
58
+ "@jbrowse/core": "5.0.0-beta.23",
57
59
  "@jbrowse/mobx-state-tree": "^6.1.0",
58
- "@jbrowse/plugin-linear-genome-view": "^4.3.0",
60
+ "@jbrowse/modifications-utils": "5.0.0-beta.23",
61
+ "@jbrowse/plugin-linear-genome-view": "5.0.0-beta.23",
59
62
  "@mui/icons-material": "^9.3.1",
60
63
  "@mui/material": "^9.3.1",
61
64
  "@mui/system": "^9.3.0",
62
- "@types/node": "^26.2.0",
65
+ "@types/node": "^26.3.0",
63
66
  "@types/react": "^19.2.18",
64
- "esbuild": "^0.28.1",
65
- "eslint": "^10.8.1",
67
+ "esbuild": "^0.28.2",
68
+ "eslint": "^10.9.1",
66
69
  "eslint-plugin-import-x": "^4.17.1",
67
70
  "eslint-plugin-react": "^7.37.5",
68
71
  "eslint-plugin-react-hooks": "^7.1.1",
@@ -70,15 +73,15 @@
70
73
  "mobx-react": "^10.0.0",
71
74
  "prettier": "^3.9.6",
72
75
  "pretty-bytes": "^7.1.1",
73
- "puppeteer": "^25.5.0",
76
+ "puppeteer": "^25.9.0",
74
77
  "react": "^19.2.8",
75
78
  "react-dom": "^19.2.8",
76
- "react-msaview": "^5.7.1",
79
+ "react-msaview": "^11.0.0",
77
80
  "rimraf": "^6.1.3",
78
81
  "tss-react": "^4.9.21",
79
- "tsx": "^4.20.6",
82
+ "tsx": "^4.23.12",
80
83
  "typescript": "^6.0.2",
81
- "typescript-eslint": "^8.66.0",
82
- "vitest": "^4.1.10"
84
+ "typescript-eslint": "^8.68.0",
85
+ "vitest": "^4.1.11"
83
86
  }
84
87
  }
@@ -2,27 +2,21 @@ import React from 'react'
2
2
 
3
3
  import { getSession } from '@jbrowse/core/util'
4
4
 
5
- import HighlightComponents from './HighlightComponents'
5
+ import MsaToGenomeHighlight from './MsaToGenomeHighlight'
6
6
  import { isTView } from '../TViewPanel/model'
7
7
 
8
8
  import type PluginManager from '@jbrowse/core/PluginManager'
9
- import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
10
9
 
11
10
  export default function AddHighlightComponentsModelF(
12
11
  pluginManager: PluginManager,
13
12
  ) {
14
- pluginManager.addToExtensionPoint(
13
+ pluginManager.contributeToExtensionPoint(
15
14
  'LinearGenomeView-TracksContainerComponent',
16
- // @ts-expect-error
17
- (rest: React.ReactNode[], { model }: { model: LinearGenomeViewModel }) => {
18
- // skip entirely unless a TView is connected to this genome view
19
- const { views } = getSession(model)
20
- return views.some(v => isTView(v) && v.connectedViewId === model.id)
21
- ? [
22
- ...rest,
23
- <HighlightComponents key="tview_highlights" model={model} />,
24
- ]
25
- : rest
26
- },
15
+ ({ model }) =>
16
+ getSession(model).views.some(
17
+ v => isTView(v) && v.connectedViewId === model.id,
18
+ ) ? (
19
+ <MsaToGenomeHighlight key="tview_highlights" model={model} />
20
+ ) : undefined,
27
21
  )
28
22
  }
@@ -1,18 +1,31 @@
1
+ import { isSequenceAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
1
2
  import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache'
3
+ import { getFeatureAdapterOrThrow } from '@jbrowse/core/data_adapters/getFeatureAdapter'
2
4
  import { RpcMethodType } from '@jbrowse/core/pluggableElementTypes'
3
- import { renameRegionsIfNeeded } from '@jbrowse/core/util'
4
-
5
- import { buildSampleTree } from '../sampleTree'
6
- import { planTviewMsa, renderTviewMsa } from '../tview'
7
-
8
- import type { AlignmentFeature } from '../readLayout'
5
+ import { assembleLocString } from '@jbrowse/core/util'
6
+
7
+ import { planModifications } from '../modifications'
8
+ import {
9
+ planHighlights,
10
+ planRowData,
11
+ planTviewMsa,
12
+ renderRows,
13
+ toFasta,
14
+ } from '../tview'
15
+
16
+ import type { TviewModifications } from '../modifications'
9
17
  import type PluginManager from '@jbrowse/core/PluginManager'
10
- import type { Region } from '@jbrowse/core/util'
18
+ import type {
19
+ RpcCallContext,
20
+ RpcExecuteArgs,
21
+ } from '@jbrowse/core/rpc/RpcRegistry'
22
+ import type { Feature, Region } from '@jbrowse/core/util'
23
+ import type { Highlight, RowDataInput } from 'react-msaview'
11
24
 
12
25
  /** one BAM/CRAM to draw rows from, and the name its rows are grouped under */
13
26
  export interface TviewSourceArgs {
14
27
  adapterConfig: Record<string, unknown>
15
- sample?: string
28
+ sample: string
16
29
  /**
17
30
  * what this file calls the region's sequence. Filled in on the client, where
18
31
  * the assembly's aliases live: two files over one assembly routinely spell it
@@ -22,62 +35,40 @@ export interface TviewSourceArgs {
22
35
  }
23
36
 
24
37
  export interface TviewGetPlanArgs {
25
- sessionId: string
26
38
  sources: TviewSourceArgs[]
27
- /** the assembly's sequence adapter, when it has one */
28
- sequenceAdapterConfig?: Record<string, unknown>
39
+ /** names the genome, so the call layer attaches its sequence adapter */
40
+ assemblyName: string
29
41
  /** the sequence adapter's own spelling of the region */
30
- sequenceRefName?: string
42
+ sequenceRefName: string
31
43
  region: Region
32
44
  /** stop before rendering an alignment bigger than this many cells */
33
45
  maxCells: number
34
46
  }
35
47
 
36
- /** what crosses back: the alignment, and the numbers the dialog reports */
37
- export interface TviewArrayReport {
38
- start: number
39
- end: number
40
- period: number
41
- unit: string
42
- width: number
43
- /** per row: copies carried, and allele length in bp */
44
- copies: [string, number][]
45
- lengths: [string, number][]
46
- }
47
-
48
48
  export interface TviewPlanResult {
49
49
  msa: string
50
- /** Newick grouping rows by sample; absent unless several were loaded */
51
- tree?: string
52
- rowCount: number
50
+ /** per row name: its sample, and its copies and allele length at the subject */
51
+ rowData: RowDataInput
52
+ /** a bracket over each insertion site and each array block */
53
+ highlights: Highlight[]
53
54
  columnCount: number
54
55
  cellCount: number
55
- insertionWidths: [number, number][]
56
- arraySpans: [number, number, number][]
57
56
  region: { refName: string; start: number; end: number }
58
- arrays: TviewArrayReport[]
59
- subjectIndex?: number
60
- referenceName?: string
57
+ /** whether rows carry a copy count at a subject array */
58
+ hasSubject: boolean
61
59
  samples: string[]
62
60
  /** set when the alignment was over maxCells and `msa` is empty */
63
61
  tooLarge?: boolean
62
+ /** set when some read in the window has an MM tag */
63
+ modifications?: TviewModifications
64
64
  }
65
65
 
66
- /** the slice of a data adapter this reads, which is all of `getFeatures` */
67
- interface FeatureSource {
68
- getFeatures: (region: Region) => {
69
- subscribe: (observer: {
70
- next: (feature: AlignmentFeature) => void
71
- error: (error: unknown) => void
72
- complete: () => void
73
- }) => unknown
66
+ declare module '@jbrowse/core/rpc/RpcRegistry' {
67
+ interface RpcRegistry {
68
+ TviewGetPlan: { args: TviewGetPlanArgs; return: TviewPlanResult }
74
69
  }
75
70
  }
76
71
 
77
- function isFeatureSource(adapter: object): adapter is FeatureSource {
78
- return 'getFeatures' in adapter && typeof adapter.getFeatures === 'function'
79
- }
80
-
81
72
  /**
82
73
  * Drains an adapter's feature observable into an array.
83
74
  *
@@ -86,22 +77,16 @@ function isFeatureSource(adapter: object): adapter is FeatureSource {
86
77
  * `ObservableCreate`. Subscribing directly needs neither.
87
78
  */
88
79
  async function fetchAll(
89
- pluginManager: PluginManager,
90
- sessionId: string,
91
- adapterConfig: Record<string, unknown>,
80
+ args: RpcExecuteArgs<'TviewGetPlan'> & {
81
+ pluginManager: PluginManager
82
+ adapterConfig: Record<string, unknown>
83
+ },
92
84
  region: Region,
93
85
  ) {
94
- const { dataAdapter } = await getAdapter(
95
- pluginManager,
96
- sessionId,
97
- adapterConfig,
98
- )
99
- if (!isFeatureSource(dataAdapter)) {
100
- throw new Error(`${adapterConfig.type as string} has no getFeatures`)
101
- }
102
- return new Promise<AlignmentFeature[]>((resolve, reject) => {
103
- const ret: AlignmentFeature[] = []
104
- dataAdapter.getFeatures(region).subscribe({
86
+ const dataAdapter = await getFeatureAdapterOrThrow(args)
87
+ return new Promise<Feature[]>((resolve, reject) => {
88
+ const ret: Feature[] = []
89
+ dataAdapter.getFeatures(region, { signal: args.signal }).subscribe({
105
90
  next: feature => ret.push(feature),
106
91
  error: reject,
107
92
  complete: () => {
@@ -111,6 +96,42 @@ async function fetchAll(
111
96
  })
112
97
  }
113
98
 
99
+ /**
100
+ * The reference over exactly `region`, which becomes the alignment's first row
101
+ * and is what makes an array an interval rather than an insertion. The region
102
+ * arrives clamped to its contig, so a short answer means the sequence could not
103
+ * be read, and a row that stops early would misplace every column after it.
104
+ */
105
+ async function fetchReference(
106
+ pluginManager: PluginManager,
107
+ {
108
+ sessionId,
109
+ sequenceAdapter,
110
+ sequenceRefName,
111
+ region,
112
+ signal,
113
+ }: RpcExecuteArgs<'TviewGetPlan'>,
114
+ ) {
115
+ const dataAdapter = sequenceAdapter
116
+ ? (await getAdapter(pluginManager, sessionId, sequenceAdapter)).dataAdapter
117
+ : undefined
118
+ const sequence =
119
+ dataAdapter && isSequenceAdapter(dataAdapter)
120
+ ? await dataAdapter.getSequence(
121
+ { ...region, refName: sequenceRefName },
122
+ { signal },
123
+ )
124
+ : undefined
125
+ const want = region.end - region.start
126
+ if (sequence?.length !== want) {
127
+ const n = (x: number) => x.toLocaleString('en-US')
128
+ throw new Error(
129
+ `Could not read the reference sequence over ${assembleLocString(region)}: got ${n(sequence?.length ?? 0)}bp of ${n(want)}bp`,
130
+ )
131
+ }
132
+ return sequence
133
+ }
134
+
114
135
  /**
115
136
  * Builds the whole alignment in the worker and sends back the FASTA.
116
137
  *
@@ -126,69 +147,40 @@ async function fetchAll(
126
147
  * against the same reference interval, so an array's copies are counted once,
127
148
  * over rows from all of them.
128
149
  */
129
- export default class TviewGetPlan extends RpcMethodType {
130
- name = 'TviewGetPlan'
150
+ export default class TviewGetPlan extends RpcMethodType<'TviewGetPlan'> {
151
+ name = 'TviewGetPlan' as const
131
152
 
132
- /**
133
- * Written against the 4.3.0 base class, which takes a bare
134
- * `Record<string, unknown>` and has no `renameRegions` helper — that is the
135
- * oldest host this bundle boots on, and the newer base class accepts the same
136
- * shape.
137
- */
138
- async serializeArguments(
139
- args: Record<string, unknown>,
140
- rpcDriverClassName: string,
141
- ) {
142
- const typed = args as unknown as TviewGetPlanArgs
143
- const assemblyManager =
144
- this.pluginManager.rootModel?.session?.assemblyManager
145
- if (!assemblyManager) {
146
- throw new Error('no assembly manager')
147
- }
148
- const refNameFor = async (adapterConfig: Record<string, unknown>) => {
149
- const { regions } = await renameRegionsIfNeeded(assemblyManager, {
150
- sessionId: typed.sessionId,
151
- adapterConfig,
152
- regions: [typed.region],
153
- })
154
- return regions[0]!.refName
155
- }
153
+ async serializeArguments(args: TviewGetPlanArgs & RpcCallContext) {
156
154
  const sources = await Promise.all(
157
- typed.sources.map(async source => ({
158
- ...source,
159
- refName: await refNameFor(source.adapterConfig),
160
- })),
161
- )
162
- const sequenceRefName = typed.sequenceAdapterConfig
163
- ? await refNameFor(typed.sequenceAdapterConfig)
164
- : undefined
165
-
166
- return super.serializeArguments(
167
- { ...args, sources, sequenceRefName },
168
- rpcDriverClassName,
155
+ args.sources.map(async source => {
156
+ const { regions } = await this.renameRegions({
157
+ sessionId: args.sessionId,
158
+ adapterConfig: source.adapterConfig,
159
+ regions: [args.region],
160
+ })
161
+ return { ...source, refName: regions[0]!.refName }
162
+ }),
169
163
  )
164
+ return super.serializeArguments({ ...args, sources })
170
165
  }
171
166
 
172
- async execute(args: TviewGetPlanArgs, rpcDriverClassName: string) {
173
- const {
174
- sessionId,
175
- sources,
176
- sequenceAdapterConfig,
177
- sequenceRefName,
178
- region,
179
- maxCells,
180
- } = await this.deserializeArguments(args, rpcDriverClassName)
181
-
182
- const perSource = await Promise.all(
183
- sources.map(source =>
184
- fetchAll(this.pluginManager, sessionId, source.adapterConfig, {
185
- ...region,
186
- refName: source.refName ?? region.refName,
187
- }),
167
+ async execute(args: RpcExecuteArgs<'TviewGetPlan'>) {
168
+ const { pluginManager } = this
169
+ const { sources, region, maxCells } = args
170
+
171
+ const [perSource, sequence] = await Promise.all([
172
+ Promise.all(
173
+ sources.map(source =>
174
+ fetchAll(
175
+ { ...args, pluginManager, adapterConfig: source.adapterConfig },
176
+ { ...region, refName: source.refName ?? region.refName },
177
+ ),
178
+ ),
188
179
  ),
189
- )
190
- const features: AlignmentFeature[] = []
191
- const sampleByIndex: (string | undefined)[] = []
180
+ fetchReference(pluginManager, args),
181
+ ])
182
+ const features: Feature[] = []
183
+ const sampleByIndex: string[] = []
192
184
  for (const [i, feats] of perSource.entries()) {
193
185
  for (const feature of feats) {
194
186
  if (feature.get('seq')) {
@@ -198,27 +190,6 @@ export default class TviewGetPlan extends RpcMethodType {
198
190
  }
199
191
  }
200
192
 
201
- let sequence: string | undefined
202
- if (sequenceAdapterConfig) {
203
- const seqFeats = await fetchAll(
204
- this.pluginManager,
205
- sessionId,
206
- sequenceAdapterConfig,
207
- { ...region, refName: sequenceRefName ?? region.refName },
208
- )
209
- const seq = seqFeats[0]?.get('seq') as string | undefined
210
- const seqStart = seqFeats[0]?.get('start') as number | undefined
211
- // the adapter may answer with a wider block than it was asked for
212
- const sliced =
213
- seq !== undefined && seqStart !== undefined
214
- ? seq.slice(region.start - seqStart, region.end - seqStart)
215
- : undefined
216
- // a short answer means the region runs off the end of the contig, and a
217
- // reference row that stops early would misplace every column after it
218
- sequence =
219
- sliced?.length === region.end - region.start ? sliced : undefined
220
- }
221
-
222
193
  const plan = planTviewMsa({
223
194
  features,
224
195
  refName: region.refName,
@@ -229,36 +200,27 @@ export default class TviewGetPlan extends RpcMethodType {
229
200
  })
230
201
 
231
202
  const shared = {
232
- rowCount: plan.reads.length,
233
203
  columnCount: plan.layout.totalColumns,
234
204
  cellCount: plan.cellCount,
235
- insertionWidths: plan.insertionWidths,
236
- arraySpans: plan.arraySpans,
205
+ rowData: planRowData(plan),
206
+ highlights: planHighlights(plan),
237
207
  region: plan.region,
238
- arrays: plan.arrays.map(a => ({
239
- start: a.start,
240
- end: a.end,
241
- period: a.period,
242
- unit: a.unit,
243
- width: a.width,
244
- copies: [...a.copiesByName.entries()],
245
- lengths: [...a.lengthByName.entries()],
246
- })),
247
- subjectIndex: plan.subject
248
- ? plan.arrays.indexOf(plan.subject)
249
- : undefined,
250
- referenceName: plan.referenceName,
208
+ hasSubject: plan.subject !== undefined,
251
209
  samples: plan.samples,
252
210
  }
253
211
 
254
212
  // the render is the expensive half and the only part bounded by rows x
255
213
  // columns, so the size check happens before it rather than after
256
- return plan.cellCount > maxCells
257
- ? { ...shared, msa: '', tooLarge: true }
258
- : {
214
+ const rows = plan.cellCount > maxCells ? undefined : renderRows(plan)
215
+ const modifications = rows
216
+ ? planModifications({ features, plan, rows })
217
+ : undefined
218
+ return rows
219
+ ? {
259
220
  ...shared,
260
- msa: renderTviewMsa(plan),
261
- tree: buildSampleTree(plan.reads),
221
+ msa: toFasta(plan, rows),
222
+ ...(modifications ? { modifications } : {}),
262
223
  }
224
+ : { ...shared, msa: '', tooLarge: true }
263
225
  }
264
226
  }
@@ -7,7 +7,6 @@ export default function TviewGetPlanRpcF(pluginManager: PluginManager) {
7
7
  }
8
8
 
9
9
  export type {
10
- TviewArrayReport,
11
10
  TviewGetPlanArgs,
12
11
  TviewPlanResult,
13
12
  TviewSourceArgs,