react-msaview 6.0.0 → 6.1.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 (118) hide show
  1. package/bundle/index.js +98 -98
  2. package/bundle/index.js.map +4 -4
  3. package/dist/columnCounts.d.ts +7 -0
  4. package/dist/columnCounts.js +18 -0
  5. package/dist/columnCounts.js.map +1 -1
  6. package/dist/components/DragHandle.d.ts +25 -0
  7. package/dist/components/DragHandle.js +49 -0
  8. package/dist/components/DragHandle.js.map +1 -0
  9. package/dist/components/ResizeHandles.d.ts +4 -2
  10. package/dist/components/ResizeHandles.js +29 -32
  11. package/dist/components/ResizeHandles.js.map +1 -1
  12. package/dist/components/VerticalScrollbar.js +2 -2
  13. package/dist/components/VerticalScrollbar.js.map +1 -1
  14. package/dist/components/dialogs/InterProScanDialog.js +52 -129
  15. package/dist/components/dialogs/InterProScanDialog.js.map +1 -1
  16. package/dist/components/header/settingsMenuItems.js +15 -0
  17. package/dist/components/header/settingsMenuItems.js.map +1 -1
  18. package/dist/components/minimap/Minimap.js +32 -4
  19. package/dist/components/minimap/Minimap.js.map +1 -1
  20. package/dist/components/msa/MSACanvas.js +8 -2
  21. package/dist/components/msa/MSACanvas.js.map +1 -1
  22. package/dist/components/msa/MSACanvasBlock.js +12 -3
  23. package/dist/components/msa/MSACanvasBlock.js.map +1 -1
  24. package/dist/components/msa/msaRaster.d.ts +63 -0
  25. package/dist/components/msa/msaRaster.js +252 -0
  26. package/dist/components/msa/msaRaster.js.map +1 -0
  27. package/dist/components/msa/renderMSABlock.d.ts +2 -1
  28. package/dist/components/msa/renderMSABlock.js +13 -21
  29. package/dist/components/msa/renderMSABlock.js.map +1 -1
  30. package/dist/components/msa/tileColor.d.ts +6 -0
  31. package/dist/components/msa/tileColor.js +35 -0
  32. package/dist/components/msa/tileColor.js.map +1 -0
  33. package/dist/components/renderCtx.d.ts +1 -1
  34. package/dist/components/tracks/TrackBlocks.d.ts +14 -0
  35. package/dist/components/tracks/TrackBlocks.js +65 -0
  36. package/dist/components/tracks/TrackBlocks.js.map +1 -0
  37. package/dist/components/tracks/{renderTracksSvg.d.ts → drawTracks.d.ts} +22 -10
  38. package/dist/components/tracks/drawTracks.js +193 -0
  39. package/dist/components/tracks/drawTracks.js.map +1 -0
  40. package/dist/components/tree/TreeCanvas.js +8 -2
  41. package/dist/components/tree/TreeCanvas.js.map +1 -1
  42. package/dist/components/tree/TreeCanvasBlock.js +7 -4
  43. package/dist/components/tree/TreeCanvasBlock.js.map +1 -1
  44. package/dist/components/tree/renderTreeCanvas.js +5 -2
  45. package/dist/components/tree/renderTreeCanvas.js.map +1 -1
  46. package/dist/constants.d.ts +3 -0
  47. package/dist/constants.js +8 -0
  48. package/dist/constants.js.map +1 -1
  49. package/dist/model/DataModel.d.ts +1 -4
  50. package/dist/model/DataModel.js +8 -10
  51. package/dist/model/DataModel.js.map +1 -1
  52. package/dist/model.d.ts +36 -7
  53. package/dist/model.js +113 -58
  54. package/dist/model.js.map +1 -1
  55. package/dist/neighborJoining.js +34 -18
  56. package/dist/neighborJoining.js.map +1 -1
  57. package/dist/renderTestEnv.d.ts +43 -0
  58. package/dist/renderTestEnv.js +88 -0
  59. package/dist/renderTestEnv.js.map +1 -0
  60. package/dist/renderToSvg.js +1 -1
  61. package/dist/renderToSvg.js.map +1 -1
  62. package/dist/sequenceLogo.d.ts +28 -0
  63. package/dist/sequenceLogo.js +47 -0
  64. package/dist/sequenceLogo.js.map +1 -0
  65. package/dist/types.d.ts +2 -0
  66. package/dist/version.d.ts +1 -1
  67. package/dist/version.js +1 -1
  68. package/package.json +3 -3
  69. package/src/columnCounts.test.ts +15 -0
  70. package/src/columnCounts.ts +19 -0
  71. package/src/components/DragHandle.tsx +81 -0
  72. package/src/components/ResizeHandles.tsx +46 -54
  73. package/src/components/VerticalScrollbar.tsx +3 -2
  74. package/src/components/dialogs/InterProScanDialog.tsx +54 -131
  75. package/src/components/header/settingsMenuItems.ts +18 -0
  76. package/src/components/minimap/Minimap.tsx +47 -4
  77. package/src/components/msa/MSACanvas.tsx +30 -10
  78. package/src/components/msa/MSACanvasBlock.tsx +13 -3
  79. package/src/components/msa/msaRaster.test.ts +145 -0
  80. package/src/components/msa/msaRaster.ts +350 -0
  81. package/src/components/msa/renderMSABlock.ts +15 -20
  82. package/src/components/msa/tileColor.ts +37 -0
  83. package/src/components/renderCtx.ts +2 -0
  84. package/src/components/tracks/TrackBlocks.tsx +111 -0
  85. package/src/components/tracks/drawTracks.ts +323 -0
  86. package/src/components/tree/TreeCanvas.tsx +16 -4
  87. package/src/components/tree/TreeCanvasBlock.tsx +18 -11
  88. package/src/components/tree/renderTreeCanvas.ts +5 -1
  89. package/src/constants.ts +10 -0
  90. package/src/impgRender.test.tsx +2 -57
  91. package/src/largeTree.test.ts +16 -2
  92. package/src/model/DataModel.ts +11 -11
  93. package/src/model.ts +128 -60
  94. package/src/neighborJoining.ts +36 -18
  95. package/src/renderDomainsSvg.test.tsx +2 -57
  96. package/src/renderMinimapSvg.test.tsx +2 -56
  97. package/src/renderSequenceLogoSvg.test.tsx +176 -0
  98. package/src/renderTestEnv.ts +96 -0
  99. package/src/renderToSvg.tsx +1 -1
  100. package/src/sequenceLogo.test.ts +88 -0
  101. package/src/sequenceLogo.ts +63 -0
  102. package/src/types.ts +7 -1
  103. package/src/version.ts +1 -1
  104. package/dist/components/ConservationTrack.d.ts +0 -8
  105. package/dist/components/ConservationTrack.js +0 -49
  106. package/dist/components/ConservationTrack.js.map +0 -1
  107. package/dist/components/ScrollbarThumb.d.ts +0 -14
  108. package/dist/components/ScrollbarThumb.js +0 -28
  109. package/dist/components/ScrollbarThumb.js.map +0 -1
  110. package/dist/components/TextTrack.d.ts +0 -8
  111. package/dist/components/TextTrack.js +0 -58
  112. package/dist/components/TextTrack.js.map +0 -1
  113. package/dist/components/tracks/renderTracksSvg.js +0 -126
  114. package/dist/components/tracks/renderTracksSvg.js.map +0 -1
  115. package/src/components/ConservationTrack.tsx +0 -99
  116. package/src/components/ScrollbarThumb.tsx +0 -48
  117. package/src/components/TextTrack.tsx +0 -103
  118. package/src/components/tracks/renderTracksSvg.ts +0 -247
