react-msaview 5.0.4 → 5.0.5
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/bundle/index.js +3 -3
- package/bundle/index.js.map +1 -1
- package/dist/components/ConservationTrack.js +9 -9
- package/dist/components/ConservationTrack.js.map +1 -1
- package/dist/components/MSAView.js +13 -6
- package/dist/components/MSAView.js.map +1 -1
- package/dist/components/TextTrack.js +12 -17
- package/dist/components/TextTrack.js.map +1 -1
- package/dist/components/msa/MSAMouseoverCanvas.js +2 -1
- package/dist/components/msa/MSAMouseoverCanvas.js.map +1 -1
- package/dist/components/msa/renderMSAMouseover.js +2 -1
- package/dist/components/msa/renderMSAMouseover.js.map +1 -1
- package/dist/components/tracks/renderTracksSvg.d.ts +19 -0
- package/dist/components/tracks/renderTracksSvg.js +48 -29
- package/dist/components/tracks/renderTracksSvg.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/src/components/ConservationTrack.tsx +10 -11
- package/src/components/MSAView.tsx +17 -6
- package/src/components/TextTrack.tsx +12 -17
- package/src/components/msa/MSAMouseoverCanvas.tsx +2 -1
- package/src/components/msa/renderMSAMouseover.ts +3 -1
- package/src/components/tracks/renderTracksSvg.ts +86 -34
- package/src/version.ts +1 -1
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
import type { MsaViewModel } from '../../model.ts'
|
|
2
2
|
import type { BasicTrack } from '../../types.ts'
|
|
3
3
|
|
|
4
|
+
export function drawConservationBars({
|
|
5
|
+
ctx,
|
|
6
|
+
conservation,
|
|
7
|
+
colWidth,
|
|
8
|
+
trackHeight,
|
|
9
|
+
offsetX,
|
|
10
|
+
blockSize,
|
|
11
|
+
}: {
|
|
12
|
+
ctx: CanvasRenderingContext2D
|
|
13
|
+
conservation: number[]
|
|
14
|
+
colWidth: number
|
|
15
|
+
trackHeight: number
|
|
16
|
+
offsetX: number
|
|
17
|
+
blockSize: number
|
|
18
|
+
}) {
|
|
19
|
+
const xStart = Math.max(0, Math.floor(offsetX / colWidth))
|
|
20
|
+
const xEnd = Math.max(0, Math.ceil((offsetX + blockSize) / colWidth))
|
|
21
|
+
|
|
22
|
+
ctx.fillStyle = 'gray'
|
|
23
|
+
for (let i = xStart; i < xEnd && i < conservation.length; i++) {
|
|
24
|
+
const value = conservation[i]!
|
|
25
|
+
const barHeight = value * trackHeight
|
|
26
|
+
const x = i * colWidth
|
|
27
|
+
ctx.fillRect(x, trackHeight - barHeight, colWidth, barHeight)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function drawTextTrackContent({
|
|
32
|
+
ctx,
|
|
33
|
+
data,
|
|
34
|
+
colorScheme,
|
|
35
|
+
contrastScheme,
|
|
36
|
+
bgColor,
|
|
37
|
+
colWidth,
|
|
38
|
+
rowHeight,
|
|
39
|
+
offsetX,
|
|
40
|
+
blockSize,
|
|
41
|
+
}: {
|
|
42
|
+
ctx: CanvasRenderingContext2D
|
|
43
|
+
data: string | undefined
|
|
44
|
+
colorScheme: Record<string, string>
|
|
45
|
+
contrastScheme: Record<string, string>
|
|
46
|
+
bgColor: boolean
|
|
47
|
+
colWidth: number
|
|
48
|
+
rowHeight: number
|
|
49
|
+
offsetX: number
|
|
50
|
+
blockSize: number
|
|
51
|
+
}) {
|
|
52
|
+
const xStart = Math.max(0, Math.floor(offsetX / colWidth))
|
|
53
|
+
const xEnd = Math.max(0, Math.ceil((offsetX + blockSize) / colWidth))
|
|
54
|
+
const str = data?.slice(xStart, xEnd)
|
|
55
|
+
|
|
56
|
+
for (let i = 0; str && i < str.length; i++) {
|
|
57
|
+
const letter = str[i]!
|
|
58
|
+
const color = colorScheme[letter.toUpperCase()]
|
|
59
|
+
if (bgColor) {
|
|
60
|
+
const x = i * colWidth + offsetX - (offsetX % colWidth)
|
|
61
|
+
ctx.fillStyle = color || 'white'
|
|
62
|
+
ctx.fillRect(x, 0, colWidth, rowHeight)
|
|
63
|
+
if (rowHeight >= 10 && colWidth >= rowHeight / 2) {
|
|
64
|
+
ctx.fillStyle = contrastScheme[letter.toUpperCase()] || 'black'
|
|
65
|
+
ctx.fillText(letter, x + colWidth / 2, rowHeight / 2 + 1)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
4
71
|
export function renderConservationTrack({
|
|
5
72
|
model,
|
|
6
73
|
ctx,
|
|
@@ -26,18 +93,14 @@ export function renderConservationTrack({
|
|
|
26
93
|
ctx.scale(k, k)
|
|
27
94
|
ctx.translate(-offsetX, offsetY)
|
|
28
95
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const hue = value * 120
|
|
38
|
-
ctx.fillStyle = `hsl(${hue}, 70%, 50%)`
|
|
39
|
-
ctx.fillRect(x, trackHeight - barHeight, colWidth, barHeight)
|
|
40
|
-
}
|
|
96
|
+
drawConservationBars({
|
|
97
|
+
ctx,
|
|
98
|
+
conservation,
|
|
99
|
+
colWidth,
|
|
100
|
+
trackHeight,
|
|
101
|
+
offsetX,
|
|
102
|
+
blockSize: bx,
|
|
103
|
+
})
|
|
41
104
|
|
|
42
105
|
ctx.resetTransform()
|
|
43
106
|
}
|
|
@@ -82,28 +145,17 @@ export function renderTextTrack({
|
|
|
82
145
|
ctx.textAlign = 'center'
|
|
83
146
|
ctx.font = ctx.font.replace(/\d+px/, `${fontSize}px`)
|
|
84
147
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
ctx.fillRect(x, 0, colWidth, rowHeight)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (rowHeight >= 10 && colWidth >= rowHeight / 2) {
|
|
100
|
-
ctx.fillStyle =
|
|
101
|
-
bgColor && color
|
|
102
|
-
? (contrastScheme[letter.toUpperCase()] ?? 'black')
|
|
103
|
-
: 'black'
|
|
104
|
-
ctx.fillText(letter, x + colWidth / 2, rowHeight / 2 + 1)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
148
|
+
drawTextTrackContent({
|
|
149
|
+
ctx,
|
|
150
|
+
data,
|
|
151
|
+
colorScheme,
|
|
152
|
+
contrastScheme,
|
|
153
|
+
bgColor,
|
|
154
|
+
colWidth,
|
|
155
|
+
rowHeight,
|
|
156
|
+
offsetX,
|
|
157
|
+
blockSize: bx,
|
|
158
|
+
})
|
|
107
159
|
|
|
108
160
|
ctx.resetTransform()
|
|
109
161
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.5'
|