react-msaview 8.3.0 → 8.4.1

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 (125) hide show
  1. package/bundle/index.js +499 -295
  2. package/bundle/index.js.map +4 -4
  3. package/dist/blockFasta.d.ts +6 -0
  4. package/dist/blockFasta.js +12 -0
  5. package/dist/blockFasta.js.map +1 -0
  6. package/dist/colorSchemes.d.ts +7 -0
  7. package/dist/colorSchemes.js +15 -0
  8. package/dist/colorSchemes.js.map +1 -1
  9. package/dist/components/MSAView.js +15 -9
  10. package/dist/components/MSAView.js.map +1 -1
  11. package/dist/components/MSAViewer.d.ts +28 -7
  12. package/dist/components/MSAViewer.js +61 -22
  13. package/dist/components/MSAViewer.js.map +1 -1
  14. package/dist/components/MetadataTable.d.ts +5 -0
  15. package/dist/components/MetadataTable.js +29 -0
  16. package/dist/components/MetadataTable.js.map +1 -0
  17. package/dist/components/Track.js +11 -2
  18. package/dist/components/Track.js.map +1 -1
  19. package/dist/components/dialogs/MetadataDialog.js +5 -6
  20. package/dist/components/dialogs/MetadataDialog.js.map +1 -1
  21. package/dist/components/header/ColorSchemeMenu.d.ts +6 -0
  22. package/dist/components/header/ColorSchemeMenu.js +23 -5
  23. package/dist/components/header/ColorSchemeMenu.js.map +1 -1
  24. package/dist/components/header/GoToBox.d.ts +338 -0
  25. package/dist/components/header/GoToBox.js +31 -0
  26. package/dist/components/header/GoToBox.js.map +1 -0
  27. package/dist/components/header/Header.js +4 -2
  28. package/dist/components/header/Header.js.map +1 -1
  29. package/dist/components/header/SelectionMenu.d.ts +12 -0
  30. package/dist/components/header/SelectionMenu.js +72 -0
  31. package/dist/components/header/SelectionMenu.js.map +1 -0
  32. package/dist/components/header/goTo.d.ts +20 -0
  33. package/dist/components/header/goTo.js +69 -0
  34. package/dist/components/header/goTo.js.map +1 -0
  35. package/dist/components/msa/MSACanvas.js +13 -2
  36. package/dist/components/msa/MSACanvas.js.map +1 -1
  37. package/dist/components/msa/MSACanvasBlock.js +5 -1
  38. package/dist/components/msa/MSACanvasBlock.js.map +1 -1
  39. package/dist/components/msa/msaKeys.js +6 -0
  40. package/dist/components/msa/msaKeys.js.map +1 -1
  41. package/dist/components/msa/msaRaster.js +1 -0
  42. package/dist/components/msa/msaRaster.js.map +1 -1
  43. package/dist/components/msa/renderHighlights.d.ts +14 -3
  44. package/dist/components/msa/renderHighlights.js +29 -4
  45. package/dist/components/msa/renderHighlights.js.map +1 -1
  46. package/dist/components/msa/tileColor.js +9 -8
  47. package/dist/components/msa/tileColor.js.map +1 -1
  48. package/dist/components/msa/useMsaBlockMouse.d.ts +1 -1
  49. package/dist/components/msa/useMsaBlockMouse.js +18 -11
  50. package/dist/components/msa/useMsaBlockMouse.js.map +1 -1
  51. package/dist/components/overlayColors.d.ts +2 -0
  52. package/dist/components/overlayColors.js +3 -0
  53. package/dist/components/overlayColors.js.map +1 -1
  54. package/dist/components/selectionDrag.d.ts +17 -0
  55. package/dist/components/selectionDrag.js +30 -0
  56. package/dist/components/selectionDrag.js.map +1 -0
  57. package/dist/components/tracks/useTrackHover.d.ts +3 -1
  58. package/dist/components/tracks/useTrackHover.js +26 -6
  59. package/dist/components/tracks/useTrackHover.js.map +1 -1
  60. package/dist/components/tree/dialogs/TreeNodeInfoDialog.js +9 -8
  61. package/dist/components/tree/dialogs/TreeNodeInfoDialog.js.map +1 -1
  62. package/dist/constants.d.ts +1 -1
  63. package/dist/constants.js +6 -6
  64. package/dist/constants.js.map +1 -1
  65. package/dist/element.d.ts +7 -3
  66. package/dist/element.js +32 -4
  67. package/dist/element.js.map +1 -1
  68. package/dist/featuresLayer.d.ts +8 -0
  69. package/dist/featuresLayer.js +42 -0
  70. package/dist/featuresLayer.js.map +1 -0
  71. package/dist/index.d.ts +1 -1
  72. package/dist/model/DataModel.d.ts +1 -1
  73. package/dist/model/DataModel.js +3 -3
  74. package/dist/model/DataModel.js.map +1 -1
  75. package/dist/model/msaModel.d.ts +14 -1
  76. package/dist/model/msaModel.js +17 -1
  77. package/dist/model/msaModel.js.map +1 -1
  78. package/dist/model.d.ts +242 -187
  79. package/dist/model.js +264 -45
  80. package/dist/model.js.map +1 -1
  81. package/dist/svgTestUtil.d.ts +284 -336
  82. package/dist/types.d.ts +50 -0
  83. package/dist/version.d.ts +1 -1
  84. package/dist/version.js +1 -1
  85. package/package.json +6 -6
  86. package/src/blockFasta.ts +18 -0
  87. package/src/colorSchemes.ts +20 -0
  88. package/src/components/MSAView.tsx +16 -9
  89. package/src/components/MSAViewer.tsx +95 -26
  90. package/src/components/MetadataTable.tsx +55 -0
  91. package/src/components/Track.tsx +14 -1
  92. package/src/components/dialogs/MetadataDialog.tsx +9 -8
  93. package/src/components/header/ColorSchemeMenu.tsx +31 -12
  94. package/src/components/header/GoToBox.tsx +64 -0
  95. package/src/components/header/Header.tsx +6 -2
  96. package/src/components/header/SelectionMenu.tsx +117 -0
  97. package/src/components/header/goTo.ts +75 -0
  98. package/src/components/msa/MSACanvas.tsx +12 -2
  99. package/src/components/msa/MSACanvasBlock.tsx +5 -1
  100. package/src/components/msa/msaKeys.ts +6 -0
  101. package/src/components/msa/msaRaster.ts +1 -0
  102. package/src/components/msa/renderHighlights.ts +46 -4
  103. package/src/components/msa/tileColor.ts +9 -8
  104. package/src/components/msa/useMsaBlockMouse.ts +24 -27
  105. package/src/components/overlayColors.ts +4 -0
  106. package/src/components/selectionDrag.ts +42 -0
  107. package/src/components/tracks/useTrackHover.ts +28 -6
  108. package/src/components/tree/dialogs/TreeNodeInfoDialog.tsx +14 -16
  109. package/src/constants.ts +6 -6
  110. package/src/element.ts +45 -5
  111. package/src/featuresLayer.ts +48 -0
  112. package/src/index.ts +5 -0
  113. package/src/model/DataModel.ts +3 -3
  114. package/src/model/msaModel.ts +19 -1
  115. package/src/model.ts +313 -55
  116. package/src/types.ts +58 -0
  117. package/src/version.ts +1 -1
  118. package/dist/components/header/RowSearch.d.ts +0 -6
  119. package/dist/components/header/RowSearch.js +0 -15
  120. package/dist/components/header/RowSearch.js.map +0 -1
  121. package/dist/components/header/revealRow.d.ts +0 -3
  122. package/dist/components/header/revealRow.js +0 -15
  123. package/dist/components/header/revealRow.js.map +0 -1
  124. package/src/components/header/RowSearch.tsx +0 -34
  125. package/src/components/header/revealRow.ts +0 -17
