@jbrowse/plugin-linear-genome-view 1.7.9 → 1.7.10
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/dist/BaseLinearDisplay/components/BaseLinearDisplay.d.ts +1 -5
- package/dist/BaseLinearDisplay/components/BaseLinearDisplay.js +32 -120
- package/dist/BaseLinearDisplay/components/Tooltip.d.ts +8 -0
- package/dist/BaseLinearDisplay/components/Tooltip.js +125 -0
- package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +3 -2
- package/dist/LinearGenomeView/components/Header.js +5 -2
- package/dist/LinearGenomeView/components/HelpDialog.js +2 -3
- package/dist/LinearGenomeView/components/LinearGenomeView.js +6 -2
- package/dist/LinearGenomeView/components/LinearGenomeView.test.js +2 -2
- package/dist/LinearGenomeView/components/OverviewScaleBar.js +2 -2
- package/dist/LinearGenomeView/components/ScaleBar.d.ts +6 -2
- package/dist/LinearGenomeView/components/ScaleBar.js +8 -3
- package/dist/LinearGenomeView/components/TrackLabel.js +25 -41
- package/dist/LinearGenomeView/index.d.ts +3 -8
- package/dist/LinearGenomeView/index.js +59 -32
- package/dist/LinearGenomeView/index.test.js +22 -5
- package/dist/index.js +22 -11
- package/package.json +3 -2
- package/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +4 -89
- package/src/BaseLinearDisplay/components/Tooltip.tsx +97 -0
- package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +10 -4
- package/src/LinearGenomeView/components/Header.tsx +3 -2
- package/src/LinearGenomeView/components/HelpDialog.tsx +5 -4
- package/src/LinearGenomeView/components/LinearGenomeView.test.js +2 -2
- package/src/LinearGenomeView/components/LinearGenomeView.tsx +16 -10
- package/src/LinearGenomeView/components/OverviewScaleBar.tsx +3 -4
- package/src/LinearGenomeView/components/ScaleBar.tsx +6 -9
- package/src/LinearGenomeView/components/TrackLabel.tsx +25 -28
- package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +4 -21
- package/src/LinearGenomeView/index.test.ts +20 -5
- package/src/LinearGenomeView/index.tsx +54 -26
- package/src/index.ts +35 -30
|
@@ -127,6 +127,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
127
127
|
),
|
|
128
128
|
hideHeader: false,
|
|
129
129
|
hideHeaderOverview: false,
|
|
130
|
+
hideNoTracksActive: false,
|
|
130
131
|
trackSelectorType: types.optional(
|
|
131
132
|
types.enumeration(['hierarchical']),
|
|
132
133
|
'hierarchical',
|
|
@@ -177,11 +178,18 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
177
178
|
get interRegionPaddingWidth() {
|
|
178
179
|
return INTER_REGION_PADDING_WIDTH
|
|
179
180
|
},
|
|
181
|
+
|
|
182
|
+
get assemblyNames() {
|
|
183
|
+
return [
|
|
184
|
+
...new Set(self.displayedRegions.map(region => region.assemblyName)),
|
|
185
|
+
]
|
|
186
|
+
},
|
|
180
187
|
}))
|
|
181
188
|
.views(self => ({
|
|
182
189
|
get assemblyErrors() {
|
|
183
190
|
const { assemblyManager } = getSession(self)
|
|
184
|
-
|
|
191
|
+
const { assemblyNames } = self
|
|
192
|
+
return assemblyNames
|
|
185
193
|
.map(a => assemblyManager.get(a)?.error)
|
|
186
194
|
.filter(f => !!f)
|
|
187
195
|
.join(', ')
|
|
@@ -189,9 +197,8 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
189
197
|
|
|
190
198
|
get assembliesInitialized() {
|
|
191
199
|
const { assemblyManager } = getSession(self)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
)
|
|
200
|
+
const { assemblyNames } = self
|
|
201
|
+
return assemblyNames.every(a => assemblyManager.get(a)?.initialized)
|
|
195
202
|
},
|
|
196
203
|
get initialized() {
|
|
197
204
|
return self.volatileWidth !== undefined && this.assembliesInitialized
|
|
@@ -273,11 +280,6 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
273
280
|
}
|
|
274
281
|
},
|
|
275
282
|
|
|
276
|
-
get assemblyNames() {
|
|
277
|
-
return [
|
|
278
|
-
...new Set(self.displayedRegions.map(region => region.assemblyName)),
|
|
279
|
-
]
|
|
280
|
-
},
|
|
281
283
|
searchScope(assemblyName: string) {
|
|
282
284
|
return {
|
|
283
285
|
assemblyName,
|
|
@@ -286,13 +288,6 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
286
288
|
}
|
|
287
289
|
},
|
|
288
290
|
|
|
289
|
-
/**
|
|
290
|
-
* @param refName - refName of the displayedRegion
|
|
291
|
-
* @param coord - coordinate at the displayed Region
|
|
292
|
-
* @param regionNumber - optional param used as identifier when
|
|
293
|
-
* there are multiple displayedRegions with the same refName
|
|
294
|
-
* @returns offsetPx of the displayed region that it lands in
|
|
295
|
-
*/
|
|
296
291
|
bpToPx({
|
|
297
292
|
refName,
|
|
298
293
|
coord,
|
|
@@ -396,10 +391,8 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
396
391
|
track => track.configuration.trackId,
|
|
397
392
|
)
|
|
398
393
|
results.forEach(result => {
|
|
399
|
-
if (openTrackIds
|
|
400
|
-
|
|
401
|
-
result.updateScore(result.getScore() + 1)
|
|
402
|
-
}
|
|
394
|
+
if (openTrackIds.includes(result.trackId)) {
|
|
395
|
+
result.updateScore(result.getScore() + 1)
|
|
403
396
|
}
|
|
404
397
|
})
|
|
405
398
|
return results
|
|
@@ -407,7 +400,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
407
400
|
|
|
408
401
|
// modifies view menu action onClick to apply to all tracks of same type
|
|
409
402
|
rewriteOnClicks(trackType: string, viewMenuActions: MenuItem[]) {
|
|
410
|
-
viewMenuActions.forEach(
|
|
403
|
+
viewMenuActions.forEach(action => {
|
|
411
404
|
// go to lowest level menu
|
|
412
405
|
if ('subMenu' in action) {
|
|
413
406
|
this.rewriteOnClicks(trackType, action.subMenu)
|
|
@@ -464,6 +457,9 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
464
457
|
toggleHeaderOverview() {
|
|
465
458
|
self.hideHeaderOverview = !self.hideHeaderOverview
|
|
466
459
|
},
|
|
460
|
+
toggleNoTracksActive() {
|
|
461
|
+
self.hideNoTracksActive = !self.hideNoTracksActive
|
|
462
|
+
},
|
|
467
463
|
|
|
468
464
|
scrollTo(offsetPx: number) {
|
|
469
465
|
const newOffsetPx = clamp(offsetPx, self.minOffset, self.maxOffset)
|
|
@@ -675,13 +671,38 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
675
671
|
const { assemblyManager } = getSession(self)
|
|
676
672
|
const { isValidRefName } = assemblyManager
|
|
677
673
|
const assemblyName = optAssemblyName || assemblyNames[0]
|
|
674
|
+
let parsedLocStrings
|
|
675
|
+
const inputs = locString
|
|
676
|
+
.split(/(\s+)/)
|
|
677
|
+
.map(f => f.trim())
|
|
678
|
+
.filter(f => !!f)
|
|
678
679
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
.map(l =>
|
|
680
|
+
// first try interpreting as a whitespace-separated sequence of
|
|
681
|
+
// multiple locstrings
|
|
682
|
+
try {
|
|
683
|
+
parsedLocStrings = inputs.map(l =>
|
|
684
|
+
parseLocString(l, ref => isValidRefName(ref, assemblyName)),
|
|
685
|
+
)
|
|
686
|
+
} catch (e) {
|
|
687
|
+
// if this fails, try interpreting as a whitespace-separated refname,
|
|
688
|
+
// start, end if start and end are integer inputs
|
|
689
|
+
const [refName, start, end] = inputs
|
|
690
|
+
if (
|
|
691
|
+
`${e}`.match(/Unknown reference sequence/) &&
|
|
692
|
+
Number.isInteger(+start) &&
|
|
693
|
+
Number.isInteger(+end)
|
|
694
|
+
) {
|
|
695
|
+
parsedLocStrings = [
|
|
696
|
+
parseLocString(refName + ':' + start + '..' + end, ref =>
|
|
697
|
+
isValidRefName(ref, assemblyName),
|
|
698
|
+
),
|
|
699
|
+
]
|
|
700
|
+
} else {
|
|
701
|
+
throw e
|
|
702
|
+
}
|
|
703
|
+
}
|
|
683
704
|
|
|
684
|
-
const locations = parsedLocStrings
|
|
705
|
+
const locations = parsedLocStrings?.map(region => {
|
|
685
706
|
const asmName = region.assemblyName || assemblyName
|
|
686
707
|
const asm = assemblyManager.get(asmName)
|
|
687
708
|
const { refName } = region
|
|
@@ -1207,6 +1228,13 @@ export function stateModelFactory(pluginManager: PluginManager) {
|
|
|
1207
1228
|
onClick: self.toggleHeaderOverview,
|
|
1208
1229
|
disabled: self.hideHeader,
|
|
1209
1230
|
},
|
|
1231
|
+
{
|
|
1232
|
+
label: 'Show no tracks active button',
|
|
1233
|
+
icon: VisibilityIcon,
|
|
1234
|
+
type: 'checkbox',
|
|
1235
|
+
checked: !self.hideNoTracksActive,
|
|
1236
|
+
onClick: self.toggleNoTracksActive,
|
|
1237
|
+
},
|
|
1210
1238
|
{
|
|
1211
1239
|
label: 'Track labels',
|
|
1212
1240
|
icon: LabelIcon,
|
package/src/index.ts
CHANGED
|
@@ -137,42 +137,47 @@ export default class LinearGenomeViewPlugin extends Plugin {
|
|
|
137
137
|
loc: string
|
|
138
138
|
tracks?: string[]
|
|
139
139
|
}) => {
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
try {
|
|
141
|
+
const { assemblyManager } = session
|
|
142
|
+
const view = session.addView('LinearGenomeView', {}) as LGV
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
await when(() => !!view.volatileWidth)
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
if (!assembly) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
'No assembly provided when launching linear genome view',
|
|
149
|
+
)
|
|
150
|
+
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
const asm = await assemblyManager.waitForAssembly(assembly)
|
|
153
|
+
if (!asm) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
`Assembly "${assembly}" not found when launching linear genome view`,
|
|
156
|
+
)
|
|
157
|
+
}
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
view.navToLocString(loc, assembly)
|
|
160
|
+
|
|
161
|
+
const idsNotFound = [] as string[]
|
|
162
|
+
tracks.forEach(track => {
|
|
163
|
+
try {
|
|
164
|
+
view.showTrack(track)
|
|
165
|
+
} catch (e) {
|
|
166
|
+
if (`${e}`.match('Could not resolve identifier')) {
|
|
167
|
+
idsNotFound.push(track)
|
|
168
|
+
} else {
|
|
169
|
+
throw e
|
|
170
|
+
}
|
|
169
171
|
}
|
|
172
|
+
})
|
|
173
|
+
if (idsNotFound.length) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Could not resolve identifiers: ${idsNotFound.join(',')}`,
|
|
176
|
+
)
|
|
170
177
|
}
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
throw
|
|
174
|
-
`Could not resolve identifiers: ${idsNotFound.join(',')}`,
|
|
175
|
-
)
|
|
178
|
+
} catch (e) {
|
|
179
|
+
session.notify(`${e}`, 'error')
|
|
180
|
+
throw e
|
|
176
181
|
}
|
|
177
182
|
},
|
|
178
183
|
)
|