react-msaview 2.1.4 → 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.
- package/bundle/index.js +37 -37
- package/dist/DialogQueue.d.ts +25 -0
- package/dist/DialogQueue.js +46 -0
- package/dist/DialogQueue.js.map +1 -0
- package/dist/UniprotTrack.js.map +1 -1
- package/dist/colorSchemes.js.map +1 -1
- package/dist/components/BoxTrackBlock.js +3 -2
- package/dist/components/BoxTrackBlock.js.map +1 -1
- package/dist/components/Header.js +10 -13
- package/dist/components/Header.js.map +1 -1
- package/dist/components/ImportForm/ImportFormExamples.d.ts +6 -0
- package/dist/components/ImportForm/ImportFormExamples.js +50 -0
- package/dist/components/ImportForm/ImportFormExamples.js.map +1 -0
- package/dist/components/ImportForm/data/seq2.js.map +1 -0
- package/dist/components/{ImportForm.d.ts → ImportForm/index.d.ts} +1 -1
- package/dist/components/ImportForm/index.js +31 -0
- package/dist/components/ImportForm/index.js.map +1 -0
- package/dist/components/ImportForm/util.d.ts +3 -0
- package/dist/components/ImportForm/util.js +15 -0
- package/dist/components/ImportForm/util.js.map +1 -0
- package/dist/components/{MSABlock.d.ts → MSAPanel/MSABlock.d.ts} +1 -1
- package/dist/components/MSAPanel/MSABlock.js +46 -0
- package/dist/components/MSAPanel/MSABlock.js.map +1 -0
- package/dist/components/{MSACanvas.d.ts → MSAPanel/MSACanvas.d.ts} +1 -1
- package/dist/components/{MSACanvas.js → MSAPanel/MSACanvas.js} +10 -3
- package/dist/components/MSAPanel/MSACanvas.js.map +1 -0
- package/dist/components/{MSAMouseoverCanvas.d.ts → MSAPanel/MSAMouseoverCanvas.d.ts} +1 -1
- package/dist/components/MSAPanel/MSAMouseoverCanvas.js +50 -0
- package/dist/components/MSAPanel/MSAMouseoverCanvas.js.map +1 -0
- package/dist/components/MSAPanel/index.d.ts +5 -0
- package/dist/components/MSAPanel/index.js +9 -0
- package/dist/components/MSAPanel/index.js.map +1 -0
- package/dist/components/MSAPanel/renderMSABlock.d.ts +8 -0
- package/dist/components/MSAPanel/renderMSABlock.js +81 -0
- package/dist/components/MSAPanel/renderMSABlock.js.map +1 -0
- package/dist/components/MSAView.d.ts +2 -2
- package/dist/components/MSAView.js +26 -31
- package/dist/components/MSAView.js.map +1 -1
- package/dist/components/Minimap.d.ts +6 -0
- package/dist/components/Minimap.js +72 -0
- package/dist/components/Minimap.js.map +1 -0
- package/dist/components/OverviewRubberband.d.ts +8 -0
- package/dist/components/OverviewRubberband.js +185 -0
- package/dist/components/OverviewRubberband.js.map +1 -0
- package/dist/components/ResizeHandles.js.map +1 -1
- package/dist/components/Rubberband.js +13 -1
- package/dist/components/Rubberband.js.map +1 -1
- package/dist/components/TextTrack.js +3 -2
- package/dist/components/TextTrack.js.map +1 -1
- package/dist/components/Track.js +5 -5
- package/dist/components/Track.js.map +1 -1
- package/dist/components/{TreeBranchMenu.d.ts → TreePanel/TreeBranchMenu.d.ts} +1 -1
- package/dist/components/TreePanel/TreeBranchMenu.js.map +1 -0
- package/dist/components/{TreeCanvas.d.ts → TreePanel/TreeCanvas.d.ts} +1 -1
- package/dist/components/{TreeCanvas.js → TreePanel/TreeCanvas.js} +1 -1
- package/dist/components/TreePanel/TreeCanvas.js.map +1 -0
- package/dist/components/{TreeCanvasBlock.d.ts → TreePanel/TreeCanvasBlock.d.ts} +1 -1
- package/dist/components/TreePanel/TreeCanvasBlock.js +117 -0
- package/dist/components/TreePanel/TreeCanvasBlock.js.map +1 -0
- package/dist/components/{TreeMenu.d.ts → TreePanel/TreeMenu.d.ts} +1 -1
- package/dist/components/{TreeMenu.js → TreePanel/TreeMenu.js} +9 -5
- package/dist/components/TreePanel/TreeMenu.js.map +1 -0
- package/dist/components/{TreeRuler.d.ts → TreePanel/TreeRuler.d.ts} +1 -1
- package/dist/components/TreePanel/TreeRuler.js +8 -0
- package/dist/components/TreePanel/TreeRuler.js.map +1 -0
- package/dist/components/{dialogs → TreePanel/dialogs}/TreeNodeInfoDlg.d.ts +1 -1
- package/dist/components/TreePanel/dialogs/TreeNodeInfoDlg.js.map +1 -0
- package/dist/components/TreePanel/index.d.ts +6 -0
- package/dist/components/TreePanel/index.js +10 -0
- package/dist/components/TreePanel/index.js.map +1 -0
- package/dist/components/TreePanel/renderTreeCanvas.d.ts +36 -0
- package/dist/components/TreePanel/renderTreeCanvas.js +153 -0
- package/dist/components/TreePanel/renderTreeCanvas.js.map +1 -0
- package/dist/components/dialogs/{AboutDlg.js → AboutDialog.js} +1 -1
- package/dist/components/dialogs/AboutDialog.js.map +1 -0
- package/dist/components/dialogs/{AddTrackDlg.js → AddTrackDialog.js} +1 -1
- package/dist/components/dialogs/AddTrackDialog.js.map +1 -0
- package/dist/components/dialogs/{AnnotationDlg.js → AnnotationDialog.js} +1 -1
- package/dist/components/dialogs/AnnotationDialog.js.map +1 -0
- package/dist/components/dialogs/{MetadataDlg.js → MetadataDialog.js} +1 -1
- package/dist/components/dialogs/MetadataDialog.js.map +1 -0
- package/dist/components/dialogs/SettingsDialog.js +54 -0
- package/dist/components/dialogs/SettingsDialog.js.map +1 -0
- package/dist/components/dialogs/{TrackInfoDlg.js → TrackInfoDialog.js} +1 -1
- package/dist/components/dialogs/TrackInfoDialog.js.map +1 -0
- package/dist/components/dialogs/{TracklistDlg.js → TracklistDialog.js} +1 -1
- package/dist/components/dialogs/TracklistDialog.js.map +1 -0
- package/dist/components/util.js.map +1 -1
- package/dist/layout.js.map +1 -1
- package/dist/model.d.ts +80 -47
- package/dist/model.js +130 -70
- package/dist/model.js.map +1 -1
- package/dist/parseNewick.js.map +1 -1
- package/dist/parsers/StockholmMSA.js.map +1 -1
- package/dist/util.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -5
- package/src/DialogQueue.ts +47 -0
- package/src/components/BoxTrackBlock.tsx +3 -1
- package/src/components/Header.tsx +9 -10
- package/src/components/ImportForm/ImportFormExamples.tsx +133 -0
- package/src/components/ImportForm/index.tsx +63 -0
- package/src/components/ImportForm/util.ts +20 -0
- package/src/components/MSAPanel/MSABlock.tsx +81 -0
- package/src/components/{MSACanvas.tsx → MSAPanel/MSACanvas.tsx} +17 -5
- package/src/components/MSAPanel/MSAMouseoverCanvas.tsx +92 -0
- package/src/components/MSAPanel/index.tsx +13 -0
- package/src/components/MSAPanel/renderMSABlock.ts +160 -0
- package/src/components/MSAView.tsx +36 -56
- package/src/components/Minimap.tsx +102 -0
- package/src/components/OverviewRubberband.tsx +283 -0
- package/src/components/Rubberband.tsx +14 -1
- package/src/components/TextTrack.tsx +3 -1
- package/src/components/Track.tsx +5 -5
- package/src/components/{TreeBranchMenu.tsx → TreePanel/TreeBranchMenu.tsx} +1 -1
- package/src/components/{TreeCanvas.tsx → TreePanel/TreeCanvas.tsx} +2 -3
- package/src/components/TreePanel/TreeCanvasBlock.tsx +190 -0
- package/src/components/{TreeMenu.tsx → TreePanel/TreeMenu.tsx} +10 -6
- package/src/components/{TreeRuler.tsx → TreePanel/TreeRuler.tsx} +3 -3
- package/src/components/{dialogs → TreePanel/dialogs}/TreeNodeInfoDlg.tsx +1 -1
- package/src/components/TreePanel/index.tsx +16 -0
- package/src/components/TreePanel/renderTreeCanvas.ts +245 -0
- package/src/components/dialogs/{SettingsDlg.tsx → SettingsDialog.tsx} +72 -47
- package/src/model.ts +157 -79
- package/src/version.ts +1 -1
- package/dist/components/ImportForm.js +0 -84
- package/dist/components/ImportForm.js.map +0 -1
- package/dist/components/MSABlock.js +0 -103
- package/dist/components/MSABlock.js.map +0 -1
- package/dist/components/MSACanvas.js.map +0 -1
- package/dist/components/MSAMouseoverCanvas.js +0 -52
- package/dist/components/MSAMouseoverCanvas.js.map +0 -1
- package/dist/components/Ruler.d.ts +0 -6
- package/dist/components/Ruler.js +0 -52
- package/dist/components/Ruler.js.map +0 -1
- package/dist/components/TreeBranchMenu.js.map +0 -1
- package/dist/components/TreeCanvas.js.map +0 -1
- package/dist/components/TreeCanvasBlock.js +0 -255
- package/dist/components/TreeCanvasBlock.js.map +0 -1
- package/dist/components/TreeMenu.js.map +0 -1
- package/dist/components/TreeRuler.js +0 -8
- package/dist/components/TreeRuler.js.map +0 -1
- package/dist/components/data/seq2.js.map +0 -1
- package/dist/components/dialogs/AboutDlg.js.map +0 -1
- package/dist/components/dialogs/AddTrackDlg.js.map +0 -1
- package/dist/components/dialogs/AnnotationDlg.js.map +0 -1
- package/dist/components/dialogs/MetadataDlg.js.map +0 -1
- package/dist/components/dialogs/SettingsDlg.js +0 -48
- package/dist/components/dialogs/SettingsDlg.js.map +0 -1
- package/dist/components/dialogs/TrackInfoDlg.js.map +0 -1
- package/dist/components/dialogs/TracklistDlg.js.map +0 -1
- package/dist/components/dialogs/TreeNodeInfoDlg.js.map +0 -1
- package/src/components/ImportForm.tsx +0 -192
- package/src/components/MSABlock.tsx +0 -164
- package/src/components/MSAMouseoverCanvas.tsx +0 -87
- package/src/components/Ruler.tsx +0 -123
- package/src/components/TreeCanvasBlock.tsx +0 -363
- /package/dist/components/{data → ImportForm/data}/seq2.d.ts +0 -0
- /package/dist/components/{data → ImportForm/data}/seq2.js +0 -0
- /package/dist/components/{TreeBranchMenu.js → TreePanel/TreeBranchMenu.js} +0 -0
- /package/dist/components/{dialogs → TreePanel/dialogs}/TreeNodeInfoDlg.js +0 -0
- /package/dist/components/dialogs/{AboutDlg.d.ts → AboutDialog.d.ts} +0 -0
- /package/dist/components/dialogs/{AddTrackDlg.d.ts → AddTrackDialog.d.ts} +0 -0
- /package/dist/components/dialogs/{AnnotationDlg.d.ts → AnnotationDialog.d.ts} +0 -0
- /package/dist/components/dialogs/{MetadataDlg.d.ts → MetadataDialog.d.ts} +0 -0
- /package/dist/components/dialogs/{SettingsDlg.d.ts → SettingsDialog.d.ts} +0 -0
- /package/dist/components/dialogs/{TrackInfoDlg.d.ts → TrackInfoDialog.d.ts} +0 -0
- /package/dist/components/dialogs/{TracklistDlg.d.ts → TracklistDialog.d.ts} +0 -0
- /package/src/components/{data → ImportForm/data}/seq2.ts +0 -0
- /package/src/components/dialogs/{AboutDlg.tsx → AboutDialog.tsx} +0 -0
- /package/src/components/dialogs/{AddTrackDlg.tsx → AddTrackDialog.tsx} +0 -0
- /package/src/components/dialogs/{AnnotationDlg.tsx → AnnotationDialog.tsx} +0 -0
- /package/src/components/dialogs/{MetadataDlg.tsx → MetadataDialog.tsx} +0 -0
- /package/src/components/dialogs/{TrackInfoDlg.tsx → TrackInfoDialog.tsx} +0 -0
- /package/src/components/dialogs/{TracklistDlg.tsx → TracklistDialog.tsx} +0 -0
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { Button, Container, Grid, Typography, Link } from '@mui/material'
|
|
3
|
-
import { observer } from 'mobx-react'
|
|
4
|
-
import { FileSelector } from '@jbrowse/core/ui'
|
|
5
|
-
import { FileLocation } from '@jbrowse/core/util/types'
|
|
6
|
-
|
|
7
|
-
// locals
|
|
8
|
-
import { MsaViewModel } from '../model'
|
|
9
|
-
import { smallTree, smallMSA, smallMSAOnly } from './data/seq2'
|
|
10
|
-
|
|
11
|
-
async function load(
|
|
12
|
-
model: MsaViewModel,
|
|
13
|
-
msaFile?: FileLocation,
|
|
14
|
-
treeFile?: FileLocation,
|
|
15
|
-
) {
|
|
16
|
-
model.setError(undefined)
|
|
17
|
-
try {
|
|
18
|
-
if (msaFile) {
|
|
19
|
-
await model.setMSAFilehandle(msaFile)
|
|
20
|
-
}
|
|
21
|
-
if (treeFile) {
|
|
22
|
-
await model.setTreeFilehandle(treeFile)
|
|
23
|
-
}
|
|
24
|
-
} catch (e) {
|
|
25
|
-
model.setError(e)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const ListItem = ({
|
|
30
|
-
onClick,
|
|
31
|
-
model,
|
|
32
|
-
children,
|
|
33
|
-
}: {
|
|
34
|
-
onClick: () => void
|
|
35
|
-
model: MsaViewModel
|
|
36
|
-
children: React.ReactNode
|
|
37
|
-
}) => (
|
|
38
|
-
<li>
|
|
39
|
-
<Link
|
|
40
|
-
onClick={event => {
|
|
41
|
-
model.setError(undefined)
|
|
42
|
-
event.preventDefault()
|
|
43
|
-
onClick()
|
|
44
|
-
}}
|
|
45
|
-
href="#"
|
|
46
|
-
>
|
|
47
|
-
<Typography display="inline">{children}</Typography>
|
|
48
|
-
</Link>
|
|
49
|
-
</li>
|
|
50
|
-
)
|
|
51
|
-
export default observer(({ model }: { model: MsaViewModel }) => {
|
|
52
|
-
const [msaFile, setMsaFile] = useState<FileLocation>()
|
|
53
|
-
const [treeFile, setTreeFile] = useState<FileLocation>()
|
|
54
|
-
const { error } = model
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Container>
|
|
58
|
-
<div style={{ width: '50%' }}>
|
|
59
|
-
{error ? (
|
|
60
|
-
<div style={{ padding: 20 }}>
|
|
61
|
-
<Typography color="error">Error: {`${error}`}</Typography>
|
|
62
|
-
</div>
|
|
63
|
-
) : null}
|
|
64
|
-
<Typography>
|
|
65
|
-
Open an MSA file (stockholm or clustal format) and/or a tree file
|
|
66
|
-
(newick format).
|
|
67
|
-
</Typography>
|
|
68
|
-
<Typography color="error">
|
|
69
|
-
Note: you can open up just an MSA or just a tree, both are not
|
|
70
|
-
required. Some MSA files e.g. stockholm format have an embedded tree
|
|
71
|
-
also and this is fine, and opening a separate tree file is not
|
|
72
|
-
required.
|
|
73
|
-
</Typography>
|
|
74
|
-
</div>
|
|
75
|
-
|
|
76
|
-
<Grid container spacing={10} justifyContent="center" alignItems="center">
|
|
77
|
-
<Grid item>
|
|
78
|
-
<Typography>MSA file or URL</Typography>
|
|
79
|
-
<FileSelector location={msaFile} setLocation={setMsaFile} />
|
|
80
|
-
<Typography>Tree file or URL</Typography>
|
|
81
|
-
<FileSelector location={treeFile} setLocation={setTreeFile} />
|
|
82
|
-
</Grid>
|
|
83
|
-
|
|
84
|
-
<Grid item>
|
|
85
|
-
<Button
|
|
86
|
-
onClick={() => load(model, msaFile, treeFile)}
|
|
87
|
-
variant="contained"
|
|
88
|
-
color="primary"
|
|
89
|
-
disabled={!msaFile && !treeFile}
|
|
90
|
-
>
|
|
91
|
-
Open
|
|
92
|
-
</Button>
|
|
93
|
-
</Grid>
|
|
94
|
-
|
|
95
|
-
<Grid item>
|
|
96
|
-
<Typography>Examples</Typography>
|
|
97
|
-
<ul>
|
|
98
|
-
<ListItem
|
|
99
|
-
model={model}
|
|
100
|
-
onClick={() =>
|
|
101
|
-
load(model, undefined, {
|
|
102
|
-
uri: 'https://jbrowse.org/genomes/newick_trees/sarscov2phylo.pub.ft.nh',
|
|
103
|
-
locationType: 'UriLocation',
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
>
|
|
107
|
-
230k COVID-19 samples (tree only)
|
|
108
|
-
</ListItem>
|
|
109
|
-
<ListItem
|
|
110
|
-
model={model}
|
|
111
|
-
onClick={() => {
|
|
112
|
-
model.setData({ msa: smallMSA, tree: smallTree })
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
Small protein MSA+tree
|
|
116
|
-
</ListItem>
|
|
117
|
-
<ListItem
|
|
118
|
-
model={model}
|
|
119
|
-
onClick={() => {
|
|
120
|
-
model.setData({ msa: smallMSAOnly })
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
Small MSA only
|
|
124
|
-
</ListItem>
|
|
125
|
-
<ListItem
|
|
126
|
-
model={model}
|
|
127
|
-
onClick={() =>
|
|
128
|
-
load(model, {
|
|
129
|
-
uri: 'https://ihh.github.io/abrowse/build/pfam-cov2.stock',
|
|
130
|
-
locationType: 'UriLocation',
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
>
|
|
134
|
-
PFAM SARS-CoV2 multi-stockholm
|
|
135
|
-
</ListItem>
|
|
136
|
-
<ListItem
|
|
137
|
-
model={model}
|
|
138
|
-
onClick={() =>
|
|
139
|
-
load(model, {
|
|
140
|
-
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/Lysine.stock',
|
|
141
|
-
locationType: 'UriLocation',
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
>
|
|
145
|
-
Lysine stockholm file
|
|
146
|
-
</ListItem>
|
|
147
|
-
<ListItem
|
|
148
|
-
model={model}
|
|
149
|
-
onClick={() =>
|
|
150
|
-
load(model, {
|
|
151
|
-
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/PF01601_full.txt',
|
|
152
|
-
locationType: 'UriLocation',
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
>
|
|
156
|
-
PF01601 stockholm file (SARS-CoV2 spike protein)
|
|
157
|
-
</ListItem>
|
|
158
|
-
<ListItem
|
|
159
|
-
model={model}
|
|
160
|
-
onClick={() =>
|
|
161
|
-
load(model, {
|
|
162
|
-
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/europe_covid.fa',
|
|
163
|
-
locationType: 'UriLocation',
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
>
|
|
167
|
-
Europe COVID full genomes (LR883044.1 and 199 other sequences)
|
|
168
|
-
</ListItem>
|
|
169
|
-
<ListItem
|
|
170
|
-
model={model}
|
|
171
|
-
onClick={() =>
|
|
172
|
-
load(
|
|
173
|
-
model,
|
|
174
|
-
{
|
|
175
|
-
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.fa',
|
|
176
|
-
locationType: 'UriLocation',
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.nh',
|
|
180
|
-
locationType: 'UriLocation',
|
|
181
|
-
},
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
>
|
|
185
|
-
MAFFT+VeryFastTree(17.9k samples)
|
|
186
|
-
</ListItem>
|
|
187
|
-
</ul>
|
|
188
|
-
</Grid>
|
|
189
|
-
</Grid>
|
|
190
|
-
</Container>
|
|
191
|
-
)
|
|
192
|
-
})
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useMemo } from 'react'
|
|
2
|
-
import { useTheme } from '@mui/material'
|
|
3
|
-
import { observer } from 'mobx-react'
|
|
4
|
-
|
|
5
|
-
// locals
|
|
6
|
-
import { MsaViewModel } from '../model'
|
|
7
|
-
import { colorContrast } from '../util'
|
|
8
|
-
import { getClustalXColor, getPercentIdentityColor } from '../colorSchemes'
|
|
9
|
-
|
|
10
|
-
const MSABlock = observer(function ({
|
|
11
|
-
model,
|
|
12
|
-
offsetX,
|
|
13
|
-
offsetY,
|
|
14
|
-
}: {
|
|
15
|
-
model: MsaViewModel
|
|
16
|
-
offsetX: number
|
|
17
|
-
offsetY: number
|
|
18
|
-
}) {
|
|
19
|
-
const {
|
|
20
|
-
MSA,
|
|
21
|
-
colWidth,
|
|
22
|
-
bgColor,
|
|
23
|
-
columns,
|
|
24
|
-
rowHeight,
|
|
25
|
-
scrollY,
|
|
26
|
-
scrollX,
|
|
27
|
-
hierarchy,
|
|
28
|
-
colorScheme,
|
|
29
|
-
colorSchemeName,
|
|
30
|
-
blockSize,
|
|
31
|
-
highResScaleFactor,
|
|
32
|
-
colStats,
|
|
33
|
-
} = model
|
|
34
|
-
const theme = useTheme()
|
|
35
|
-
|
|
36
|
-
const contrastScheme = useMemo(
|
|
37
|
-
() => colorContrast(colorScheme, theme),
|
|
38
|
-
[colorScheme, theme],
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
const ref = useRef<HTMLCanvasElement>(null)
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!ref.current) {
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const ctx = ref.current.getContext('2d')
|
|
48
|
-
if (!ctx) {
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
ctx.resetTransform()
|
|
53
|
-
ctx.scale(highResScaleFactor, highResScaleFactor)
|
|
54
|
-
ctx.clearRect(0, 0, blockSize, blockSize)
|
|
55
|
-
ctx.translate(-offsetX, rowHeight / 2 - offsetY)
|
|
56
|
-
ctx.textAlign = 'center'
|
|
57
|
-
ctx.font = ctx.font.replace(/\d+px/, `${Math.max(8, rowHeight - 8)}px`)
|
|
58
|
-
|
|
59
|
-
const leaves = hierarchy.leaves()
|
|
60
|
-
const b = blockSize
|
|
61
|
-
|
|
62
|
-
// slice vertical rows, e.g. tree leaves, avoid negative slice
|
|
63
|
-
const yStart = Math.max(0, Math.floor((offsetY - rowHeight) / rowHeight))
|
|
64
|
-
const yEnd = Math.max(0, Math.ceil((offsetY + b + rowHeight) / rowHeight))
|
|
65
|
-
|
|
66
|
-
// slice horizontal visible letters, avoid negative slice
|
|
67
|
-
const xStart = Math.max(0, Math.floor(offsetX / colWidth))
|
|
68
|
-
const xEnd = Math.max(0, Math.ceil((offsetX + b) / colWidth))
|
|
69
|
-
const visibleLeaves = leaves.slice(yStart, yEnd)
|
|
70
|
-
for (const node of visibleLeaves) {
|
|
71
|
-
const {
|
|
72
|
-
// @ts-expect-error
|
|
73
|
-
x: y,
|
|
74
|
-
data: { name },
|
|
75
|
-
} = node
|
|
76
|
-
|
|
77
|
-
const str = columns[name]?.slice(xStart, xEnd)
|
|
78
|
-
for (let i = 0; i < str?.length; i++) {
|
|
79
|
-
const letter = str[i]
|
|
80
|
-
const color =
|
|
81
|
-
colorSchemeName === 'clustalx_protein_dynamic'
|
|
82
|
-
? getClustalXColor(colStats[xStart + i], model, name, xStart + i)
|
|
83
|
-
: colorSchemeName === 'percent_identity_dynamic'
|
|
84
|
-
? getPercentIdentityColor(
|
|
85
|
-
colStats[xStart + i],
|
|
86
|
-
model,
|
|
87
|
-
name,
|
|
88
|
-
xStart + i,
|
|
89
|
-
)
|
|
90
|
-
: colorScheme[letter.toUpperCase()]
|
|
91
|
-
if (bgColor) {
|
|
92
|
-
const x = i * colWidth + offsetX - (offsetX % colWidth)
|
|
93
|
-
ctx.fillStyle = color || 'white'
|
|
94
|
-
ctx.fillRect(x, y - rowHeight, colWidth, rowHeight)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (rowHeight >= 5 && colWidth > rowHeight / 2) {
|
|
100
|
-
for (const node of visibleLeaves) {
|
|
101
|
-
const {
|
|
102
|
-
// @ts-expect-error
|
|
103
|
-
x: y,
|
|
104
|
-
data: { name },
|
|
105
|
-
} = node
|
|
106
|
-
|
|
107
|
-
const str = columns[name]?.slice(xStart, xEnd)
|
|
108
|
-
for (let i = 0; i < str?.length; i++) {
|
|
109
|
-
const letter = str[i]
|
|
110
|
-
const color = colorScheme[letter.toUpperCase()]
|
|
111
|
-
const contrast = contrastScheme[letter.toUpperCase()] || 'black'
|
|
112
|
-
const x = i * colWidth + offsetX - (offsetX % colWidth)
|
|
113
|
-
|
|
114
|
-
// note: -rowHeight/4 matches +rowHeight/4 in tree
|
|
115
|
-
ctx.fillStyle = bgColor ? contrast : color || 'black'
|
|
116
|
-
ctx.fillText(letter, x + colWidth / 2, y - rowHeight / 4)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
-
}, [
|
|
122
|
-
MSA,
|
|
123
|
-
highResScaleFactor,
|
|
124
|
-
columns,
|
|
125
|
-
colorScheme,
|
|
126
|
-
contrastScheme,
|
|
127
|
-
bgColor,
|
|
128
|
-
rowHeight,
|
|
129
|
-
colWidth,
|
|
130
|
-
hierarchy,
|
|
131
|
-
offsetX,
|
|
132
|
-
offsetY,
|
|
133
|
-
blockSize,
|
|
134
|
-
])
|
|
135
|
-
return (
|
|
136
|
-
<canvas
|
|
137
|
-
ref={ref}
|
|
138
|
-
onMouseMove={event => {
|
|
139
|
-
if (!ref.current) {
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
const { left, top } = ref.current.getBoundingClientRect()
|
|
143
|
-
const mouseX = event.clientX - left + offsetX
|
|
144
|
-
const mouseY = event.clientY - top + offsetY
|
|
145
|
-
model.setMousePos(
|
|
146
|
-
Math.floor(mouseX / colWidth) + 1,
|
|
147
|
-
Math.floor(mouseY / rowHeight),
|
|
148
|
-
)
|
|
149
|
-
}}
|
|
150
|
-
onMouseLeave={() => model.setMousePos()}
|
|
151
|
-
width={blockSize * highResScaleFactor}
|
|
152
|
-
height={blockSize * highResScaleFactor}
|
|
153
|
-
style={{
|
|
154
|
-
position: 'absolute',
|
|
155
|
-
top: scrollY + offsetY,
|
|
156
|
-
left: scrollX + offsetX,
|
|
157
|
-
width: blockSize,
|
|
158
|
-
height: blockSize,
|
|
159
|
-
}}
|
|
160
|
-
/>
|
|
161
|
-
)
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
export default MSABlock
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
|
|
4
|
-
// locals
|
|
5
|
-
import { MsaViewModel } from '../model'
|
|
6
|
-
import { sum } from '@jbrowse/core/util'
|
|
7
|
-
|
|
8
|
-
const MSAMouseoverCanvas = observer(function ({
|
|
9
|
-
model,
|
|
10
|
-
}: {
|
|
11
|
-
model: MsaViewModel
|
|
12
|
-
}) {
|
|
13
|
-
const ref = useRef<HTMLCanvasElement>(null)
|
|
14
|
-
const {
|
|
15
|
-
height,
|
|
16
|
-
width,
|
|
17
|
-
treeAreaWidth,
|
|
18
|
-
resizeHandleWidth,
|
|
19
|
-
rulerHeight,
|
|
20
|
-
turnedOnTracks,
|
|
21
|
-
scrollX,
|
|
22
|
-
scrollY,
|
|
23
|
-
mouseCol,
|
|
24
|
-
mouseRow,
|
|
25
|
-
rowHeight,
|
|
26
|
-
colWidth,
|
|
27
|
-
} = model
|
|
28
|
-
const totalTrackAreaHeight = sum(turnedOnTracks.map(r => r.model.height))
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (!ref.current) {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const ctx = ref.current.getContext('2d')
|
|
35
|
-
if (!ctx) {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
ctx.resetTransform()
|
|
40
|
-
ctx.clearRect(0, 0, width, height)
|
|
41
|
-
|
|
42
|
-
ctx.fillStyle = 'rgba(0,0,0,0.15)'
|
|
43
|
-
if (mouseCol !== undefined) {
|
|
44
|
-
const x =
|
|
45
|
-
(mouseCol - 1) * colWidth + scrollX + treeAreaWidth + resizeHandleWidth
|
|
46
|
-
|
|
47
|
-
ctx.fillRect(x, 0, colWidth, height)
|
|
48
|
-
}
|
|
49
|
-
if (mouseRow !== undefined) {
|
|
50
|
-
const y =
|
|
51
|
-
mouseRow * rowHeight + scrollY + rulerHeight + totalTrackAreaHeight
|
|
52
|
-
ctx.fillRect(treeAreaWidth + resizeHandleWidth, y, width, rowHeight)
|
|
53
|
-
}
|
|
54
|
-
}, [
|
|
55
|
-
mouseCol,
|
|
56
|
-
colWidth,
|
|
57
|
-
scrollY,
|
|
58
|
-
totalTrackAreaHeight,
|
|
59
|
-
mouseRow,
|
|
60
|
-
rowHeight,
|
|
61
|
-
rulerHeight,
|
|
62
|
-
scrollX,
|
|
63
|
-
height,
|
|
64
|
-
resizeHandleWidth,
|
|
65
|
-
treeAreaWidth,
|
|
66
|
-
width,
|
|
67
|
-
])
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<canvas
|
|
71
|
-
ref={ref}
|
|
72
|
-
width={width}
|
|
73
|
-
height={height}
|
|
74
|
-
style={{
|
|
75
|
-
position: 'absolute',
|
|
76
|
-
top: 0,
|
|
77
|
-
left: 0,
|
|
78
|
-
width,
|
|
79
|
-
height,
|
|
80
|
-
zIndex: 1000,
|
|
81
|
-
pointerEvents: 'none',
|
|
82
|
-
}}
|
|
83
|
-
/>
|
|
84
|
-
)
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
export default MSAMouseoverCanvas
|
package/src/components/Ruler.tsx
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react'
|
|
2
|
-
import { makeStyles } from 'tss-react/mui'
|
|
3
|
-
import { observer } from 'mobx-react'
|
|
4
|
-
// locals
|
|
5
|
-
import { MsaViewModel } from '../model'
|
|
6
|
-
import { makeTicks, mathPower } from './util'
|
|
7
|
-
|
|
8
|
-
const useStyles = makeStyles()({
|
|
9
|
-
majorTickLabel: {
|
|
10
|
-
fontSize: '11px',
|
|
11
|
-
},
|
|
12
|
-
majorTick: {
|
|
13
|
-
stroke: '#555',
|
|
14
|
-
},
|
|
15
|
-
minorTick: {
|
|
16
|
-
stroke: '#999',
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
function RulerBlock({
|
|
21
|
-
start,
|
|
22
|
-
end,
|
|
23
|
-
bpPerPx,
|
|
24
|
-
reversed,
|
|
25
|
-
major,
|
|
26
|
-
minor,
|
|
27
|
-
}: {
|
|
28
|
-
start: number
|
|
29
|
-
end: number
|
|
30
|
-
bpPerPx: number
|
|
31
|
-
reversed?: boolean
|
|
32
|
-
major?: boolean
|
|
33
|
-
minor?: boolean
|
|
34
|
-
}) {
|
|
35
|
-
const { classes } = useStyles()
|
|
36
|
-
const ticks = makeTicks(start, end, bpPerPx, major, minor)
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
{ticks.map(tick => {
|
|
40
|
-
const x = (reversed ? end - tick.base : tick.base - start) / bpPerPx
|
|
41
|
-
return (
|
|
42
|
-
<line
|
|
43
|
-
key={tick.base}
|
|
44
|
-
x1={x}
|
|
45
|
-
x2={x}
|
|
46
|
-
y1={11}
|
|
47
|
-
y2={tick.type === 'major' ? 11 + 6 : 11 + 4}
|
|
48
|
-
strokeWidth={1}
|
|
49
|
-
stroke={tick.type === 'major' ? '#555' : '#999'}
|
|
50
|
-
className={
|
|
51
|
-
tick.type === 'major' ? classes.majorTick : classes.minorTick
|
|
52
|
-
}
|
|
53
|
-
data-bp={tick.base}
|
|
54
|
-
/>
|
|
55
|
-
)
|
|
56
|
-
})}
|
|
57
|
-
{ticks
|
|
58
|
-
.filter(tick => tick.type === 'major')
|
|
59
|
-
.map(tick => {
|
|
60
|
-
const x = (reversed ? end - tick.base : tick.base - start) / bpPerPx
|
|
61
|
-
return (
|
|
62
|
-
<text
|
|
63
|
-
x={x}
|
|
64
|
-
y={10}
|
|
65
|
-
key={`label-${tick.base}`}
|
|
66
|
-
textAnchor="middle"
|
|
67
|
-
style={{ fontSize: '11px' }}
|
|
68
|
-
className={classes.majorTickLabel}
|
|
69
|
-
>
|
|
70
|
-
{mathPower(tick.base + 1)}
|
|
71
|
-
</text>
|
|
72
|
-
)
|
|
73
|
-
})}
|
|
74
|
-
</>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const Ruler = observer(function ({ model }: { model: MsaViewModel }) {
|
|
79
|
-
const {
|
|
80
|
-
MSA,
|
|
81
|
-
colWidth,
|
|
82
|
-
msaAreaWidth,
|
|
83
|
-
rulerHeight,
|
|
84
|
-
resizeHandleWidth,
|
|
85
|
-
scrollX,
|
|
86
|
-
blocksX,
|
|
87
|
-
blockSize,
|
|
88
|
-
} = model
|
|
89
|
-
const ref = useRef<HTMLDivElement>(null)
|
|
90
|
-
const offsetX = blocksX[0]
|
|
91
|
-
|
|
92
|
-
return !MSA ? null : (
|
|
93
|
-
<div
|
|
94
|
-
ref={ref}
|
|
95
|
-
style={{
|
|
96
|
-
position: 'relative',
|
|
97
|
-
width: msaAreaWidth,
|
|
98
|
-
cursor: 'crosshair',
|
|
99
|
-
overflow: 'hidden',
|
|
100
|
-
height: rulerHeight,
|
|
101
|
-
background: '#ccc',
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
<svg
|
|
105
|
-
style={{
|
|
106
|
-
width: blocksX.length * blockSize,
|
|
107
|
-
position: 'absolute',
|
|
108
|
-
left: scrollX + offsetX + resizeHandleWidth,
|
|
109
|
-
pointerEvents: 'none',
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
<RulerBlock
|
|
113
|
-
key={offsetX}
|
|
114
|
-
start={offsetX / colWidth}
|
|
115
|
-
end={offsetX / colWidth + (blockSize * blocksX.length) / colWidth}
|
|
116
|
-
bpPerPx={1 / colWidth}
|
|
117
|
-
/>
|
|
118
|
-
</svg>
|
|
119
|
-
</div>
|
|
120
|
-
)
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
export default Ruler
|