package/src/types.ts CHANGED
@@ -17,6 +17,13 @@ export type TrackKind = 'text' | 'bar' | 'logo' | 'arc' | 'ruler'
17
17
  */
18
18
  export type ResidueEncoding = 'fill' | 'color'
19
19
 
20
+ /**
21
+ * The residue colors: a scheme name from the built-in table, or a scale's
22
+ * `{map}` of letter to color, which leaves every letter it does not list
23
+ * uncolored
24
+ */
25
+ export type ColorScheme = string | Required<Pick<ScaleSpec, 'map'>>
26
+
20
27
  export interface BasicTrackModel {
21
28
  id: string
22
29
  name: string
@@ -324,6 +331,26 @@ export interface Highlight {
324
331
  color?: string
325
332
  }
326
333
 
334
+ /**
335
+ * A feature on one row as data, the JSON form of a GFF line: `start` and `end`
336
+ * are residues of `row`, 1-based and inclusive. `name` is the key the legend,
337
+ * the palette and the filter dialog group features by, `color` overrides the
338
+ * palette and any scale, and a `strand` draws the span as an arrow. Every other
339
+ * field is a column the `featureFill` and `featureLabel` encodings can read.
340
+ */
341
+ export interface Feature {
342
+ row: string
343
+ start: number
344
+ end: number
345
+ name?: string
346
+ description?: string
347
+ /** a GFF feature type; `exon`, `CDS` and the UTRs draw as numbered segments */
348
+ type?: string
349
+ strand?: '+' | '-'
350
+ color?: string
351
+ [field: string]: string | number | undefined
352
+ }
353
+
327
354
  /**
328
355
  * What the viewer draws over a clade. `highlight` fills the rows behind it,
329
356
  * across the tree and the alignment. `bracket` draws a bar and the clade's
@@ -401,6 +428,27 @@ export interface Region {
401
428
  end: number
402
429
  }
403
430
 
431
+ /**
432
+ * A block of the alignment the reader selected: columns `start` to `end` of the
433
+ * file, 1-based and inclusive like a Highlight without a row, across the rows
434
+ * `rows` names, or across every row where `rows` is absent.
435
+ */
436
+ export interface MsaSelection {
437
+ start: number
438
+ end: number
439
+ rows?: string[]
440
+ }
441
+
442
+ /**
443
+ * An MsaSelection resolved to what is on screen: the visible columns it covers
444
+ * and its rows as runs of consecutive row indices, top to bottom
445
+ */
446
+ export interface ResolvedSelection {
447
+ startCol: number
448
+ endCol: number
449
+ rowRuns: [number, number][]
450
+ }
451
+
404
452
  /**
405
453
  * A cell of the alignment in the host's coordinates, 1-based like Highlight:
406
454
  * `column` counts every column of the file, hidden gappy ones included, and
@@ -421,6 +469,16 @@ export interface Viewport {
421
469
  endColumn: number
422
470
  }
423
471
 
472
+ /**
473
+ * A row table as a host passes it: fields per row name. A number or a boolean
474
+ * reads as its string, the way a GFF value does, and the viewer leaves out any
475
+ * other value. See docs/layers.md
476
+ */
477
+ export type RowDataInput = Record<
478
+ string,
479
+ Record<string, string | number | boolean | null>
480
+ >
481
+
424
482
  /**
425
483
  * A channel of a mark the viewer always draws. `tipLabel` colors each tip label
426
484
  * in the tree, `rowTint` washes the row across the tree gutter and the
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '8.3.0'
1
+ export const version = '8.4.1'
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import type { MsaViewModel } from '../../model.ts';
3
- declare const RowSearch: ({ model }: {
4
- model: MsaViewModel;
5
- }) => React.JSX.Element | null;
6
- export default RowSearch;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { Autocomplete, TextField, createFilterOptions } from '@mui/material';
3
- import { observer } from 'mobx-react';
4
- import { findableRowNames, revealRow } from './revealRow.js';
5
- const filterOptions = createFilterOptions({ limit: 50 });
6
- const RowSearch = observer(function ({ model }) {
7
- const names = findableRowNames(model);
8
- return names.length > 1 ? (React.createElement(Autocomplete, { size: "small", options: names, filterOptions: filterOptions, value: null, blurOnSelect: true, onChange: (_, name) => {
9
- if (name) {
10
- revealRow(model, name);
11
- }
12
- }, style: { width: 180, margin: 'auto 8px' }, renderInput: params => (React.createElement(TextField, { ...params, placeholder: "Find row", "aria-label": "Find row" })) })) : null;
13
- });
14
- export default RowSearch;
15
- //# sourceMappingURL=RowSearch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RowSearch.js","sourceRoot":"","sources":["../../../src/components/header/RowSearch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI5D,MAAM,aAAa,GAAG,mBAAmB,CAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;AAEhE,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,EAAE,KAAK,EAA2B;IACrE,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CACxB,oBAAC,YAAY,IACX,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,IAAI,EACX,YAAY,QACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;YACpB,IAAI,IAAI,EAAE,CAAC;gBACT,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACxB,CAAC;QACH,CAAC,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EACzC,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,CACrB,oBAAC,SAAS,OAAK,MAAM,EAAE,WAAW,EAAC,UAAU,gBAAY,UAAU,GAAG,CACvE,GACD,CACH,CAAC,CAAC,CAAC,IAAI,CAAA;AACV,CAAC,CAAC,CAAA;AAEF,eAAe,SAAS,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { MsaViewModel } from '../../model.ts';
2
- export declare function findableRowNames(model: MsaViewModel): string[];
3
- export declare function revealRow(model: MsaViewModel, name: string): void;
@@ -1,15 +0,0 @@
1
- export function findableRowNames(model) {
2
- const collapsed = new Set(model.collapsed);
3
- return model.leaves
4
- .filter(({ data: { id, name } }) => !(collapsed.has(id) && name === id))
5
- .map(leaf => leaf.data.name);
6
- }
7
- export function revealRow(model, name) {
8
- const index = model.rowNamesSet.get(name);
9
- if (index !== undefined) {
10
- const { rowHeight, msaAreaHeight } = model;
11
- model.setScrollY(-(index + 0.5) * rowHeight + msaAreaHeight / 2);
12
- model.setMousePos(undefined, index);
13
- }
14
- }
15
- //# sourceMappingURL=revealRow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"revealRow.js","sourceRoot":"","sources":["../../../src/components/header/revealRow.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,KAAmB;IAClD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAC,MAAM;SAChB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;SACvE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAmB,EAAE,IAAY;IACzD,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,KAAK,CAAA;QAC1C,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,SAAS,GAAG,aAAa,GAAG,CAAC,CAAC,CAAA;QAChE,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;IACrC,CAAC;AACH,CAAC"}
@@ -1,34 +0,0 @@
1
- import React from 'react'
2
-
3
- import { Autocomplete, TextField, createFilterOptions } from '@mui/material'
4
- import { observer } from 'mobx-react'
5
-
6
- import { findableRowNames, revealRow } from './revealRow.ts'
7
-
8
- import type { MsaViewModel } from '../../model.ts'
9
-
10
- const filterOptions = createFilterOptions<string>({ limit: 50 })
11
-
12
- const RowSearch = observer(function ({ model }: { model: MsaViewModel }) {
13
- const names = findableRowNames(model)
14
- return names.length > 1 ? (
15
- <Autocomplete
16
- size="small"
17
- options={names}
18
- filterOptions={filterOptions}
19
- value={null}
20
- blurOnSelect
21
- onChange={(_, name) => {
22
- if (name) {
23
- revealRow(model, name)
24
- }
25
- }}
26
- style={{ width: 180, margin: 'auto 8px' }}
27
- renderInput={params => (
28
- <TextField {...params} placeholder="Find row" aria-label="Find row" />
29
- )}
30
- />
31
- ) : null
32
- })
33
-
34
- export default RowSearch
@@ -1,17 +0,0 @@
1
- import type { MsaViewModel } from '../../model.ts'
2
-
3
- export function findableRowNames(model: MsaViewModel) {
4
- const collapsed = new Set(model.collapsed)
5
- return model.leaves
6
- .filter(({ data: { id, name } }) => !(collapsed.has(id) && name === id))
7
- .map(leaf => leaf.data.name)
8
- }
9
-
10
- export function revealRow(model: MsaViewModel, name: string) {
11
- const index = model.rowNamesSet.get(name)
12
- if (index !== undefined) {
13
- const { rowHeight, msaAreaHeight } = model
14
- model.setScrollY(-(index + 0.5) * rowHeight + msaAreaHeight / 2)
15
- model.setMousePos(undefined, index)
16
- }
17
- }