@@ -1,126 +0,0 @@
1
- import { setFontSize } from '../../setFontSize.js';
2
- import { visibleColRange } from '../msa/visibleColRange.js';
3
- export function drawConservationBars({ ctx, values, color, colWidth, trackHeight, offsetX, blockSize, }) {
4
- const { xStart, xEnd } = visibleColRange({
5
- offsetX,
6
- blockWidth: blockSize,
7
- colWidth,
8
- });
9
- ctx.fillStyle = color;
10
- for (let i = xStart; i < xEnd && i < values.length; i++) {
11
- const value = values[i];
12
- const barHeight = value * trackHeight;
13
- const x = i * colWidth;
14
- ctx.fillRect(x, trackHeight - barHeight, colWidth, barHeight);
15
- }
16
- }
17
- // the bar-track values live on model getters (kept off the plain track object so
18
- // the live canvas autorun stays reactive); select the right one by track id
19
- export function barTrackValues(model, trackId) {
20
- return trackId === 'property-conservation'
21
- ? model.propertyConservation
22
- : model.conservation;
23
- }
24
- export function drawTextTrackContent({ ctx, data, colorScheme, contrastScheme, bgColor, textColor, colWidth, rowHeight, offsetX, blockSize, }) {
25
- const { xStart, xEnd } = visibleColRange({
26
- offsetX,
27
- blockWidth: blockSize,
28
- colWidth,
29
- });
30
- const str = data?.slice(xStart, xEnd);
31
- const drawLetters = rowHeight >= 10 && colWidth >= rowHeight / 2;
32
- for (let i = 0; str && i < str.length; i++) {
33
- const letter = str[i];
34
- const upper = letter.toUpperCase();
35
- const color = colorScheme[upper];
36
- const x = (xStart + i) * colWidth;
37
- const filled = bgColor && !!color;
38
- if (filled) {
39
- ctx.fillStyle = color;
40
- ctx.fillRect(x, 0, colWidth, rowHeight);
41
- }
42
- if (drawLetters) {
43
- // a letter on a colored tile needs the tile's contrast color; otherwise it
44
- // sits on the plain background and takes the theme's text color
45
- ctx.fillStyle = filled ? (contrastScheme[upper] ?? 'black') : textColor;
46
- ctx.fillText(letter, x + colWidth / 2, rowHeight / 2 + 1);
47
- }
48
- }
49
- }
50
- export function renderConservationTrack({ model, ctx, track, offsetX, offsetY, trackHeight, blockSizeXOverride, highResScaleFactorOverride, }) {
51
- const { blockSize, colWidth, highResScaleFactor } = model;
52
- const bx = blockSizeXOverride ?? blockSize;
53
- const k = highResScaleFactorOverride ?? highResScaleFactor;
54
- ctx.resetTransform();
55
- ctx.scale(k, k);
56
- ctx.translate(-offsetX, offsetY);
57
- drawConservationBars({
58
- ctx,
59
- values: barTrackValues(model, track.model.id),
60
- color: track.model.barColor ?? 'gray',
61
- colWidth,
62
- trackHeight,
63
- offsetX,
64
- blockSize: bx,
65
- });
66
- ctx.resetTransform();
67
- }
68
- export function renderTextTrack({ model, ctx, track, offsetX, offsetY, contrastScheme, theme, blockSizeXOverride, highResScaleFactorOverride, }) {
69
- const { blockSize, bgColor, colorScheme: modelColorScheme, colWidth, fontSize, rowHeight, highResScaleFactor, } = model;
70
- const { customColorScheme, data } = track.model;
71
- const colorScheme = customColorScheme ?? modelColorScheme;
72
- const bx = blockSizeXOverride ?? blockSize;
73
- const k = highResScaleFactorOverride ?? highResScaleFactor;
74
- ctx.resetTransform();
75
- ctx.scale(k, k);
76
- ctx.translate(-offsetX, offsetY);
77
- ctx.textAlign = 'center';
78
- setFontSize(ctx, fontSize);
79
- drawTextTrackContent({
80
- ctx,
81
- data,
82
- colorScheme,
83
- contrastScheme,
84
- bgColor,
85
- textColor: theme.palette.text.primary,
86
- colWidth,
87
- rowHeight,
88
- offsetX,
89
- blockSize: bx,
90
- });
91
- ctx.resetTransform();
92
- }
93
- export function renderAllTracks({ model, ctx, offsetX, contrastScheme, theme, blockSizeXOverride, highResScaleFactorOverride, }) {
94
- const { turnedOnTracks } = model;
95
- let currentY = 0;
96
- for (const track of turnedOnTracks) {
97
- const trackHeight = track.model.height;
98
- if (track.model.barColor !== undefined) {
99
- renderConservationTrack({
100
- model,
101
- ctx,
102
- track,
103
- offsetX,
104
- offsetY: currentY,
105
- trackHeight,
106
- blockSizeXOverride,
107
- highResScaleFactorOverride,
108
- });
109
- }
110
- else {
111
- renderTextTrack({
112
- model,
113
- ctx,
114
- track,
115
- offsetX,
116
- offsetY: currentY,
117
- contrastScheme,
118
- theme,
119
- blockSizeXOverride,
120
- highResScaleFactorOverride,
121
- });
122
- }
123
- currentY += trackHeight;
124
- }
125
- }
126
- //# sourceMappingURL=renderTracksSvg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderTracksSvg.js","sourceRoot":"","sources":["../../../src/components/tracks/renderTracksSvg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAO3D,MAAM,UAAU,oBAAoB,CAAC,EACnC,GAAG,EACH,MAAM,EACN,KAAK,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,GASV;IACC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;QACvC,OAAO;QACP,UAAU,EAAE,SAAS;QACrB,QAAQ;KACT,CAAC,CAAA;IAEF,GAAG,CAAC,SAAS,GAAG,KAAK,CAAA;IACrB,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAE,CAAA;QACxB,MAAM,SAAS,GAAG,KAAK,GAAG,WAAW,CAAA;QACrC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAA;QACtB,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,WAAW,GAAG,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAAC,KAAmB,EAAE,OAAe;IACjE,OAAO,OAAO,KAAK,uBAAuB;QACxC,CAA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gBACP,OAAO,EAAE,QAAQ;gBACjB,WAAW;gBACX,kBAAkB;gBAClB,0BAA0B;aAC3B,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,eAAe,CAAC;gBACd,KAAK;gBACL,GAAG;gBACH,KAAK;gBACL,OAAO;gBACP,OAAO,EAAE,QAAQ;gBACjB,cAAc;gBACd,KAAK;gBACL,kBAAkB;gBAClB,0BAA0B;aAC3B,CAAC,CAAA;QACJ,CAAC;QAED,QAAQ,IAAI,WAAW,CAAA;IACzB,CAAC;AACH,CAAC"}
@@ -1,99 +0,0 @@
1
- import React from 'react'
2
-
3
- import { observer } from 'mobx-react'
4
-
5
- import { useCanvasAutorun } from '../useCanvasAutorun.ts'
6
- import { ConservationTrackResizeHandle } from './ResizeHandles.tsx'
7
- import {
8
- barTrackValues,
9
- drawConservationBars,
10
- } from './tracks/renderTracksSvg.ts'
11
-
12
- import type { MsaViewModel } from '../model.ts'
13
- import type { BasicTrack } from '../types.ts'
14
-
15
- const ConservationBlock = observer(function ({
16
- model,
17
- track,
18
- offsetX,
19
- trackHeight,
20
- }: {
21
- model: MsaViewModel
22
- track: BasicTrack
23
- offsetX: number
24
- trackHeight: number
25
- }) {
26
- const { blockSize, scrollX, highResScaleFactor } = model
27
-
28
- const ref = useCanvasAutorun({
29
- draw: ctx => {
30
- const { colWidth } = model
31
- ctx.resetTransform()
32
- ctx.scale(highResScaleFactor, highResScaleFactor)
33
- ctx.clearRect(0, 0, blockSize, trackHeight)
34
- ctx.translate(-offsetX, 0)
35
-
36
- drawConservationBars({
37
- ctx,
38
- values: barTrackValues(model, track.model.id),
39
- color: track.model.barColor ?? 'gray',
40
- colWidth,
41
- trackHeight,
42
- offsetX,
43
- blockSize,
44
- })
45
- },
46
- width: blockSize * highResScaleFactor,
47
- height: trackHeight * highResScaleFactor,
48
- deps: [model, track, offsetX, trackHeight],
49
- })
50
-
51
- return (
52
- <canvas
53
- ref={ref}
54
- height={trackHeight * highResScaleFactor}
55
- width={blockSize * highResScaleFactor}
56
- style={{
57
- position: 'absolute',
58
- left: scrollX + offsetX,
59
- width: blockSize,
60
- height: trackHeight,
61
- }}
62
- />
63
- )
64
- })
65
-
66
- const ConservationTrack = observer(function ({
67
- model,
68
- track,
69
- }: {
70
- model: MsaViewModel
71
- track: BasicTrack
72
- }) {
73
- const { blocksX, msaAreaWidth } = model
74
- const trackHeight = track.model.height
75
-
76
- return (
77
- <div
78
- style={{
79
- position: 'relative',
80
- height: trackHeight,
81
- width: msaAreaWidth,
82
- overflow: 'hidden',
83
- }}
84
- >
85
- {blocksX.map(bx => (
86
- <ConservationBlock
87
- key={bx}
88
- model={model}
89
- track={track}
90
- offsetX={bx}
91
- trackHeight={trackHeight}
92
- />
93
- ))}
94
- <ConservationTrackResizeHandle model={model} />
95
- </div>
96
- )
97
- })
98
-
99
- export default ConservationTrack
@@ -1,48 +0,0 @@
1
- import React, { useState } from 'react'
2
-
3
- import { useDragScroll } from '../useDragScroll.ts'
4
-
5
- export const scrollbarThumbFill = 'rgba(66,119,127,0.3)'
6
- const scrollbarThumbFillHovered = 'rgba(66,119,127,0.6)'
7
-
8
- /**
9
- * The draggable thumb shared by the horizontal Minimap and the
10
- * VerticalScrollbar. `getStart` is read at mousedown and handed back to
11
- * `onDrag` alongside the pixel delta since, so a caller only supplies the
12
- * scroll offset it drives and where the thumb sits.
13
- */
14
- export default function ScrollbarThumb({
15
- axis,
16
- getStart,
17
- onDrag,
18
- style,
19
- }: {
20
- axis: 'x' | 'y'
21
- getStart: () => number
22
- onDrag: (delta: number, startValue: number) => void
23
- style: React.CSSProperties
24
- }) {
25
- const [hovered, setHovered] = useState(false)
26
- const { startDrag } = useDragScroll(axis, onDrag)
27
-
28
- return (
29
- <div
30
- onMouseOver={() => {
31
- setHovered(true)
32
- }}
33
- onMouseOut={() => {
34
- setHovered(false)
35
- }}
36
- onMouseDown={event => {
37
- startDrag(event, getStart())
38
- }}
39
- style={{
40
- position: 'absolute',
41
- zIndex: 100,
42
- cursor: 'pointer',
43
- background: hovered ? scrollbarThumbFillHovered : scrollbarThumbFill,
44
- ...style,
45
- }}
46
- />
47
- )
48
- }
@@ -1,103 +0,0 @@
1
- import React from 'react'
2
-
3
- import { observer } from 'mobx-react'
4
-
5
- import { setFontSize } from '../setFontSize.ts'
6
- import { useCanvasAutorun } from '../useCanvasAutorun.ts'
7
- import { useColorContrast } from '../useColorContrast.ts'
8
- import { drawTextTrackContent } from './tracks/renderTracksSvg.ts'
9
-
10
- import type { MsaViewModel } from '../model.ts'
11
- import type { BasicTrack } from '../types.ts'
12
-
13
- const AnnotationBlock = observer(function ({
14
- track,
15
- model,
16
- offsetX,
17
- }: {
18
- track: BasicTrack
19
- model: MsaViewModel
20
- offsetX: number
21
- }) {
22
- const {
23
- blockSize,
24
- scrollX,
25
- colorScheme: modelColorScheme,
26
- rowHeight,
27
- highResScaleFactor,
28
- } = model
29
- const {
30
- model: { customColorScheme, data },
31
- } = track
32
-
33
- const colorScheme = customColorScheme ?? modelColorScheme
34
- const { theme, contrastScheme } = useColorContrast(colorScheme)
35
- const ref = useCanvasAutorun({
36
- draw: ctx => {
37
- const { bgColor, colWidth, fontSize } = model
38
- ctx.resetTransform()
39
- ctx.scale(highResScaleFactor, highResScaleFactor)
40
- ctx.clearRect(0, 0, blockSize, rowHeight)
41
- ctx.translate(-offsetX, 0)
42
- ctx.textAlign = 'center'
43
- setFontSize(ctx, fontSize)
44
-
45
- drawTextTrackContent({
46
- ctx,
47
- data,
48
- colorScheme,
49
- contrastScheme,
50
- bgColor,
51
- textColor: theme.palette.text.primary,
52
- colWidth,
53
- rowHeight,
54
- offsetX,
55
- blockSize,
56
- })
57
- },
58
- width: blockSize * highResScaleFactor,
59
- height: rowHeight * highResScaleFactor,
60
- deps: [model, offsetX, theme, contrastScheme, colorScheme, data],
61
- })
62
- return (
63
- <canvas
64
- ref={ref}
65
- height={rowHeight * highResScaleFactor}
66
- width={blockSize * highResScaleFactor}
67
- style={{
68
- position: 'absolute',
69
- left: scrollX + offsetX,
70
- width: blockSize,
71
- height: rowHeight,
72
- }}
73
- />
74
- )
75
- })
76
- const AnnotationTrack = observer(function ({
77
- track,
78
- model,
79
- }: {
80
- track: BasicTrack
81
- model: MsaViewModel
82
- }) {
83
- const { blocksX, msaAreaWidth, rowHeight } = model
84
- if (!track.model.data) {
85
- return null
86
- }
87
- return (
88
- <div
89
- style={{
90
- position: 'relative',
91
- height: rowHeight,
92
- width: msaAreaWidth,
93
- overflow: 'hidden',
94
- }}
95
- >
96
- {blocksX.map(bx => (
97
- <AnnotationBlock key={bx} track={track} model={model} offsetX={bx} />
98
- ))}
99
- </div>
100
- )
101
- })
102
-
103
- export default AnnotationTrack
@@ -1,247 +0,0 @@
1
- import { setFontSize } from '../../setFontSize.ts'
2
- import { visibleColRange } from '../msa/visibleColRange.ts'
3
-
4
- import type { MsaViewModel } from '../../model.ts'
5
- import type { BasicTrack } from '../../types.ts'
6
- import type { RenderCtx } from '../renderCtx.ts'
7
- import type { Theme } from '@mui/material'
8
-
9
- export function drawConservationBars({
10
- ctx,
11
- values,
12
- color,
13
- colWidth,
14
- trackHeight,
15
- offsetX,
16
- blockSize,
17
- }: {
18
- ctx: RenderCtx
19
- values: number[]
20
- color: string
21
- colWidth: number
22
- trackHeight: number
23
- offsetX: number
24
- blockSize: number
25
- }) {
26
- const { xStart, xEnd } = visibleColRange({
27
- offsetX,
28
- blockWidth: blockSize,
29
- colWidth,
30
- })
31
-
32
- ctx.fillStyle = color
33
- for (let i = xStart; i < xEnd && i < values.length; i++) {
34
- const value = values[i]!
35
- const barHeight = value * trackHeight
36
- const x = i * colWidth
37
- ctx.fillRect(x, trackHeight - barHeight, colWidth, barHeight)
38
- }
39
- }
40
-
41
- // the bar-track values live on model getters (kept off the plain track object so
42
- // the live canvas autorun stays reactive); select the right one by track id
43
- export function barTrackValues(model: MsaViewModel, trackId: string) {
44
- return trackId === 'property-conservation'
45
- ? model.propertyConservation
46
- : model.conservation
47
- }
48
-
49
- export function drawTextTrackContent({
50
- ctx,
51
- data,
52
- colorScheme,
53
- contrastScheme,
54
- bgColor,
55
- textColor,
56
- colWidth,
57
- rowHeight,
58
- offsetX,
59
- blockSize,
60
- }: {
61
- ctx: RenderCtx
62
- data: string | undefined
63
- colorScheme: Record<string, string>
64
- contrastScheme: Record<string, string>
65
- bgColor: boolean
66
- textColor: string
67
- colWidth: number
68
- rowHeight: number
69
- offsetX: number
70
- blockSize: number
71
- }) {
72
- const { xStart, xEnd } = visibleColRange({
73
- offsetX,
74
- blockWidth: blockSize,
75
- colWidth,
76
- })
77
- const str = data?.slice(xStart, xEnd)
78
- const drawLetters = rowHeight >= 10 && colWidth >= rowHeight / 2
79
-
80
- for (let i = 0; str && i < str.length; i++) {
81
- const letter = str[i]!
82
- const upper = letter.toUpperCase()
83
- const color = colorScheme[upper]
84
- const x = (xStart + i) * colWidth
85
- const filled = bgColor && !!color
86
- if (filled) {
87
- ctx.fillStyle = color!
88
- ctx.fillRect(x, 0, colWidth, rowHeight)
89
- }
90
- if (drawLetters) {
91
- // a letter on a colored tile needs the tile's contrast color; otherwise it
92
- // sits on the plain background and takes the theme's text color
93
- ctx.fillStyle = filled ? (contrastScheme[upper] ?? 'black') : textColor
94
- ctx.fillText(letter, x + colWidth / 2, rowHeight / 2 + 1)
95
- }
96
- }
97
- }
98
-
99
- export function renderConservationTrack({
100
- model,
101
- ctx,
102
- track,
103
- offsetX,
104
- offsetY,
105
- trackHeight,
106
- blockSizeXOverride,
107
- highResScaleFactorOverride,
108
- }: {
109
- model: MsaViewModel
110
- ctx: RenderCtx
111
- track: BasicTrack
112
- offsetX: number
113
- offsetY: number
114
- trackHeight: number
115
- blockSizeXOverride?: number
116
- highResScaleFactorOverride?: number
117
- }) {
118
- const { blockSize, colWidth, highResScaleFactor } = model
119
- const bx = blockSizeXOverride ?? blockSize
120
- const k = highResScaleFactorOverride ?? highResScaleFactor
121
-
122
- ctx.resetTransform()
123
- ctx.scale(k, k)
124
- ctx.translate(-offsetX, offsetY)
125
-
126
- drawConservationBars({
127
- ctx,
128
- values: barTrackValues(model, track.model.id),
129
- color: track.model.barColor ?? 'gray',
130
- colWidth,
131
- trackHeight,
132
- offsetX,
133
- blockSize: bx,
134
- })
135
-
136
- ctx.resetTransform()
137
- }
138
-
139
- export function renderTextTrack({
140
- model,
141
- ctx,
142
- track,
143
- offsetX,
144
- offsetY,
145
- contrastScheme,
146
- theme,
147
- blockSizeXOverride,
148
- highResScaleFactorOverride,
149
- }: {
150
- model: MsaViewModel
151
- ctx: RenderCtx
152
- track: BasicTrack
153
- offsetX: number
154
- offsetY: number
155
- contrastScheme: Record<string, string>
156
- theme: Theme
157
- blockSizeXOverride?: number
158
- highResScaleFactorOverride?: number
159
- }) {
160
- const {
161
- blockSize,
162
- bgColor,
163
- colorScheme: modelColorScheme,
164
- colWidth,
165
- fontSize,
166
- rowHeight,
167
- highResScaleFactor,
168
- } = model
169
-
170
- const { customColorScheme, data } = track.model
171
- const colorScheme = customColorScheme ?? modelColorScheme
172
- const bx = blockSizeXOverride ?? blockSize
173
- const k = highResScaleFactorOverride ?? highResScaleFactor
174
-
175
- ctx.resetTransform()
176
- ctx.scale(k, k)
177
- ctx.translate(-offsetX, offsetY)
178
- ctx.textAlign = 'center'
179
- setFontSize(ctx, fontSize)
180
-
181
- drawTextTrackContent({
182
- ctx,
183
- data,
184
- colorScheme,
185
- contrastScheme,
186
- bgColor,
187
- textColor: theme.palette.text.primary,
188
- colWidth,
189
- rowHeight,
190
- offsetX,
191
- blockSize: bx,
192
- })
193
-
194
- ctx.resetTransform()
195
- }
196
-
197
- export function renderAllTracks({
198
- model,
199
- ctx,
200
- offsetX,
201
- contrastScheme,
202
- theme,
203
- blockSizeXOverride,
204
- highResScaleFactorOverride,
205
- }: {
206
- model: MsaViewModel
207
- ctx: RenderCtx
208
- offsetX: number
209
- contrastScheme: Record<string, string>
210
- theme: Theme
211
- blockSizeXOverride?: number
212
- highResScaleFactorOverride?: number
213
- }) {
214
- const { turnedOnTracks } = model
215
- let currentY = 0
216
-
217
- for (const track of turnedOnTracks) {
218
- const trackHeight = track.model.height
219
-
220
- if (track.model.barColor !== undefined) {
221
- renderConservationTrack({
222
- model,
223
- ctx,
224
- track,
225
- offsetX,
226
- offsetY: currentY,
227
- trackHeight,
228
- blockSizeXOverride,
229
- highResScaleFactorOverride,
230
- })
231
- } else {
232
- renderTextTrack({
233
- model,
234
- ctx,
235
- track,
236
- offsetX,
237
- offsetY: currentY,
238
- contrastScheme,
239
- theme,
240
- blockSizeXOverride,
241
- highResScaleFactorOverride,
242
- })
243
- }
244
-
245
- currentY += trackHeight
246
- }
247
- }