@apollo-annotation/jbrowse-plugin-apollo 0.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.
- package/README.md +76 -0
- package/dist/index.esm.js +10248 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/jbrowse-plugin-apollo.cjs.development.js +10298 -0
- package/dist/jbrowse-plugin-apollo.cjs.development.js.map +1 -0
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js +2 -0
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js.map +1 -0
- package/dist/jbrowse-plugin-apollo.umd.development.js +46957 -0
- package/dist/jbrowse-plugin-apollo.umd.development.js.map +1 -0
- package/dist/jbrowse-plugin-apollo.umd.production.min.js +2 -0
- package/dist/jbrowse-plugin-apollo.umd.production.min.js.map +1 -0
- package/package.json +130 -0
- package/src/ApolloInternetAccount/addMenuItems.ts +94 -0
- package/src/ApolloInternetAccount/components/AuthTypeSelector.tsx +121 -0
- package/src/ApolloInternetAccount/components/LoginButtons.tsx +62 -0
- package/src/ApolloInternetAccount/components/LoginIcons.tsx +74 -0
- package/src/ApolloInternetAccount/configSchema.ts +26 -0
- package/src/ApolloInternetAccount/index.ts +2 -0
- package/src/ApolloInternetAccount/model.ts +448 -0
- package/src/ApolloJobModel.ts +117 -0
- package/src/ApolloSequenceAdapter/ApolloSequenceAdapter.ts +186 -0
- package/src/ApolloSequenceAdapter/configSchema.ts +12 -0
- package/src/ApolloSequenceAdapter/index.ts +21 -0
- package/src/ApolloSixFrameRenderer/ApolloSixFrameRenderer.tsx +12 -0
- package/src/ApolloSixFrameRenderer/components/ApolloRendering.tsx +692 -0
- package/src/ApolloSixFrameRenderer/configSchema.ts +7 -0
- package/src/ApolloSixFrameRenderer/index.ts +3 -0
- package/src/ApolloTextSearchAdapter/ApolloTextSearchAdapter.ts +64 -0
- package/src/ApolloTextSearchAdapter/configSchema.ts +24 -0
- package/src/ApolloTextSearchAdapter/index.ts +18 -0
- package/src/BackendDrivers/BackendDriver.ts +31 -0
- package/src/BackendDrivers/CollaborationServerDriver.ts +318 -0
- package/src/BackendDrivers/DesktopFileDriver.ts +170 -0
- package/src/BackendDrivers/InMemoryFileDriver.ts +76 -0
- package/src/BackendDrivers/index.ts +4 -0
- package/src/ChangeManager.ts +148 -0
- package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +248 -0
- package/src/LinearApolloDisplay/components/index.ts +1 -0
- package/src/LinearApolloDisplay/configSchema.ts +16 -0
- package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +422 -0
- package/src/LinearApolloDisplay/glyphs/CanonicalGeneGlyph.ts +1191 -0
- package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +151 -0
- package/src/LinearApolloDisplay/glyphs/Glyph.ts +382 -0
- package/src/LinearApolloDisplay/glyphs/ImplicitExonGeneGlyph.ts +697 -0
- package/src/LinearApolloDisplay/glyphs/index.ts +4 -0
- package/src/LinearApolloDisplay/index.ts +2 -0
- package/src/LinearApolloDisplay/stateModel/base.ts +146 -0
- package/src/LinearApolloDisplay/stateModel/getGlyph.ts +39 -0
- package/src/LinearApolloDisplay/stateModel/glyphs.ts +45 -0
- package/src/LinearApolloDisplay/stateModel/index.ts +20 -0
- package/src/LinearApolloDisplay/stateModel/layouts.ts +230 -0
- package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +513 -0
- package/src/LinearApolloDisplay/stateModel/rendering.ts +441 -0
- package/src/LinearApolloDisplay/stateModel/trackHeightMixin.ts +43 -0
- package/src/LinearApolloDisplay/types.ts +1 -0
- package/src/OntologyManager/OntologyStore/__snapshots__/fulltext.test.ts.snap +208 -0
- package/src/OntologyManager/OntologyStore/__snapshots__/index.test.ts.snap +18846 -0
- package/src/OntologyManager/OntologyStore/fulltext-stopwords.ts +137 -0
- package/src/OntologyManager/OntologyStore/fulltext.test.ts +94 -0
- package/src/OntologyManager/OntologyStore/fulltext.ts +264 -0
- package/src/OntologyManager/OntologyStore/index.test.ts +130 -0
- package/src/OntologyManager/OntologyStore/index.ts +526 -0
- package/src/OntologyManager/OntologyStore/indexeddb-schema.ts +89 -0
- package/src/OntologyManager/OntologyStore/indexeddb-storage.ts +180 -0
- package/src/OntologyManager/OntologyStore/obo-graph-json-schema.ts +110 -0
- package/src/OntologyManager/OntologyStore/prefixes.ts +35 -0
- package/src/OntologyManager/index.ts +173 -0
- package/src/SixFrameFeatureDisplay/components/TrackLines.tsx +19 -0
- package/src/SixFrameFeatureDisplay/components/index.ts +1 -0
- package/src/SixFrameFeatureDisplay/configSchema.ts +21 -0
- package/src/SixFrameFeatureDisplay/index.ts +2 -0
- package/src/SixFrameFeatureDisplay/stateModel.ts +413 -0
- package/src/TabularEditor/HybridGrid/ChangeHandling.ts +88 -0
- package/src/TabularEditor/HybridGrid/Feature.tsx +346 -0
- package/src/TabularEditor/HybridGrid/FeatureAttributes.tsx +34 -0
- package/src/TabularEditor/HybridGrid/Highlight.tsx +40 -0
- package/src/TabularEditor/HybridGrid/HybridGrid.tsx +138 -0
- package/src/TabularEditor/HybridGrid/NumberCell.tsx +77 -0
- package/src/TabularEditor/HybridGrid/ToolBar.tsx +59 -0
- package/src/TabularEditor/HybridGrid/featureContextMenuItems.ts +119 -0
- package/src/TabularEditor/HybridGrid/index.ts +1 -0
- package/src/TabularEditor/TabularEditorPane.tsx +34 -0
- package/src/TabularEditor/index.ts +3 -0
- package/src/TabularEditor/model.ts +44 -0
- package/src/TabularEditor/types.ts +3 -0
- package/src/components/AddAssembly.tsx +464 -0
- package/src/components/AddChildFeature.tsx +247 -0
- package/src/components/AddFeature.tsx +252 -0
- package/src/components/CopyFeature.tsx +328 -0
- package/src/components/DeleteAssembly.tsx +185 -0
- package/src/components/DeleteFeature.tsx +90 -0
- package/src/components/Dialog.tsx +47 -0
- package/src/components/DownloadGFF3.tsx +213 -0
- package/src/components/ImportFeatures.tsx +295 -0
- package/src/components/ManageChecks.tsx +280 -0
- package/src/components/ManageUsers.tsx +218 -0
- package/src/components/ModifyFeatureAttribute.tsx +457 -0
- package/src/components/OntologyTermAutocomplete.tsx +240 -0
- package/src/components/OntologyTermMultiSelect.tsx +349 -0
- package/src/components/OpenLocalFile.tsx +178 -0
- package/src/components/ViewChangeLog.tsx +208 -0
- package/src/components/ViewCheckResults.tsx +151 -0
- package/src/components/index.ts +12 -0
- package/src/config.ts +10 -0
- package/src/declare.d.ts +3 -0
- package/src/extensions/annotationFromPileup.ts +208 -0
- package/src/extensions/index.ts +1 -0
- package/src/index.ts +394 -0
- package/src/makeDisplayComponent.tsx +244 -0
- package/src/session/ClientDataStore.ts +282 -0
- package/src/session/index.ts +1 -0
- package/src/session/session.ts +373 -0
- package/src/types.ts +10 -0
- package/src/util/index.ts +31 -0
- package/src/util/loadAssemblyIntoClient.ts +291 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { AnyConfigurationSchemaType } from '@jbrowse/core/configuration/configurationSchema'
|
|
2
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
3
|
+
import { defaultCodonTable, doesIntersect2, revcom } from '@jbrowse/core/util'
|
|
4
|
+
import { Theme } from '@mui/material'
|
|
5
|
+
import { autorun } from 'mobx'
|
|
6
|
+
import { Instance, addDisposer } from 'mobx-state-tree'
|
|
7
|
+
|
|
8
|
+
import { ApolloSessionModel } from '../../session'
|
|
9
|
+
import { getGlyph } from './getGlyph'
|
|
10
|
+
import { layoutsModelFactory } from './layouts'
|
|
11
|
+
|
|
12
|
+
export function renderingModelIntermediateFactory(
|
|
13
|
+
pluginManager: PluginManager,
|
|
14
|
+
configSchema: AnyConfigurationSchemaType,
|
|
15
|
+
) {
|
|
16
|
+
const LinearApolloDisplayLayouts = layoutsModelFactory(
|
|
17
|
+
pluginManager,
|
|
18
|
+
configSchema,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
return LinearApolloDisplayLayouts.named('LinearApolloDisplayRendering')
|
|
22
|
+
.props({
|
|
23
|
+
sequenceRowHeight: 15,
|
|
24
|
+
apolloRowHeight: 20,
|
|
25
|
+
detailsMinHeight: 200,
|
|
26
|
+
detailsHeight: 200,
|
|
27
|
+
lastRowTooltipBufferHeight: 40,
|
|
28
|
+
isShown: true,
|
|
29
|
+
})
|
|
30
|
+
.volatile(() => ({
|
|
31
|
+
canvas: null as HTMLCanvasElement | null,
|
|
32
|
+
overlayCanvas: null as HTMLCanvasElement | null,
|
|
33
|
+
collaboratorCanvas: null as HTMLCanvasElement | null,
|
|
34
|
+
seqTrackCanvas: null as HTMLCanvasElement | null,
|
|
35
|
+
seqTrackOverlayCanvas: null as HTMLCanvasElement | null,
|
|
36
|
+
theme: undefined as Theme | undefined,
|
|
37
|
+
}))
|
|
38
|
+
.views((self) => ({
|
|
39
|
+
get featuresHeight() {
|
|
40
|
+
return (
|
|
41
|
+
(self.highestRow + 1) * self.apolloRowHeight +
|
|
42
|
+
self.lastRowTooltipBufferHeight
|
|
43
|
+
)
|
|
44
|
+
},
|
|
45
|
+
}))
|
|
46
|
+
.actions((self) => ({
|
|
47
|
+
toggleShown() {
|
|
48
|
+
self.isShown = !self.isShown
|
|
49
|
+
},
|
|
50
|
+
setDetailsHeight(newHeight: number) {
|
|
51
|
+
self.detailsHeight = self.isShown
|
|
52
|
+
? Math.max(
|
|
53
|
+
Math.min(newHeight, self.height - 100),
|
|
54
|
+
Math.min(self.height, self.detailsMinHeight),
|
|
55
|
+
)
|
|
56
|
+
: newHeight
|
|
57
|
+
},
|
|
58
|
+
setCanvas(canvas: HTMLCanvasElement | null) {
|
|
59
|
+
self.canvas = canvas
|
|
60
|
+
},
|
|
61
|
+
setOverlayCanvas(canvas: HTMLCanvasElement | null) {
|
|
62
|
+
self.overlayCanvas = canvas
|
|
63
|
+
},
|
|
64
|
+
setCollaboratorCanvas(canvas: HTMLCanvasElement | null) {
|
|
65
|
+
self.collaboratorCanvas = canvas
|
|
66
|
+
},
|
|
67
|
+
setSeqTrackCanvas(canvas: HTMLCanvasElement | null) {
|
|
68
|
+
self.seqTrackCanvas = canvas
|
|
69
|
+
},
|
|
70
|
+
setSeqTrackOverlayCanvas(canvas: HTMLCanvasElement | null) {
|
|
71
|
+
self.seqTrackOverlayCanvas = canvas
|
|
72
|
+
},
|
|
73
|
+
setTheme(theme: Theme) {
|
|
74
|
+
self.theme = theme
|
|
75
|
+
},
|
|
76
|
+
afterAttach() {
|
|
77
|
+
addDisposer(
|
|
78
|
+
self,
|
|
79
|
+
autorun(
|
|
80
|
+
() => {
|
|
81
|
+
if (!self.lgv.initialized || self.regionCannotBeRendered()) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
const ctx = self.collaboratorCanvas?.getContext('2d')
|
|
85
|
+
if (!ctx) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
ctx.clearRect(
|
|
89
|
+
0,
|
|
90
|
+
0,
|
|
91
|
+
self.lgv.dynamicBlocks.totalWidthPx,
|
|
92
|
+
self.featuresHeight,
|
|
93
|
+
)
|
|
94
|
+
for (const collaborator of (
|
|
95
|
+
self.session as unknown as ApolloSessionModel
|
|
96
|
+
).collaborators) {
|
|
97
|
+
const { locations } = collaborator
|
|
98
|
+
if (locations.length === 0) {
|
|
99
|
+
continue
|
|
100
|
+
}
|
|
101
|
+
let idx = 0
|
|
102
|
+
for (const displayedRegion of self.lgv.displayedRegions) {
|
|
103
|
+
for (const location of locations) {
|
|
104
|
+
if (location.refSeq !== displayedRegion.refName) {
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
const { end, refSeq, start } = location
|
|
108
|
+
const locationStartPxInfo = self.lgv.bpToPx({
|
|
109
|
+
refName: refSeq,
|
|
110
|
+
coord: start,
|
|
111
|
+
regionNumber: idx,
|
|
112
|
+
})
|
|
113
|
+
if (!locationStartPxInfo) {
|
|
114
|
+
continue
|
|
115
|
+
}
|
|
116
|
+
const locationStartPx =
|
|
117
|
+
locationStartPxInfo.offsetPx - self.lgv.offsetPx
|
|
118
|
+
const locationWidthPx = (end - start) / self.lgv.bpPerPx
|
|
119
|
+
ctx.fillStyle = 'rgba(0,255,0,.2)'
|
|
120
|
+
ctx.fillRect(locationStartPx, 1, locationWidthPx, 100)
|
|
121
|
+
ctx.fillStyle = 'black'
|
|
122
|
+
ctx.fillText(
|
|
123
|
+
collaborator.name,
|
|
124
|
+
locationStartPx + 1,
|
|
125
|
+
11,
|
|
126
|
+
locationWidthPx - 2,
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
idx++
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{ name: 'LinearApolloDisplayRenderCollaborators' },
|
|
134
|
+
),
|
|
135
|
+
)
|
|
136
|
+
},
|
|
137
|
+
}))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function colorCode(letter: string, theme?: Theme) {
|
|
141
|
+
return (
|
|
142
|
+
theme?.palette.bases[
|
|
143
|
+
letter.toUpperCase() as keyof Theme['palette']['bases']
|
|
144
|
+
].main.toString() ?? 'lightgray'
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function codonColorCode(letter: string) {
|
|
149
|
+
const colorMap: Record<string, string> = {
|
|
150
|
+
M: '#33ee33',
|
|
151
|
+
'*': '#f44336',
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return colorMap[letter?.toUpperCase()] || 'lightgray'
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function reverseCodonSeq(seq: string): string {
|
|
158
|
+
return [...seq]
|
|
159
|
+
.map((c) => revcom(c))
|
|
160
|
+
.reverse()
|
|
161
|
+
.join('')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function drawLetter(
|
|
165
|
+
seqTrackctx: CanvasRenderingContext2D,
|
|
166
|
+
startPx: number,
|
|
167
|
+
widthPx: number,
|
|
168
|
+
letter: string,
|
|
169
|
+
textY: number,
|
|
170
|
+
) {
|
|
171
|
+
const fontSize = Math.min(widthPx, 10)
|
|
172
|
+
seqTrackctx.fillStyle = '#000'
|
|
173
|
+
seqTrackctx.font = `${fontSize}px`
|
|
174
|
+
const textWidth = seqTrackctx.measureText(letter).width
|
|
175
|
+
const textX = startPx + (widthPx - textWidth) / 2
|
|
176
|
+
seqTrackctx.fillText(letter, textX, textY + 10)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function drawTranslation(
|
|
180
|
+
seqTrackctx: CanvasRenderingContext2D,
|
|
181
|
+
bpPerPx: number,
|
|
182
|
+
trnslStartPx: number,
|
|
183
|
+
trnslY: number,
|
|
184
|
+
trnslWidthPx: number,
|
|
185
|
+
sequenceRowHeight: number,
|
|
186
|
+
seq: string,
|
|
187
|
+
i: number,
|
|
188
|
+
reverse: boolean,
|
|
189
|
+
) {
|
|
190
|
+
let codonSeq: string = seq.slice(i, i + 3).toUpperCase()
|
|
191
|
+
if (reverse) {
|
|
192
|
+
codonSeq = reverseCodonSeq(codonSeq)
|
|
193
|
+
}
|
|
194
|
+
const codonLetter =
|
|
195
|
+
defaultCodonTable[codonSeq as keyof typeof defaultCodonTable]
|
|
196
|
+
if (!codonLetter) {
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
seqTrackctx.beginPath()
|
|
200
|
+
seqTrackctx.fillStyle = codonColorCode(codonLetter)
|
|
201
|
+
seqTrackctx.rect(trnslStartPx, trnslY, trnslWidthPx, sequenceRowHeight)
|
|
202
|
+
seqTrackctx.fill()
|
|
203
|
+
if (bpPerPx <= 0.1) {
|
|
204
|
+
seqTrackctx.stroke()
|
|
205
|
+
drawLetter(seqTrackctx, trnslStartPx, trnslWidthPx, codonLetter, trnslY)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function sequenceRenderingModelFactory(
|
|
210
|
+
pluginManager: PluginManager,
|
|
211
|
+
configSchema: AnyConfigurationSchemaType,
|
|
212
|
+
) {
|
|
213
|
+
const LinearApolloDisplayRendering = renderingModelIntermediateFactory(
|
|
214
|
+
pluginManager,
|
|
215
|
+
configSchema,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
return LinearApolloDisplayRendering.actions((self) => ({
|
|
219
|
+
afterAttach() {
|
|
220
|
+
addDisposer(
|
|
221
|
+
self,
|
|
222
|
+
autorun(
|
|
223
|
+
async () => {
|
|
224
|
+
if (!self.lgv.initialized || self.regionCannotBeRendered()) {
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
if (self.lgv.bpPerPx > 3) {
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
const seqTrackctx = self.seqTrackCanvas?.getContext('2d')
|
|
231
|
+
if (!seqTrackctx) {
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
seqTrackctx.clearRect(
|
|
236
|
+
0,
|
|
237
|
+
0,
|
|
238
|
+
self.lgv.dynamicBlocks.totalWidthPx,
|
|
239
|
+
self.lgv.bpPerPx <= 1 ? 125 : 95,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
for (const [idx, region] of self.regions.entries()) {
|
|
243
|
+
const driver = (
|
|
244
|
+
self.session as unknown as ApolloSessionModel
|
|
245
|
+
).apolloDataStore.getBackendDriver(region.assemblyName)
|
|
246
|
+
|
|
247
|
+
if (!driver) {
|
|
248
|
+
throw new Error('Failed to get the backend driver')
|
|
249
|
+
}
|
|
250
|
+
const { seq } = await driver.getSequence(region)
|
|
251
|
+
|
|
252
|
+
if (!seq) {
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
for (const [i, letter] of [...seq].entries()) {
|
|
256
|
+
const trnslXOffset =
|
|
257
|
+
(self.lgv.bpToPx({
|
|
258
|
+
refName: region.refName,
|
|
259
|
+
coord: region.start + i,
|
|
260
|
+
regionNumber: idx,
|
|
261
|
+
})?.offsetPx ?? 0) - self.lgv.offsetPx
|
|
262
|
+
const trnslWidthPx = 3 / self.lgv.bpPerPx
|
|
263
|
+
const trnslStartPx = self.displayedRegions[idx].reversed
|
|
264
|
+
? trnslXOffset - trnslWidthPx
|
|
265
|
+
: trnslXOffset
|
|
266
|
+
|
|
267
|
+
// Draw translation forward
|
|
268
|
+
for (let j = 2; j >= 0; j--) {
|
|
269
|
+
if ((region.start + i) % 3 === j) {
|
|
270
|
+
drawTranslation(
|
|
271
|
+
seqTrackctx,
|
|
272
|
+
self.lgv.bpPerPx,
|
|
273
|
+
trnslStartPx,
|
|
274
|
+
self.sequenceRowHeight * (2 - j),
|
|
275
|
+
trnslWidthPx,
|
|
276
|
+
self.sequenceRowHeight,
|
|
277
|
+
seq,
|
|
278
|
+
i,
|
|
279
|
+
false,
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (self.lgv.bpPerPx <= 1) {
|
|
285
|
+
const xOffset =
|
|
286
|
+
(self.lgv.bpToPx({
|
|
287
|
+
refName: region.refName,
|
|
288
|
+
coord: region.start + i,
|
|
289
|
+
regionNumber: idx,
|
|
290
|
+
})?.offsetPx ?? 0) - self.lgv.offsetPx
|
|
291
|
+
const widthPx = 1 / self.lgv.bpPerPx
|
|
292
|
+
const startPx = self.displayedRegions[idx].reversed
|
|
293
|
+
? xOffset - widthPx
|
|
294
|
+
: xOffset
|
|
295
|
+
|
|
296
|
+
// Draw forward
|
|
297
|
+
seqTrackctx.beginPath()
|
|
298
|
+
seqTrackctx.fillStyle = colorCode(letter, self.theme)
|
|
299
|
+
seqTrackctx.rect(
|
|
300
|
+
startPx,
|
|
301
|
+
self.sequenceRowHeight * 3,
|
|
302
|
+
widthPx,
|
|
303
|
+
self.sequenceRowHeight,
|
|
304
|
+
)
|
|
305
|
+
seqTrackctx.fill()
|
|
306
|
+
if (self.lgv.bpPerPx <= 0.1) {
|
|
307
|
+
seqTrackctx.stroke()
|
|
308
|
+
drawLetter(
|
|
309
|
+
seqTrackctx,
|
|
310
|
+
startPx,
|
|
311
|
+
widthPx,
|
|
312
|
+
letter,
|
|
313
|
+
self.sequenceRowHeight * 3,
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Draw reverse
|
|
318
|
+
const revLetter = revcom(letter)
|
|
319
|
+
seqTrackctx.beginPath()
|
|
320
|
+
seqTrackctx.fillStyle = colorCode(revLetter, self.theme)
|
|
321
|
+
seqTrackctx.rect(
|
|
322
|
+
startPx,
|
|
323
|
+
self.sequenceRowHeight * 4,
|
|
324
|
+
widthPx,
|
|
325
|
+
self.sequenceRowHeight,
|
|
326
|
+
)
|
|
327
|
+
seqTrackctx.fill()
|
|
328
|
+
if (self.lgv.bpPerPx <= 0.1) {
|
|
329
|
+
seqTrackctx.stroke()
|
|
330
|
+
drawLetter(
|
|
331
|
+
seqTrackctx,
|
|
332
|
+
startPx,
|
|
333
|
+
widthPx,
|
|
334
|
+
revLetter,
|
|
335
|
+
self.sequenceRowHeight * 4,
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Draw translation reverse
|
|
341
|
+
for (let k = 0; k <= 2; k++) {
|
|
342
|
+
const rowOffset = self.lgv.bpPerPx <= 1 ? 5 : 3
|
|
343
|
+
if ((region.start + i) % 3 === k) {
|
|
344
|
+
drawTranslation(
|
|
345
|
+
seqTrackctx,
|
|
346
|
+
self.lgv.bpPerPx,
|
|
347
|
+
trnslStartPx,
|
|
348
|
+
self.sequenceRowHeight * (rowOffset + k),
|
|
349
|
+
trnslWidthPx,
|
|
350
|
+
self.sequenceRowHeight,
|
|
351
|
+
seq,
|
|
352
|
+
i,
|
|
353
|
+
true,
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{ name: 'LinearApolloDisplayRenderSequence' },
|
|
361
|
+
),
|
|
362
|
+
)
|
|
363
|
+
},
|
|
364
|
+
}))
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function renderingModelFactory(
|
|
368
|
+
pluginManager: PluginManager,
|
|
369
|
+
configSchema: AnyConfigurationSchemaType,
|
|
370
|
+
) {
|
|
371
|
+
const LinearApolloDisplayRendering = sequenceRenderingModelFactory(
|
|
372
|
+
pluginManager,
|
|
373
|
+
configSchema,
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
return LinearApolloDisplayRendering.actions((self) => ({
|
|
377
|
+
afterAttach() {
|
|
378
|
+
addDisposer(
|
|
379
|
+
self,
|
|
380
|
+
autorun(
|
|
381
|
+
() => {
|
|
382
|
+
if (!self.lgv.initialized || self.regionCannotBeRendered()) {
|
|
383
|
+
return
|
|
384
|
+
}
|
|
385
|
+
const ctx = self.canvas?.getContext('2d')
|
|
386
|
+
if (!ctx) {
|
|
387
|
+
return
|
|
388
|
+
}
|
|
389
|
+
ctx.clearRect(
|
|
390
|
+
0,
|
|
391
|
+
0,
|
|
392
|
+
self.lgv.dynamicBlocks.totalWidthPx,
|
|
393
|
+
self.featuresHeight,
|
|
394
|
+
)
|
|
395
|
+
for (const [idx, featureLayout] of self.featureLayouts.entries()) {
|
|
396
|
+
const displayedRegion = self.displayedRegions[idx]
|
|
397
|
+
for (const [row, featureLayoutRow] of featureLayout.entries()) {
|
|
398
|
+
for (const [featureRow, feature] of featureLayoutRow) {
|
|
399
|
+
if (featureRow > 0) {
|
|
400
|
+
continue
|
|
401
|
+
}
|
|
402
|
+
if (
|
|
403
|
+
!doesIntersect2(
|
|
404
|
+
displayedRegion.start,
|
|
405
|
+
displayedRegion.end,
|
|
406
|
+
feature.min,
|
|
407
|
+
feature.max,
|
|
408
|
+
)
|
|
409
|
+
) {
|
|
410
|
+
continue
|
|
411
|
+
}
|
|
412
|
+
const x =
|
|
413
|
+
(self.lgv.bpToPx({
|
|
414
|
+
refName: displayedRegion.refName,
|
|
415
|
+
coord: feature.min,
|
|
416
|
+
regionNumber: idx,
|
|
417
|
+
})?.offsetPx ?? 0) - self.lgv.offsetPx
|
|
418
|
+
getGlyph(feature, self.lgv.bpPerPx).draw(
|
|
419
|
+
self,
|
|
420
|
+
ctx,
|
|
421
|
+
feature,
|
|
422
|
+
x,
|
|
423
|
+
row,
|
|
424
|
+
displayedRegion.reversed,
|
|
425
|
+
)
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
{ name: 'LinearApolloDisplayRenderFeatures' },
|
|
431
|
+
),
|
|
432
|
+
)
|
|
433
|
+
},
|
|
434
|
+
}))
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export type LinearApolloDisplayRenderingModel = ReturnType<
|
|
438
|
+
typeof renderingModelIntermediateFactory
|
|
439
|
+
>
|
|
440
|
+
export type LinearApolloDisplayRendering =
|
|
441
|
+
Instance<LinearApolloDisplayRenderingModel>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// TODO: get this added to LGV runtime exports so we don't have to duplicate it
|
|
2
|
+
import { getConf } from '@jbrowse/core/configuration'
|
|
3
|
+
import { types } from 'mobx-state-tree'
|
|
4
|
+
|
|
5
|
+
const minDisplayHeight = 20
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* #stateModel TrackHeightMixin
|
|
9
|
+
* #category display
|
|
10
|
+
*/
|
|
11
|
+
export const TrackHeightMixin = types
|
|
12
|
+
.model({
|
|
13
|
+
heightPreConfig: types.maybe(
|
|
14
|
+
types.refinement(
|
|
15
|
+
'displayHeight',
|
|
16
|
+
types.number,
|
|
17
|
+
(n) => n >= minDisplayHeight,
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
})
|
|
21
|
+
.volatile(() => ({
|
|
22
|
+
scrollTop: 0,
|
|
23
|
+
}))
|
|
24
|
+
.views((self) => ({
|
|
25
|
+
get height() {
|
|
26
|
+
// @ts-expect-error getConf needs self.configuration
|
|
27
|
+
return self.heightPreConfig ?? (getConf(self, 'height') as number)
|
|
28
|
+
},
|
|
29
|
+
}))
|
|
30
|
+
.actions((self) => ({
|
|
31
|
+
setScrollTop(scrollTop: number) {
|
|
32
|
+
self.scrollTop = scrollTop
|
|
33
|
+
},
|
|
34
|
+
setHeight(displayHeight: number) {
|
|
35
|
+
self.heightPreConfig = Math.max(displayHeight, minDisplayHeight)
|
|
36
|
+
return self.height
|
|
37
|
+
},
|
|
38
|
+
resizeHeight(distance: number) {
|
|
39
|
+
const oldHeight = self.height
|
|
40
|
+
const newHeight = this.setHeight(self.height + distance)
|
|
41
|
+
return newHeight - oldHeight
|
|
42
|
+
},
|
|
43
|
+
}))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CanvasMouseEvent = React.MouseEvent<HTMLCanvasElement, MouseEvent>
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`elaborateMatch can do another 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"field": {
|
|
7
|
+
"displayName": "ID",
|
|
8
|
+
"jsonPath": "$PREFIXED_ID",
|
|
9
|
+
},
|
|
10
|
+
"score": 109.1,
|
|
11
|
+
"str": "SO:0000001",
|
|
12
|
+
"term": {
|
|
13
|
+
"id": "http://purl.obolibrary.org/obo/SO_0000001",
|
|
14
|
+
"lbl": "region",
|
|
15
|
+
"meta": {
|
|
16
|
+
"basicPropertyValues": [
|
|
17
|
+
{
|
|
18
|
+
"pred": "http://www.geneontology.org/formats/oboInOwl#hasOBONamespace",
|
|
19
|
+
"val": "sequence",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
"definition": {
|
|
23
|
+
"val": "A sequence_feature with an extent greater than zero. A nucleotide region is composed of bases and a polypeptide region is composed of amino acids. It may also be termed a region of some number of nucleotides.",
|
|
24
|
+
"xrefs": [
|
|
25
|
+
"SO:ke",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
"subsets": [
|
|
29
|
+
"http://purl.obolibrary.org/obo/so#SOFA",
|
|
30
|
+
],
|
|
31
|
+
"synonyms": [
|
|
32
|
+
{
|
|
33
|
+
"pred": "hasExactSynonym",
|
|
34
|
+
"val": "sequence",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
"type": "CLASS",
|
|
39
|
+
},
|
|
40
|
+
"wordMatches": [
|
|
41
|
+
{
|
|
42
|
+
"position": 0,
|
|
43
|
+
"wordIndex": 0,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
exports[`elaborateMatch can do one 1`] = `
|
|
51
|
+
[
|
|
52
|
+
{
|
|
53
|
+
"field": {
|
|
54
|
+
"displayName": "definition",
|
|
55
|
+
"jsonPath": "$.meta.definition.val",
|
|
56
|
+
},
|
|
57
|
+
"score": 208.39346153846154,
|
|
58
|
+
"str": "A sequence_feature with an extent greater than zero. A nucleotide region is composed of bases and a polypeptide region is composed of amino acids. It may also be termed a region of some number of nucleotides.",
|
|
59
|
+
"term": {
|
|
60
|
+
"id": "http://purl.obolibrary.org/obo/SO_0000001",
|
|
61
|
+
"lbl": "region",
|
|
62
|
+
"meta": {
|
|
63
|
+
"basicPropertyValues": [
|
|
64
|
+
{
|
|
65
|
+
"pred": "http://www.geneontology.org/formats/oboInOwl#hasOBONamespace",
|
|
66
|
+
"val": "sequence",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
"definition": {
|
|
70
|
+
"val": "A sequence_feature with an extent greater than zero. A nucleotide region is composed of bases and a polypeptide region is composed of amino acids. It may also be termed a region of some number of nucleotides.",
|
|
71
|
+
"xrefs": [
|
|
72
|
+
"SO:ke",
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
"subsets": [
|
|
76
|
+
"http://purl.obolibrary.org/obo/so#SOFA",
|
|
77
|
+
],
|
|
78
|
+
"synonyms": [
|
|
79
|
+
{
|
|
80
|
+
"pred": "hasExactSynonym",
|
|
81
|
+
"val": "sequence",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
"type": "CLASS",
|
|
86
|
+
},
|
|
87
|
+
"wordMatches": [
|
|
88
|
+
{
|
|
89
|
+
"position": 55,
|
|
90
|
+
"wordIndex": 0,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"position": 66,
|
|
94
|
+
"wordIndex": 1,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"position": 112,
|
|
98
|
+
"wordIndex": 1,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"position": 171,
|
|
102
|
+
"wordIndex": 1,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"position": 196,
|
|
106
|
+
"wordIndex": 0,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
exports[`getWords can get the words from a test node 1`] = `
|
|
114
|
+
[
|
|
115
|
+
[
|
|
116
|
+
"$PREFIXED_ID",
|
|
117
|
+
"so:0000001",
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
"$.lbl",
|
|
121
|
+
"region",
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
"$.meta.definition.val",
|
|
125
|
+
"sequence",
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
"$.meta.definition.val",
|
|
129
|
+
"feature",
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
"$.meta.definition.val",
|
|
133
|
+
"extent",
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
"$.meta.definition.val",
|
|
137
|
+
"greater",
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
"$.meta.definition.val",
|
|
141
|
+
"zero",
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
"$.meta.definition.val",
|
|
145
|
+
"nucleotide",
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
"$.meta.definition.val",
|
|
149
|
+
"region",
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
"$.meta.definition.val",
|
|
153
|
+
"composed",
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
"$.meta.definition.val",
|
|
157
|
+
"bases",
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
"$.meta.definition.val",
|
|
161
|
+
"polypeptide",
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
"$.meta.definition.val",
|
|
165
|
+
"region",
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
"$.meta.definition.val",
|
|
169
|
+
"composed",
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
"$.meta.definition.val",
|
|
173
|
+
"amino",
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
"$.meta.definition.val",
|
|
177
|
+
"acids",
|
|
178
|
+
],
|
|
179
|
+
[
|
|
180
|
+
"$.meta.definition.val",
|
|
181
|
+
"may",
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
"$.meta.definition.val",
|
|
185
|
+
"also",
|
|
186
|
+
],
|
|
187
|
+
[
|
|
188
|
+
"$.meta.definition.val",
|
|
189
|
+
"termed",
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
"$.meta.definition.val",
|
|
193
|
+
"region",
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
"$.meta.definition.val",
|
|
197
|
+
"number",
|
|
198
|
+
],
|
|
199
|
+
[
|
|
200
|
+
"$.meta.definition.val",
|
|
201
|
+
"nucleotides",
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
"$.meta.synonyms[*].val",
|
|
205
|
+
"sequence",
|
|
206
|
+
],
|
|
207
|
+
]
|
|
208
|
+
`;
|