@apollo-annotation/jbrowse-plugin-apollo 0.3.12 → 1.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.
Files changed (192) hide show
  1. package/dist/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.d.ts +1 -1
  2. package/dist/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.d.ts.map +1 -1
  3. package/dist/BackendDrivers/BackendDriver.d.ts +29 -4
  4. package/dist/BackendDrivers/BackendDriver.d.ts.map +1 -1
  5. package/dist/BackendDrivers/CollaborationServerDriver.d.ts +3 -1
  6. package/dist/BackendDrivers/CollaborationServerDriver.d.ts.map +1 -1
  7. package/dist/BackendDrivers/LocalDriver/LocalDriver.d.ts +22 -0
  8. package/dist/BackendDrivers/LocalDriver/LocalDriver.d.ts.map +1 -0
  9. package/dist/BackendDrivers/LocalDriver/db.d.ts +4 -0
  10. package/dist/BackendDrivers/LocalDriver/db.d.ts.map +1 -0
  11. package/dist/BackendDrivers/index.d.ts +1 -2
  12. package/dist/BackendDrivers/index.d.ts.map +1 -1
  13. package/dist/ChangeManager.d.ts +3 -3
  14. package/dist/ChangeManager.d.ts.map +1 -1
  15. package/dist/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.d.ts +0 -6
  16. package/dist/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.d.ts.map +1 -1
  17. package/dist/FeatureDetailsWidget/TranscriptWidgetEditLocation.d.ts.map +1 -1
  18. package/dist/FeatureDetailsWidget/model.d.ts +0 -2
  19. package/dist/FeatureDetailsWidget/model.d.ts.map +1 -1
  20. package/dist/LinearApolloDisplay/components/CheckResultWarnings.d.ts.map +1 -1
  21. package/dist/LinearApolloDisplay/components/LinearApolloDisplay.d.ts.map +1 -1
  22. package/dist/LinearApolloDisplay/components/OverlayCanvas.d.ts +7 -0
  23. package/dist/LinearApolloDisplay/components/OverlayCanvas.d.ts.map +1 -0
  24. package/dist/LinearApolloDisplay/components/Tooltip.d.ts +10 -0
  25. package/dist/LinearApolloDisplay/components/Tooltip.d.ts.map +1 -0
  26. package/dist/LinearApolloDisplay/glyphs/BoxGlyph.d.ts +0 -1
  27. package/dist/LinearApolloDisplay/glyphs/BoxGlyph.d.ts.map +1 -1
  28. package/dist/LinearApolloDisplay/glyphs/CDSGlyph.d.ts +3 -0
  29. package/dist/LinearApolloDisplay/glyphs/CDSGlyph.d.ts.map +1 -0
  30. package/dist/LinearApolloDisplay/glyphs/ExonGlyph.d.ts +3 -0
  31. package/dist/LinearApolloDisplay/glyphs/ExonGlyph.d.ts.map +1 -0
  32. package/dist/LinearApolloDisplay/glyphs/GeneGlyph.d.ts.map +1 -1
  33. package/dist/LinearApolloDisplay/glyphs/GenericChildGlyph.d.ts.map +1 -1
  34. package/dist/LinearApolloDisplay/glyphs/Glyph.d.ts +26 -20
  35. package/dist/LinearApolloDisplay/glyphs/Glyph.d.ts.map +1 -1
  36. package/dist/LinearApolloDisplay/glyphs/TranscriptGlyph.d.ts +3 -0
  37. package/dist/LinearApolloDisplay/glyphs/TranscriptGlyph.d.ts.map +1 -0
  38. package/dist/LinearApolloDisplay/glyphs/util.d.ts +13 -0
  39. package/dist/LinearApolloDisplay/glyphs/util.d.ts.map +1 -1
  40. package/dist/LinearApolloDisplay/stateModel/base.d.ts +17 -0
  41. package/dist/LinearApolloDisplay/stateModel/base.d.ts.map +1 -1
  42. package/dist/LinearApolloDisplay/stateModel/index.d.ts +35 -17
  43. package/dist/LinearApolloDisplay/stateModel/index.d.ts.map +1 -1
  44. package/dist/LinearApolloDisplay/stateModel/layouts.d.ts +29 -7
  45. package/dist/LinearApolloDisplay/stateModel/layouts.d.ts.map +1 -1
  46. package/dist/LinearApolloDisplay/stateModel/mouseEvents.d.ts +69 -23
  47. package/dist/LinearApolloDisplay/stateModel/mouseEvents.d.ts.map +1 -1
  48. package/dist/LinearApolloDisplay/stateModel/rendering.d.ts +26 -9
  49. package/dist/LinearApolloDisplay/stateModel/rendering.d.ts.map +1 -1
  50. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/base.d.ts +6 -0
  51. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/base.d.ts.map +1 -1
  52. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/index.d.ts +6 -0
  53. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/index.d.ts.map +1 -1
  54. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/rendering.d.ts +6 -0
  55. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/rendering.d.ts.map +1 -1
  56. package/dist/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.d.ts.map +1 -1
  57. package/dist/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.d.ts.map +1 -1
  58. package/dist/LinearApolloSixFrameDisplay/glyphs/Glyph.d.ts +1 -1
  59. package/dist/LinearApolloSixFrameDisplay/glyphs/Glyph.d.ts.map +1 -1
  60. package/dist/LinearApolloSixFrameDisplay/stateModel/layouts.d.ts.map +1 -1
  61. package/dist/LinearApolloSixFrameDisplay/stateModel/rendering.d.ts.map +1 -1
  62. package/dist/OntologyManager/OntologyStore/fulltext.d.ts +1 -1
  63. package/dist/OntologyManager/OntologyStore/fulltext.d.ts.map +1 -1
  64. package/dist/OntologyManager/OntologyStore/index.d.ts +2 -2
  65. package/dist/OntologyManager/OntologyStore/index.d.ts.map +1 -1
  66. package/dist/OntologyManager/OntologyStore/indexeddb-storage.d.ts +1 -1
  67. package/dist/OntologyManager/OntologyStore/indexeddb-storage.d.ts.map +1 -1
  68. package/dist/OntologyManager/OntologyStore/types.d.ts +18 -0
  69. package/dist/OntologyManager/OntologyStore/types.d.ts.map +1 -0
  70. package/dist/TabularEditor/HybridGrid/featureContextMenuItems.d.ts.map +1 -1
  71. package/dist/components/AddChildFeature.d.ts.map +1 -1
  72. package/dist/components/ColorFeature.d.ts +13 -0
  73. package/dist/components/ColorFeature.d.ts.map +1 -0
  74. package/dist/components/CreateApolloAnnotation.d.ts.map +1 -1
  75. package/dist/components/DownloadGFF3.d.ts +4 -1
  76. package/dist/components/DownloadGFF3.d.ts.map +1 -1
  77. package/dist/components/DuplicateTranscript.d.ts.map +1 -1
  78. package/dist/components/ViewChangeLog.d.ts +2 -1
  79. package/dist/components/ViewChangeLog.d.ts.map +1 -1
  80. package/dist/components/ViewCheckResults.d.ts +2 -1
  81. package/dist/components/ViewCheckResults.d.ts.map +1 -1
  82. package/dist/components/index.d.ts +1 -1
  83. package/dist/components/index.d.ts.map +1 -1
  84. package/dist/config.d.ts +4 -0
  85. package/dist/config.d.ts.map +1 -0
  86. package/dist/extensions/annotationFromJBrowseFeature.d.ts.map +1 -1
  87. package/dist/extensions/annotationFromPileup.d.ts.map +1 -1
  88. package/dist/index.d.ts +11 -0
  89. package/dist/index.d.ts.map +1 -0
  90. package/dist/index.esm.js +6325 -5997
  91. package/dist/index.esm.js.map +1 -1
  92. package/dist/jbrowse-plugin-apollo.cjs.development.js +5869 -5541
  93. package/dist/jbrowse-plugin-apollo.cjs.development.js.map +1 -1
  94. package/dist/jbrowse-plugin-apollo.cjs.production.min.js +1 -1
  95. package/dist/jbrowse-plugin-apollo.cjs.production.min.js.map +1 -1
  96. package/dist/jbrowse-plugin-apollo.umd.development.js +16782 -25897
  97. package/dist/jbrowse-plugin-apollo.umd.development.js.map +1 -1
  98. package/dist/jbrowse-plugin-apollo.umd.production.min.js +1 -1
  99. package/dist/jbrowse-plugin-apollo.umd.production.min.js.map +1 -1
  100. package/dist/makeDisplayComponent.d.ts.map +1 -1
  101. package/dist/menus/Icons.d.ts +3 -0
  102. package/dist/menus/Icons.d.ts.map +1 -0
  103. package/dist/menus/topLevelMenu.d.ts.map +1 -1
  104. package/dist/session/changeHandlers.d.ts +9 -0
  105. package/dist/session/changeHandlers.d.ts.map +1 -0
  106. package/dist/util/annotationFeatureUtils.d.ts +2 -1
  107. package/dist/util/annotationFeatureUtils.d.ts.map +1 -1
  108. package/dist/util/glyphUtils.d.ts +3 -3
  109. package/dist/util/glyphUtils.d.ts.map +1 -1
  110. package/dist/util/index.d.ts +0 -1
  111. package/dist/util/index.d.ts.map +1 -1
  112. package/package.json +4 -4
  113. package/src/ApolloInternetAccount/model.ts +68 -4
  114. package/src/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.ts +6 -3
  115. package/src/ApolloTextSearchAdapter/ApolloTextSearchAdapter.ts +1 -1
  116. package/src/BackendDrivers/BackendDriver.ts +36 -3
  117. package/src/BackendDrivers/CollaborationServerDriver.ts +78 -23
  118. package/src/BackendDrivers/LocalDriver/LocalDriver.ts +367 -0
  119. package/src/BackendDrivers/LocalDriver/db.ts +37 -0
  120. package/src/BackendDrivers/index.ts +1 -2
  121. package/src/ChangeManager.ts +27 -25
  122. package/src/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.tsx +1 -1
  123. package/src/FeatureDetailsWidget/TranscriptWidgetEditLocation.tsx +69 -53
  124. package/src/LinearApolloDisplay/components/CheckResultWarnings.tsx +1 -5
  125. package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +95 -115
  126. package/src/LinearApolloDisplay/components/OverlayCanvas.tsx +76 -0
  127. package/src/LinearApolloDisplay/components/Tooltip.tsx +42 -0
  128. package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +60 -302
  129. package/src/LinearApolloDisplay/glyphs/CDSGlyph.ts +145 -0
  130. package/src/LinearApolloDisplay/glyphs/ExonGlyph.ts +212 -0
  131. package/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +65 -999
  132. package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +71 -181
  133. package/src/LinearApolloDisplay/glyphs/Glyph.ts +42 -66
  134. package/src/LinearApolloDisplay/glyphs/TranscriptGlyph.ts +291 -0
  135. package/src/LinearApolloDisplay/glyphs/util.ts +87 -0
  136. package/src/LinearApolloDisplay/stateModel/base.ts +83 -0
  137. package/src/LinearApolloDisplay/stateModel/layouts.ts +198 -138
  138. package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +252 -158
  139. package/src/LinearApolloDisplay/stateModel/rendering.ts +103 -21
  140. package/src/LinearApolloReferenceSequenceDisplay/drawSequenceOverlay.ts +3 -3
  141. package/src/LinearApolloReferenceSequenceDisplay/stateModel/base.ts +20 -2
  142. package/src/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.tsx +7 -2
  143. package/src/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.ts +8 -13
  144. package/src/LinearApolloSixFrameDisplay/glyphs/Glyph.ts +1 -1
  145. package/src/LinearApolloSixFrameDisplay/stateModel/layouts.ts +4 -3
  146. package/src/LinearApolloSixFrameDisplay/stateModel/mouseEvents.ts +1 -1
  147. package/src/LinearApolloSixFrameDisplay/stateModel/rendering.ts +2 -1
  148. package/src/OntologyManager/OntologyStore/__snapshots__/index.test.ts.snap +18262 -8519
  149. package/src/OntologyManager/OntologyStore/fulltext.ts +1 -2
  150. package/src/OntologyManager/OntologyStore/index.test.ts +5 -2
  151. package/src/OntologyManager/OntologyStore/index.ts +7 -8
  152. package/src/OntologyManager/OntologyStore/indexeddb-storage.ts +2 -2
  153. package/src/OntologyManager/OntologyStore/types.ts +27 -0
  154. package/src/OntologyManager/index.ts +15 -26
  155. package/src/TabularEditor/HybridGrid/featureContextMenuItems.ts +4 -5
  156. package/src/components/AddChildFeature.tsx +15 -8
  157. package/src/components/ColorFeature.tsx +167 -0
  158. package/src/components/CreateApolloAnnotation.tsx +35 -9
  159. package/src/components/DownloadGFF3.tsx +92 -121
  160. package/src/components/DuplicateTranscript.tsx +10 -0
  161. package/src/components/ViewChangeLog.tsx +123 -83
  162. package/src/components/ViewCheckResults.tsx +15 -73
  163. package/src/components/index.ts +1 -1
  164. package/src/config.ts +37 -19
  165. package/src/extensions/annotationFromJBrowseFeature.test.ts +1 -1
  166. package/src/extensions/annotationFromJBrowseFeature.ts +91 -63
  167. package/src/extensions/annotationFromPileup.ts +40 -40
  168. package/src/index.ts +45 -1
  169. package/src/makeDisplayComponent.tsx +10 -3
  170. package/src/menus/Icons.tsx +49 -0
  171. package/src/menus/topLevelMenu.ts +24 -96
  172. package/src/session/ClientDataStore.ts +16 -17
  173. package/src/session/changeHandlers.ts +261 -0
  174. package/src/session/session.ts +77 -46
  175. package/src/util/annotationFeatureUtils.ts +29 -1
  176. package/src/util/glyphUtils.ts +74 -31
  177. package/src/util/index.ts +0 -1
  178. package/dist/BackendDrivers/DesktopFileDriver.d.ts +0 -160
  179. package/dist/BackendDrivers/DesktopFileDriver.d.ts.map +0 -1
  180. package/dist/BackendDrivers/InMemoryFileDriver.d.ts +0 -162
  181. package/dist/BackendDrivers/InMemoryFileDriver.d.ts.map +0 -1
  182. package/dist/LinearApolloDisplay/glyphs/index.d.ts +0 -4
  183. package/dist/LinearApolloDisplay/glyphs/index.d.ts.map +0 -1
  184. package/dist/components/OpenLocalFile.d.ts +0 -15
  185. package/dist/components/OpenLocalFile.d.ts.map +0 -1
  186. package/dist/util/loadAssemblyIntoClient.d.ts +0 -5
  187. package/dist/util/loadAssemblyIntoClient.d.ts.map +0 -1
  188. package/src/BackendDrivers/DesktopFileDriver.ts +0 -184
  189. package/src/BackendDrivers/InMemoryFileDriver.ts +0 -107
  190. package/src/LinearApolloDisplay/glyphs/index.ts +0 -3
  191. package/src/components/OpenLocalFile.tsx +0 -189
  192. package/src/util/loadAssemblyIntoClient.ts +0 -94
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
2
2
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
- import type { ClientDataStore as ClientDataStoreType } from '@apollo-annotation/common'
4
3
  import {
5
4
  type AnnotationFeature,
6
5
  AnnotationFeatureModel,
@@ -12,8 +11,12 @@ import {
12
11
  filterJBrowseConfig,
13
12
  } from '@apollo-annotation/shared'
14
13
  import type PluginManager from '@jbrowse/core/PluginManager'
15
- import type { AssemblyModel } from '@jbrowse/core/assemblyManager/assembly'
16
- import { getConf, readConfObject } from '@jbrowse/core/configuration'
14
+ import type assemblyManager from '@jbrowse/core/assemblyManager'
15
+ import {
16
+ type AnyConfigurationModel,
17
+ getConf,
18
+ readConfObject,
19
+ } from '@jbrowse/core/configuration'
17
20
  import type { BaseTrackConfig } from '@jbrowse/core/pluggableElementTypes'
18
21
  import type {
19
22
  AbstractSessionModel,
@@ -34,15 +37,17 @@ import { autorun, flow, observable, when } from 'mobx'
34
37
 
35
38
  import type { ApolloInternetAccountModel } from '../ApolloInternetAccount/model'
36
39
  import { ApolloJobModel } from '../ApolloJobModel'
37
- import type { ChangeManager } from '../ChangeManager'
38
40
  import type ApolloPluginConfigurationSchema from '../config'
39
- import type { ApolloRootModel } from '../types'
41
+ import { type ApolloRootModel, isApolloInternetAccount } from '../types'
40
42
  import { createFetchErrorMessage } from '../util'
41
43
 
42
- import { clientDataStoreFactory } from './ClientDataStore'
44
+ import {
45
+ type ClientDataStoreModel,
46
+ clientDataStoreFactory,
47
+ } from './ClientDataStore'
43
48
 
44
49
  export interface ApolloSession extends AbstractSessionModel {
45
- apolloDataStore: ClientDataStoreType & { changeManager: ChangeManager }
50
+ apolloDataStore: ClientDataStoreModel
46
51
  apolloSelectedFeature?: AnnotationFeature
47
52
  apolloSetSelectedFeature(feature?: AnnotationFeature): void
48
53
  }
@@ -58,6 +63,8 @@ export interface HoveredFeature {
58
63
  bp: number
59
64
  }
60
65
 
66
+ type Assembly = Instance<ReturnType<typeof assemblyManager>>['assemblies'][0]
67
+
61
68
  export function extendSession(
62
69
  pluginManager: PluginManager,
63
70
  sessionModel: ReturnType<typeof types.model>,
@@ -110,31 +117,22 @@ export function extendSession(
110
117
  apolloSetHoveredFeature(feature?: HoveredFeature) {
111
118
  self.apolloHoveredFeature = feature
112
119
  },
113
- addApolloTrackConfig(assembly: AssemblyModel, baseURL?: string) {
120
+ addApolloLocalTrackConfig(assembly: Assembly) {
114
121
  const trackId = `apollo_track_${assembly.name}`
115
122
  const hasTrack = (self as unknown as AbstractSessionModel).tracks.some(
116
123
  (track) => track.trackId === trackId,
117
124
  )
118
125
  if (!hasTrack) {
119
- ;(self as unknown as SessionWithAddTracks).addTrackConf({
126
+ ;(
127
+ getRoot<ApolloRootModel>(self).jbrowse as {
128
+ addTrackConf: SessionWithAddTracks['addTrackConf']
129
+ }
130
+ ).addTrackConf({
120
131
  type: 'ApolloTrack',
121
132
  trackId,
122
- name: `Annotations (${
123
- // @ts-expect-error getConf types don't quite work here for some reason
124
- getConf(assembly, 'displayName') || assembly.name
125
- })`,
133
+ name: `Annotations (${assembly.displayName})`,
126
134
  assemblyNames: [assembly.name],
127
- textSearching: {
128
- textSearchAdapter: {
129
- type: 'ApolloTextSearchAdapter',
130
- trackId,
131
- assemblyNames: [assembly.name],
132
- textSearchAdapterId: `apollo_search_${assembly.name}`,
133
- ...(baseURL
134
- ? { baseURL: { uri: baseURL, locationType: 'UriLocation' } }
135
- : {}),
136
- },
137
- },
135
+ category: ['Apollo'],
138
136
  })
139
137
  }
140
138
  },
@@ -182,7 +180,7 @@ export function extendSession(
182
180
  }
183
181
  if (locations.length === 0) {
184
182
  for (const internetAccount of internetAccounts) {
185
- if ('baseURL' in internetAccount) {
183
+ if (isApolloInternetAccount(internetAccount)) {
186
184
  internetAccount.postUserLocation([])
187
185
  }
188
186
  }
@@ -191,7 +189,7 @@ export function extendSession(
191
189
 
192
190
  const allLocations: UserLocation[] = []
193
191
  for (const internetAccount of internetAccounts) {
194
- if ('baseURL' in internetAccount) {
192
+ if (isApolloInternetAccount(internetAccount)) {
195
193
  for (const location of locations) {
196
194
  const tmpLoc: UserLocation = {
197
195
  assemblyId: location.assemblyName,
@@ -257,7 +255,7 @@ export function extendSession(
257
255
  }
258
256
  if (locations.length === 0) {
259
257
  for (const internetAccount of internetAccounts) {
260
- if ('baseURL' in internetAccount) {
258
+ if (isApolloInternetAccount(internetAccount)) {
261
259
  internetAccount.postUserLocation([])
262
260
  }
263
261
  }
@@ -266,7 +264,7 @@ export function extendSession(
266
264
 
267
265
  const allLocations: UserLocation[] = []
268
266
  for (const internetAccount of internetAccounts) {
269
- if ('baseURL' in internetAccount) {
267
+ if (isApolloInternetAccount(internetAccount)) {
270
268
  for (const location of locations) {
271
269
  const tmpLoc: UserLocation = {
272
270
  assemblyId: location.assemblyName,
@@ -301,7 +299,51 @@ export function extendSession(
301
299
  pluginConfiguration,
302
300
  'hasRole',
303
301
  ) as boolean
304
- if (hasRole) {
302
+ const featureTypeOntologyName = readConfObject(
303
+ pluginConfiguration,
304
+ 'featureTypeOntologyName',
305
+ ) as string
306
+ const hasApolloInternetAccount = internetAccounts.some((ia) =>
307
+ isApolloInternetAccount(ia),
308
+ )
309
+ const nonApolloAssemblies = (
310
+ self as unknown as AbstractSessionModel
311
+ ).assemblyManager.assemblies.filter(
312
+ (a) =>
313
+ !(
314
+ getConf(a, ['sequence', 'metadata']) as {
315
+ apollo?: boolean
316
+ }
317
+ ).apollo,
318
+ )
319
+ if (!hasApolloInternetAccount || hasRole) {
320
+ // Wait for assemblyManager to load before we do this part
321
+ const { assemblies } = (self as unknown as AbstractSessionModel)
322
+ .assemblyManager
323
+ if (assemblies.length === 0) {
324
+ return
325
+ }
326
+ const { pluginConfiguration } = self.apolloDataStore
327
+ const configuredOntologies =
328
+ pluginConfiguration.ontologies as AnyConfigurationModel[]
329
+ const featureTypeOntology = configuredOntologies.find(
330
+ (ont) =>
331
+ readConfObject(ont, 'name') === featureTypeOntologyName,
332
+ )
333
+ if (!featureTypeOntology) {
334
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
335
+ pluginConfiguration.addOntology({
336
+ name: 'Sequence Ontology',
337
+ version: '01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa',
338
+ source: {
339
+ uri: 'https://raw.githubusercontent.com/The-Sequence-Ontology/SO-Ontologies/01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa/Ontology_Files/so.json',
340
+ locationType: 'UriLocation',
341
+ },
342
+ })
343
+ }
344
+ for (const a of nonApolloAssemblies) {
345
+ self.addApolloLocalTrackConfig(a)
346
+ }
305
347
  // @ts-expect-error not sure why snapshot type is wrong for snapshot
306
348
  applySnapshot(self, self.previousSnapshot)
307
349
  reaction.dispose()
@@ -369,23 +411,22 @@ export function extendSession(
369
411
  }))
370
412
 
371
413
  .views((self) => {
372
- const superTrackActionMenuItems = (
373
- self as unknown as AbstractSessionModel
374
- ).getTrackActionMenuItems
414
+ const superTrackActions = (self as unknown as AbstractSessionModel)
415
+ .getTrackActions
375
416
  return {
376
- getTrackActionMenuItems(conf: BaseTrackConfig) {
417
+ getTrackActions(conf: BaseTrackConfig) {
377
418
  if (
378
419
  conf.type === 'ApolloTrack' ||
379
420
  conf.type === 'ReferenceSequenceTrack'
380
421
  ) {
381
- return superTrackActionMenuItems?.(conf)
422
+ return superTrackActions?.(conf)
382
423
  }
383
424
  const trackId = readConfObject(conf, 'trackId') as string
384
425
  const sessionTrackIdentifier = '-sessionTrack'
385
426
  const isSessionTrack = trackId.endsWith(sessionTrackIdentifier)
386
427
  return isSessionTrack
387
428
  ? [
388
- ...(superTrackActionMenuItems?.(conf) ?? []),
429
+ ...(superTrackActions?.(conf) ?? []),
389
430
  {
390
431
  label: 'Save track to Apollo',
391
432
  onClick: async () => {
@@ -438,7 +479,7 @@ export function extendSession(
438
479
  },
439
480
  ]
440
481
  : [
441
- ...(superTrackActionMenuItems?.(conf) ?? []),
482
+ ...(superTrackActions?.(conf) ?? []),
442
483
  {
443
484
  label: 'Remove track from Apollo',
444
485
  onClick: async () => {
@@ -486,15 +527,9 @@ export function extendSession(
486
527
  return types.snapshotProcessor(sm, {
487
528
  postProcessor(snap: SnapshotOut<typeof sm>, node) {
488
529
  snap.apolloSelectedFeature = undefined
489
- const assemblies = Object.fromEntries(
490
- Object.entries(snap.apolloDataStore.assemblies).filter(
491
- ([, assembly]) => assembly.backendDriverType === 'InMemoryFileDriver',
492
- ),
493
- )
494
530
  // @ts-expect-error ontologyManager isn't actually required
495
531
  snap.apolloDataStore = {
496
532
  typeName: 'Client',
497
- assemblies,
498
533
  checkResults: {},
499
534
  }
500
535
  if (!node) {
@@ -507,10 +542,6 @@ export function extendSession(
507
542
  if (!feature) {
508
543
  continue
509
544
  }
510
- const assembly = apolloDataStore.assemblies.get(feature.assemblyId)
511
- if (assembly && assembly.backendDriverType === 'InMemoryFileDriver') {
512
- snap.apolloDataStore.checkResults[cr._id] = getSnapshot(cr)
513
- }
514
545
  }
515
546
  return snap
516
547
  },
@@ -1,4 +1,7 @@
1
- import type { AnnotationFeature } from '@apollo-annotation/mst'
1
+ import type {
2
+ AnnotationFeature,
3
+ AnnotationFeatureSnapshot,
4
+ } from '@apollo-annotation/mst'
2
5
 
3
6
  export function getFeatureName(feature: AnnotationFeature) {
4
7
  const { attributes } = feature
@@ -110,3 +113,28 @@ export function getRelatedFeatures(
110
113
  }
111
114
  return relatedFeatures
112
115
  }
116
+
117
+ export function removeSkippedAttributes(
118
+ feature: AnnotationFeatureSnapshot,
119
+ skippedAttributes: Set<string>,
120
+ ) {
121
+ if (feature.attributes) {
122
+ const newAttributes: Record<string, readonly string[] | undefined> = {}
123
+ for (const [attribute, values] of Object.entries(feature.attributes)) {
124
+ if (!skippedAttributes.has(attribute)) {
125
+ newAttributes[attribute] = values
126
+ }
127
+ }
128
+ feature.attributes =
129
+ Object.keys(newAttributes).length === 0 ? undefined : newAttributes
130
+ }
131
+ if (feature.children) {
132
+ const newChildren: Record<string, AnnotationFeatureSnapshot> = {}
133
+ for (const [childId, child] of Object.entries(feature.children)) {
134
+ const newChild = { ...child } as AnnotationFeatureSnapshot
135
+ removeSkippedAttributes(newChild, skippedAttributes)
136
+ newChildren[childId] = newChild
137
+ }
138
+ feature.children = newChildren
139
+ }
140
+ }
@@ -1,12 +1,11 @@
1
1
  import type {
2
2
  AnnotationFeature,
3
+ Children,
3
4
  TranscriptPartCoding,
4
5
  } from '@apollo-annotation/mst'
5
- import type { BaseDisplayModel } from '@jbrowse/core/pluggableElementTypes'
6
6
  import type { MenuItem } from '@jbrowse/core/ui'
7
7
  import {
8
8
  type AbstractSessionModel,
9
- getContainingView,
10
9
  isSessionModelWithWidgets,
11
10
  } from '@jbrowse/core/util'
12
11
  import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
@@ -15,11 +14,12 @@ import SkipPreviousRoundedIcon from '@mui/icons-material/SkipPreviousRounded'
15
14
 
16
15
  import type { LinearApolloDisplayMouseEvents } from '../LinearApolloDisplay/stateModel/mouseEvents'
17
16
  import type { LinearApolloSixFrameDisplayMouseEvents } from '../LinearApolloSixFrameDisplay/stateModel/mouseEvents'
18
- import { AddChildFeature, CopyFeature, DeleteFeature } from '../components'
17
+ import { AddChildFeature } from '../components/AddChildFeature'
18
+ import { ColorFeature } from '../components/ColorFeature'
19
+ import { CopyFeature } from '../components/CopyFeature'
20
+ import { DeleteFeature } from '../components/DeleteFeature'
19
21
  import type { ApolloSessionModel } from '../session'
20
22
 
21
- import type { MousePositionWithFeature } from '.'
22
-
23
23
  type NavLocation = Parameters<LinearGenomeViewModel['navTo']>[0]
24
24
 
25
25
  export function selectFeatureAndOpenWidget(
@@ -63,6 +63,20 @@ export function selectFeatureAndOpenWidget(
63
63
  }
64
64
  }
65
65
 
66
+ export function isGeneFeature(
67
+ feature: AnnotationFeature,
68
+ session: ApolloSessionModel,
69
+ ): boolean {
70
+ const { featureTypeOntology } = session.apolloDataStore.ontologyManager
71
+ if (!featureTypeOntology) {
72
+ throw new Error('featureTypeOntology is undefined')
73
+ }
74
+ return (
75
+ featureTypeOntology.isTypeOf(feature.type, 'gene') ||
76
+ featureTypeOntology.isTypeOf(feature.type, 'pseudogene')
77
+ )
78
+ }
79
+
66
80
  export function isTranscriptFeature(
67
81
  feature: AnnotationFeature,
68
82
  session: ApolloSessionModel,
@@ -99,6 +113,36 @@ export function isCDSFeature(
99
113
  return featureTypeOntology.isTypeOf(feature.type, 'CDS')
100
114
  }
101
115
 
116
+ export function looksLikeGene(
117
+ feature: AnnotationFeature,
118
+ session: ApolloSessionModel,
119
+ ) {
120
+ const { featureTypeOntology } = session.apolloDataStore.ontologyManager
121
+ if (!featureTypeOntology) {
122
+ throw new Error('featureTypeOntology is undefined')
123
+ }
124
+ const children = feature.children as Children
125
+ if (!children?.size) {
126
+ return false
127
+ }
128
+ const isGene = isGeneFeature(feature, session)
129
+ if (!isGene) {
130
+ return false
131
+ }
132
+ for (const [, child] of children) {
133
+ if (isTranscriptFeature(child, session)) {
134
+ const { children: grandChildren } = child as { children?: Children }
135
+ if (!grandChildren?.size) {
136
+ return false
137
+ }
138
+ return [...grandChildren.values()].some((grandchild) =>
139
+ isExonFeature(grandchild, session),
140
+ )
141
+ }
142
+ }
143
+ return false
144
+ }
145
+
102
146
  export interface AdjacentExons {
103
147
  upstream: AnnotationFeature | undefined
104
148
  downstream: AnnotationFeature | undefined
@@ -109,16 +153,8 @@ export function getAdjacentExons(
109
153
  display:
110
154
  | LinearApolloDisplayMouseEvents
111
155
  | LinearApolloSixFrameDisplayMouseEvents,
112
- mousePosition: MousePositionWithFeature,
113
- session: ApolloSessionModel,
114
156
  ): AdjacentExons {
115
- const lgv = getContainingView(
116
- display as BaseDisplayModel,
117
- ) as unknown as LinearGenomeViewModel
118
-
119
157
  // Genomic coords of current view
120
- const viewGenomicLeft = mousePosition.bp - lgv.bpPerPx * mousePosition.x
121
- const viewGenomicRight = viewGenomicLeft + lgv.coarseTotalBp
122
158
  if (!currentExon.parent) {
123
159
  return { upstream: undefined, downstream: undefined }
124
160
  }
@@ -126,7 +162,8 @@ export function getAdjacentExons(
126
162
  if (!transcript.children) {
127
163
  throw new Error(`Error getting children of ${transcript._id}`)
128
164
  }
129
- const { featureTypeOntology } = session.apolloDataStore.ontologyManager
165
+ const { featureTypeOntology } =
166
+ display.session.apolloDataStore.ontologyManager
130
167
  if (!featureTypeOntology) {
131
168
  throw new Error('featureTypeOntology is undefined')
132
169
  }
@@ -143,14 +180,14 @@ export function getAdjacentExons(
143
180
  }
144
181
  exons = exons.sort((a, b) => (a.min < b.min ? -1 : 1))
145
182
  for (const exon of exons) {
146
- if (exon.min > viewGenomicRight) {
183
+ if (exon.min > currentExon.max) {
147
184
  adjacentExons.downstream = exon
148
185
  break
149
186
  }
150
187
  }
151
188
  exons = exons.sort((a, b) => (a.min > b.min ? -1 : 1))
152
189
  for (const exon of exons) {
153
- if (exon.max < viewGenomicLeft) {
190
+ if (exon.max < currentExon.min) {
154
191
  adjacentExons.upstream = exon
155
192
  break
156
193
  }
@@ -241,19 +278,6 @@ export function isSelectedFeature(
241
278
  return Boolean(selectedFeature && feature._id === selectedFeature._id)
242
279
  }
243
280
 
244
- export function containsSelectedFeature(
245
- feature: AnnotationFeature,
246
- selectedFeature: AnnotationFeature | undefined,
247
- ): boolean {
248
- if (!selectedFeature) {
249
- return false
250
- }
251
- if (feature._id === selectedFeature._id) {
252
- return true
253
- }
254
- return feature.hasDescendant(selectedFeature._id)
255
- }
256
-
257
281
  function makeFeatureLabel(feature: AnnotationFeature) {
258
282
  let name: string | undefined
259
283
  if (feature.attributes.get('gff_name')) {
@@ -288,7 +312,6 @@ export function getContextMenuItemsForFeature(
288
312
  } = display
289
313
  const menuItems: MenuItem[] = []
290
314
  const role = internetAccount ? internetAccount.role : 'admin'
291
- const admin = role === 'admin'
292
315
  const readOnly = !(role && ['admin', 'user'].includes(role))
293
316
  const [region] = regions
294
317
  const sourceAssemblyId = display.getAssemblyId(region.assemblyName)
@@ -341,7 +364,7 @@ export function getContextMenuItemsForFeature(
341
364
  },
342
365
  {
343
366
  label: 'Delete feature',
344
- disabled: !admin,
367
+ disabled: readOnly,
345
368
  onClick: () => {
346
369
  ;(session as unknown as AbstractSessionModel).queueDialog(
347
370
  (doneCallback) => [
@@ -363,6 +386,26 @@ export function getContextMenuItemsForFeature(
363
386
  )
364
387
  },
365
388
  },
389
+ {
390
+ label: 'Color feature',
391
+ disabled: readOnly,
392
+ onClick: () => {
393
+ ;(session as unknown as AbstractSessionModel).queueDialog(
394
+ (doneCallback) => [
395
+ ColorFeature,
396
+ {
397
+ session,
398
+ handleClose: () => {
399
+ doneCallback()
400
+ },
401
+ changeManager,
402
+ sourceFeature,
403
+ sourceAssemblyId: currentAssemblyId,
404
+ },
405
+ ],
406
+ )
407
+ },
408
+ },
366
409
  )
367
410
  if (isSessionModelWithWidgets(session)) {
368
411
  menuItems.push({
package/src/util/index.ts CHANGED
@@ -28,7 +28,6 @@ export function getApolloInternetAccount(session: ApolloSessionModel) {
28
28
  | undefined
29
29
  }
30
30
 
31
- export * from './loadAssemblyIntoClient'
32
31
  export * from './annotationFeatureUtils'
33
32
  export * from './glyphUtils'
34
33
  export * from './mouseEventsUtils'
@@ -1,160 +0,0 @@
1
- import { type AssemblySpecificChange, type Change } from '@apollo-annotation/common';
2
- import type { AnnotationFeatureSnapshot, CheckResultSnapshot } from '@apollo-annotation/mst';
3
- import { ValidationResultSet } from '@apollo-annotation/shared';
4
- import { type Region } from '@jbrowse/core/util';
5
- import { BackendDriver, type RefNameAliases } from './BackendDriver';
6
- export declare class DesktopFileDriver extends BackendDriver {
7
- loadAssembly(assemblyName: string): Promise<import("@apollo-annotation/mst").ApolloAssemblyI>;
8
- getAssembly(assemblyName: string): Promise<import("@apollo-annotation/mst").ApolloAssemblyI>;
9
- getRefNameAliases(assemblyName: string): Promise<RefNameAliases[]>;
10
- getFeatures(region: Region): Promise<[AnnotationFeatureSnapshot[], CheckResultSnapshot[]]>;
11
- getSequence(region: Region): Promise<{
12
- seq: string;
13
- refSeq: string;
14
- }>;
15
- getRegions(assemblyName: string): Promise<Region[]>;
16
- getAssemblies(): ({
17
- configuration: any;
18
- } & import("@jbrowse/mobx-state-tree/dist/internal").NonEmptyObject & {
19
- error: unknown;
20
- loadingP: Promise<void> | undefined;
21
- volatileRegions: import("@jbrowse/core/assemblyManager/assembly").BasicRegion[] | undefined;
22
- refNameAliases: {
23
- [x: string]: string;
24
- } | undefined;
25
- canonicalToSeqAdapterRefNames: Record<string, string> | undefined;
26
- cytobands: import("@jbrowse/core/util").Feature[] | undefined;
27
- } & {
28
- getConf(arg: string): any;
29
- readonly lowerCaseRefNameAliases: {
30
- [k: string]: string;
31
- } | undefined;
32
- } & {
33
- readonly initialized: boolean;
34
- readonly name: string;
35
- readonly regions: import("@jbrowse/core/assemblyManager/assembly").BasicRegion[] | undefined;
36
- readonly aliases: string[];
37
- readonly displayName: string;
38
- hasName(name: string): boolean;
39
- readonly allAliases: string[];
40
- readonly allRefNames: string[] | undefined;
41
- readonly lowerCaseRefNames: string[] | undefined;
42
- readonly allRefNamesWithLowerCase: string[] | undefined;
43
- readonly rpcManager: import("@jbrowse/core/rpc/RpcManager").default;
44
- readonly refNameColors: string[];
45
- } & {
46
- readonly refNames: string[] | undefined;
47
- } & {
48
- getCanonicalRefName(refName: string): string | undefined;
49
- getCanonicalRefName2(refName: string): string;
50
- getRefNameColor(refName: string): string | undefined;
51
- isValidRefName(refName: string): boolean;
52
- getSeqAdapterRefName(canonicalRefName: string): string;
53
- } & {
54
- setLoaded({ regions, refNameAliases, cytobands, }: {
55
- regions: import("@jbrowse/core/util").Region[];
56
- refNameAliases: {
57
- [x: string]: string;
58
- };
59
- cytobands: import("@jbrowse/core/util").Feature[];
60
- }): void;
61
- setError(e: unknown): void;
62
- setRegions(regions: import("@jbrowse/core/util").Region[]): void;
63
- setRefNameAliases(aliases: {
64
- [x: string]: string;
65
- }): void;
66
- setCytobands(cytobands: import("@jbrowse/core/util").Feature[]): void;
67
- setCanonicalToSeqAdapterRefNames(map: Record<string, string>): void;
68
- setLoadingP(p?: Promise<void>): void;
69
- load(): Promise<void>;
70
- loadPre(): Promise<void>;
71
- } & {
72
- getAdapterMapEntry(adapterConf: {
73
- [x: string]: unknown;
74
- }, options: import("@jbrowse/core/data_adapters/BaseAdapter").BaseOptions): Promise<import("@jbrowse/core/assemblyManager/assembly").RefNameMap>;
75
- getRefNameMapForAdapter(adapterConf: {
76
- [x: string]: unknown;
77
- }, opts: import("@jbrowse/core/data_adapters/BaseAdapter").BaseOptions): Promise<{
78
- [x: string]: string;
79
- }>;
80
- getReverseRefNameMapForAdapter(adapterConf: {
81
- [x: string]: unknown;
82
- }, opts: import("@jbrowse/core/data_adapters/BaseAdapter").BaseOptions): Promise<{
83
- [x: string]: string;
84
- }>;
85
- afterCreate(): void;
86
- } & import("@jbrowse/mobx-state-tree").IStateTreeNode<import("@jbrowse/mobx-state-tree").IModelType<{
87
- configuration: import("@jbrowse/mobx-state-tree").IMaybe<import("@jbrowse/mobx-state-tree").IReferenceType<import("@jbrowse/mobx-state-tree").IAnyType>>;
88
- }, {
89
- error: unknown;
90
- loadingP: Promise<void> | undefined;
91
- volatileRegions: import("@jbrowse/core/assemblyManager/assembly").BasicRegion[] | undefined;
92
- refNameAliases: {
93
- [x: string]: string;
94
- } | undefined;
95
- canonicalToSeqAdapterRefNames: Record<string, string> | undefined;
96
- cytobands: import("@jbrowse/core/util").Feature[] | undefined;
97
- } & {
98
- getConf(arg: string): any;
99
- readonly lowerCaseRefNameAliases: {
100
- [k: string]: string;
101
- } | undefined;
102
- } & {
103
- readonly initialized: boolean;
104
- readonly name: string;
105
- readonly regions: import("@jbrowse/core/assemblyManager/assembly").BasicRegion[] | undefined;
106
- readonly aliases: string[];
107
- readonly displayName: string;
108
- hasName(name: string): boolean;
109
- readonly allAliases: string[];
110
- readonly allRefNames: string[] | undefined;
111
- readonly lowerCaseRefNames: string[] | undefined;
112
- readonly allRefNamesWithLowerCase: string[] | undefined;
113
- readonly rpcManager: import("@jbrowse/core/rpc/RpcManager").default;
114
- readonly refNameColors: string[];
115
- } & {
116
- readonly refNames: string[] | undefined;
117
- } & {
118
- getCanonicalRefName(refName: string): string | undefined;
119
- getCanonicalRefName2(refName: string): string;
120
- getRefNameColor(refName: string): string | undefined;
121
- isValidRefName(refName: string): boolean;
122
- getSeqAdapterRefName(canonicalRefName: string): string;
123
- } & {
124
- setLoaded({ regions, refNameAliases, cytobands, }: {
125
- regions: import("@jbrowse/core/util").Region[];
126
- refNameAliases: {
127
- [x: string]: string;
128
- };
129
- cytobands: import("@jbrowse/core/util").Feature[];
130
- }): void;
131
- setError(e: unknown): void;
132
- setRegions(regions: import("@jbrowse/core/util").Region[]): void;
133
- setRefNameAliases(aliases: {
134
- [x: string]: string;
135
- }): void;
136
- setCytobands(cytobands: import("@jbrowse/core/util").Feature[]): void;
137
- setCanonicalToSeqAdapterRefNames(map: Record<string, string>): void;
138
- setLoadingP(p?: Promise<void>): void;
139
- load(): Promise<void>;
140
- loadPre(): Promise<void>;
141
- } & {
142
- getAdapterMapEntry(adapterConf: {
143
- [x: string]: unknown;
144
- }, options: import("@jbrowse/core/data_adapters/BaseAdapter").BaseOptions): Promise<import("@jbrowse/core/assemblyManager/assembly").RefNameMap>;
145
- getRefNameMapForAdapter(adapterConf: {
146
- [x: string]: unknown;
147
- }, opts: import("@jbrowse/core/data_adapters/BaseAdapter").BaseOptions): Promise<{
148
- [x: string]: string;
149
- }>;
150
- getReverseRefNameMapForAdapter(adapterConf: {
151
- [x: string]: unknown;
152
- }, opts: import("@jbrowse/core/data_adapters/BaseAdapter").BaseOptions): Promise<{
153
- [x: string]: string;
154
- }>;
155
- afterCreate(): void;
156
- }, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>>)[];
157
- submitChange(change: Change | AssemblySpecificChange): Promise<ValidationResultSet>;
158
- searchFeatures(_term: string, _assemblies: string[]): Promise<AnnotationFeatureSnapshot[]>;
159
- }
160
- //# sourceMappingURL=DesktopFileDriver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DesktopFileDriver.d.ts","sourceRoot":"","sources":["../../src/BackendDrivers/DesktopFileDriver.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EAEZ,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,mBAAmB,EAGpB,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,oBAAoB,CAAA;AAK5D,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEpE,qBAAa,iBAAkB,SAAQ,aAAa;IAC5C,YAAY,CAAC,YAAY,EAAE,MAAM;IAgBjC,WAAW,CAAC,YAAY,EAAE,MAAM;IAQhC,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAalE,WAAW,CACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,yBAAyB,EAAE,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAK1D,WAAW,CAAC,MAAM,EAAE,MAAM;;;;IAW1B,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAczD,aAAa;;;;;gCAjET,wCAAQ;;;;;0BAMkD,oBAA0B;;;;;;;;;iCAOlF,wCAAc;;;;;;;;;;;;;;;;;;;;4BA8BX,oBAAkB;;;;8BAIxB,oBAA0B;;;mCAIc,oBAC5C;;;;uCAGM,oBACK;;;;;;;;2BAYS,yCAAuC,+BAC/C,wCAAe;;;wBAIlB,yCACT;;;;;wBAOW,yCACN;;;;;8BAvFuB,0BAC7B,gBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoFlC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB;IAoEpD,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,yBAAyB,EAAE,CAAC;CAGxC"}