@apollo-annotation/jbrowse-plugin-apollo 0.3.5 → 0.3.7

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 (136) hide show
  1. package/dist/index.esm.js +6964 -4598
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/jbrowse-plugin-apollo.cjs.development.js +6610 -4261
  4. package/dist/jbrowse-plugin-apollo.cjs.development.js.map +1 -1
  5. package/dist/jbrowse-plugin-apollo.cjs.production.min.js +1 -1
  6. package/dist/jbrowse-plugin-apollo.cjs.production.min.js.map +1 -1
  7. package/dist/jbrowse-plugin-apollo.umd.development.js +11563 -7493
  8. package/dist/jbrowse-plugin-apollo.umd.development.js.map +1 -1
  9. package/dist/jbrowse-plugin-apollo.umd.production.min.js +1 -1
  10. package/dist/jbrowse-plugin-apollo.umd.production.min.js.map +1 -1
  11. package/package.json +4 -4
  12. package/src/ApolloInternetAccount/addMenuItems.ts +23 -2
  13. package/src/ApolloInternetAccount/components/AuthTypeSelector.tsx +1 -0
  14. package/src/ApolloInternetAccount/components/LoginButtons.tsx +1 -1
  15. package/src/ApolloInternetAccount/components/LoginIcons.tsx +1 -1
  16. package/src/ApolloInternetAccount/configSchema.ts +1 -1
  17. package/src/ApolloInternetAccount/model.ts +11 -10
  18. package/src/ApolloJobModel.ts +1 -1
  19. package/src/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.ts +8 -6
  20. package/src/ApolloRefNameAliasAdapter/index.ts +2 -2
  21. package/src/ApolloSequenceAdapter/ApolloSequenceAdapter.ts +4 -4
  22. package/src/ApolloSequenceAdapter/index.ts +1 -1
  23. package/src/ApolloTextSearchAdapter/ApolloTextSearchAdapter.ts +8 -7
  24. package/src/ApolloTextSearchAdapter/index.ts +1 -1
  25. package/src/BackendDrivers/BackendDriver.ts +7 -7
  26. package/src/BackendDrivers/CollaborationServerDriver.ts +14 -10
  27. package/src/BackendDrivers/DesktopFileDriver.ts +11 -10
  28. package/src/BackendDrivers/InMemoryFileDriver.ts +10 -6
  29. package/src/ChangeManager.ts +15 -11
  30. package/src/FeatureDetailsWidget/ApolloFeatureDetailsWidget.tsx +8 -7
  31. package/src/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.tsx +35 -14
  32. package/src/FeatureDetailsWidget/AttributeKey.tsx +50 -0
  33. package/src/FeatureDetailsWidget/AttributeKeySelector.tsx +104 -0
  34. package/src/FeatureDetailsWidget/Attributes.tsx +215 -367
  35. package/src/FeatureDetailsWidget/BasicInformation.tsx +6 -5
  36. package/src/FeatureDetailsWidget/DefaultAttributeEditor.tsx +104 -0
  37. package/src/FeatureDetailsWidget/DefaultAttributeViewer.tsx +22 -0
  38. package/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx +4 -4
  39. package/src/FeatureDetailsWidget/NumberTextField.tsx +1 -1
  40. package/src/FeatureDetailsWidget/Sequence.tsx +2 -2
  41. package/src/FeatureDetailsWidget/StringTextField.tsx +1 -1
  42. package/src/FeatureDetailsWidget/TranscriptSequence.tsx +15 -23
  43. package/src/FeatureDetailsWidget/TranscriptWidgetEditLocation.tsx +950 -196
  44. package/src/FeatureDetailsWidget/TranscriptWidgetSummary.tsx +8 -4
  45. package/src/FeatureDetailsWidget/model.ts +8 -3
  46. package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +7 -7
  47. package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +59 -72
  48. package/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +253 -60
  49. package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +52 -6
  50. package/src/LinearApolloDisplay/glyphs/Glyph.ts +16 -8
  51. package/src/LinearApolloDisplay/stateModel/base.ts +81 -10
  52. package/src/LinearApolloDisplay/stateModel/index.ts +4 -3
  53. package/src/LinearApolloDisplay/stateModel/layouts.ts +8 -39
  54. package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +63 -46
  55. package/src/LinearApolloDisplay/stateModel/rendering.ts +60 -31
  56. package/src/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.tsx +226 -0
  57. package/src/LinearApolloSixFrameDisplay/components/TrackLines.tsx +32 -0
  58. package/src/LinearApolloSixFrameDisplay/components/index.ts +2 -0
  59. package/src/LinearApolloSixFrameDisplay/configSchema.ts +7 -0
  60. package/src/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.ts +940 -0
  61. package/src/LinearApolloSixFrameDisplay/glyphs/Glyph.ts +63 -0
  62. package/src/LinearApolloSixFrameDisplay/glyphs/index.ts +1 -0
  63. package/src/LinearApolloSixFrameDisplay/index.ts +2 -0
  64. package/src/LinearApolloSixFrameDisplay/stateModel/base.ts +302 -0
  65. package/src/LinearApolloSixFrameDisplay/stateModel/index.ts +27 -0
  66. package/src/LinearApolloSixFrameDisplay/stateModel/layouts.ts +252 -0
  67. package/src/LinearApolloSixFrameDisplay/stateModel/mouseEvents.ts +368 -0
  68. package/src/LinearApolloSixFrameDisplay/stateModel/rendering.ts +201 -0
  69. package/src/LinearApolloSixFrameDisplay/types.ts +1 -0
  70. package/src/OntologyManager/OntologyStore/fulltext.test.ts +1 -1
  71. package/src/OntologyManager/OntologyStore/fulltext.ts +8 -3
  72. package/src/OntologyManager/OntologyStore/index.test.ts +3 -1
  73. package/src/OntologyManager/OntologyStore/index.ts +19 -14
  74. package/src/OntologyManager/OntologyStore/indexeddb-schema.ts +6 -5
  75. package/src/OntologyManager/OntologyStore/indexeddb-storage.ts +11 -5
  76. package/src/OntologyManager/index.ts +12 -7
  77. package/src/OntologyManager/util.ts +3 -2
  78. package/src/TabularEditor/HybridGrid/ChangeHandling.ts +2 -2
  79. package/src/TabularEditor/HybridGrid/Feature.tsx +13 -7
  80. package/src/TabularEditor/HybridGrid/FeatureAttributes.tsx +1 -1
  81. package/src/TabularEditor/HybridGrid/HybridGrid.tsx +3 -2
  82. package/src/TabularEditor/HybridGrid/ToolBar.tsx +1 -1
  83. package/src/TabularEditor/HybridGrid/featureContextMenuItems.ts +114 -22
  84. package/src/TabularEditor/TabularEditorPane.tsx +1 -1
  85. package/src/TabularEditor/model.ts +2 -2
  86. package/src/TabularEditor/types.ts +5 -2
  87. package/src/components/AddAssembly.tsx +182 -179
  88. package/src/components/AddAssemblyAliases.tsx +114 -0
  89. package/src/components/AddChildFeature.tsx +8 -10
  90. package/src/components/AddFeature.tsx +216 -44
  91. package/src/components/AddRefSeqAliases.tsx +14 -12
  92. package/src/components/CopyFeature.tsx +10 -11
  93. package/src/components/CreateApolloAnnotation.tsx +342 -158
  94. package/src/components/DeleteAssembly.tsx +9 -8
  95. package/src/components/DeleteFeature.tsx +362 -14
  96. package/src/components/Dialog.tsx +1 -1
  97. package/src/components/DownloadGFF3.tsx +31 -11
  98. package/src/components/FilterFeatures.tsx +6 -4
  99. package/src/components/FilterTranscripts.tsx +86 -0
  100. package/src/components/ImportFeatures.tsx +7 -6
  101. package/src/components/LogOut.tsx +5 -4
  102. package/src/components/ManageChecks.tsx +9 -8
  103. package/src/components/ManageUsers.tsx +11 -10
  104. package/src/components/MergeExons.tsx +193 -0
  105. package/src/components/MergeTranscripts.tsx +185 -0
  106. package/src/components/OntologyTermAutocomplete.tsx +5 -5
  107. package/src/components/OntologyTermMultiSelect.tsx +6 -6
  108. package/src/components/OpenLocalFile.tsx +4 -3
  109. package/src/components/SplitExon.tsx +134 -0
  110. package/src/components/ViewChangeLog.tsx +7 -6
  111. package/src/components/ViewCheckResults.tsx +8 -7
  112. package/src/components/index.ts +3 -0
  113. package/src/config.ts +5 -0
  114. package/src/extensions/annotationFromJBrowseFeature.test.ts +1 -0
  115. package/src/extensions/annotationFromJBrowseFeature.ts +13 -10
  116. package/src/extensions/annotationFromPileup.ts +104 -94
  117. package/src/index.ts +33 -50
  118. package/src/makeDisplayComponent.tsx +90 -37
  119. package/src/session/ClientDataStore.ts +21 -17
  120. package/src/session/session.ts +46 -39
  121. package/src/types.ts +4 -4
  122. package/src/util/annotationFeatureUtils.ts +66 -1
  123. package/src/util/copyToClipboard.ts +21 -0
  124. package/src/util/glyphUtils.ts +49 -0
  125. package/src/util/index.ts +5 -3
  126. package/src/util/loadAssemblyIntoClient.ts +10 -3
  127. package/src/util/mouseEventsUtils.ts +113 -0
  128. package/src/ApolloSixFrameRenderer/ApolloSixFrameRenderer.tsx +0 -13
  129. package/src/ApolloSixFrameRenderer/components/ApolloRendering.tsx +0 -707
  130. package/src/ApolloSixFrameRenderer/configSchema.ts +0 -7
  131. package/src/ApolloSixFrameRenderer/index.ts +0 -3
  132. package/src/SixFrameFeatureDisplay/components/TrackLines.tsx +0 -19
  133. package/src/SixFrameFeatureDisplay/components/index.ts +0 -1
  134. package/src/SixFrameFeatureDisplay/configSchema.ts +0 -21
  135. package/src/SixFrameFeatureDisplay/index.ts +0 -2
  136. package/src/SixFrameFeatureDisplay/stateModel.ts +0 -443
@@ -13,22 +13,23 @@ import {
13
13
  DialogContentText,
14
14
  MenuItem,
15
15
  Select,
16
- SelectChangeEvent,
16
+ type SelectChangeEvent,
17
17
  } from '@mui/material'
18
18
  import {
19
19
  DataGrid,
20
- GridColDef,
21
- GridRowsProp,
20
+ type GridColDef,
21
+ type GridRowsProp,
22
22
  GridToolbar,
23
23
  } from '@mui/x-data-grid'
24
24
  import { getRoot } from 'mobx-state-tree'
25
25
  import React, { useEffect, useState } from 'react'
26
26
  import { makeStyles } from 'tss-react/mui'
27
27
 
28
- import { ApolloInternetAccountModel } from '../ApolloInternetAccount/model'
29
- import { ApolloSessionModel } from '../session'
30
- import { ApolloRootModel } from '../types'
28
+ import { type ApolloInternetAccountModel } from '../ApolloInternetAccount/model'
29
+ import { type ApolloSessionModel } from '../session'
30
+ import { type ApolloRootModel } from '../types'
31
31
  import { createFetchErrorMessage } from '../util'
32
+
32
33
  import { Dialog } from './Dialog'
33
34
 
34
35
  interface ViewChangeLogProps {
@@ -4,7 +4,7 @@
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
6
6
  /* eslint-disable @typescript-eslint/no-unsafe-return */
7
- import { Assembly } from '@jbrowse/core/assemblyManager/assembly'
7
+ import { type Assembly } from '@jbrowse/core/assemblyManager/assembly'
8
8
  import {
9
9
  Button,
10
10
  DialogActions,
@@ -12,21 +12,22 @@ import {
12
12
  DialogContentText,
13
13
  MenuItem,
14
14
  Select,
15
- SelectChangeEvent,
15
+ type SelectChangeEvent,
16
16
  } from '@mui/material'
17
17
  import {
18
18
  DataGrid,
19
- GridColDef,
20
- GridRowsProp,
19
+ type GridColDef,
20
+ type GridRowsProp,
21
21
  GridToolbar,
22
22
  } from '@mui/x-data-grid'
23
23
  import { getRoot } from 'mobx-state-tree'
24
24
  import React, { useEffect, useState } from 'react'
25
25
 
26
- import { ApolloInternetAccountModel } from '../ApolloInternetAccount/model'
27
- import { ApolloSessionModel } from '../session'
28
- import { ApolloRootModel } from '../types'
26
+ import { type ApolloInternetAccountModel } from '../ApolloInternetAccount/model'
27
+ import { type ApolloSessionModel } from '../session'
28
+ import { type ApolloRootModel } from '../types'
29
29
  import { createFetchErrorMessage } from '../util'
30
+
30
31
  import { Dialog } from './Dialog'
31
32
 
32
33
  interface ViewCheckResultsProps {
@@ -9,7 +9,10 @@ export * from './ImportFeatures'
9
9
  export * from './LogOut'
10
10
  export * from './ManageChecks'
11
11
  export * from './ManageUsers'
12
+ export * from './MergeExons'
13
+ export * from './MergeTranscripts'
12
14
  export * from './OpenLocalFile'
13
15
  export * from './ViewChangeLog'
14
16
  export * from './AddRefSeqAliases'
15
17
  export * from './ViewCheckResults'
18
+ export * from './SplitExon'
package/src/config.ts CHANGED
@@ -10,6 +10,11 @@ const ApolloPluginConfigurationSchema = ConfigurationSchema('ApolloPlugin', {
10
10
  type: 'string',
11
11
  defaultValue: 'Sequence Ontology',
12
12
  },
13
+ hasRole: {
14
+ description: 'Flag used internally by jbrowse-plugin-apollo',
15
+ type: 'boolean',
16
+ defaultValue: false,
17
+ },
13
18
  })
14
19
 
15
20
  export default ApolloPluginConfigurationSchema
@@ -1,5 +1,6 @@
1
1
  import SimpleFeature from '@jbrowse/core/util/simpleFeature'
2
2
  import { describe, expect, it } from '@jest/globals'
3
+
3
4
  import { jbrowseFeatureToAnnotationFeature } from './annotationFromJBrowseFeature'
4
5
 
5
6
  describe('Convert JBrowse feature to annotation feature', () => {
@@ -3,21 +3,22 @@
3
3
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-call */
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-return */
6
- import DisplayType from '@jbrowse/core/pluggableElementTypes/DisplayType'
7
- import PluggableElementBase from '@jbrowse/core/pluggableElementTypes/PluggableElementBase'
8
- import AddIcon from '@mui/icons-material/Add'
6
+ import { type AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
7
+ import { gff3ToAnnotationFeature } from '@apollo-annotation/shared'
8
+ import { type GFF3Feature } from '@gmod/gff'
9
+ import { type Assembly } from '@jbrowse/core/assemblyManager/assembly'
10
+ import type DisplayType from '@jbrowse/core/pluggableElementTypes/DisplayType'
11
+ import type PluggableElementBase from '@jbrowse/core/pluggableElementTypes/PluggableElementBase'
9
12
  import {
10
- AbstractSessionModel,
13
+ type AbstractSessionModel,
11
14
  getContainingView,
12
15
  getSession,
13
16
  } from '@jbrowse/core/util'
14
- import { Assembly } from '@jbrowse/core/assemblyManager/assembly'
15
- import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
16
- import { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
17
- import { Feature } from '@jbrowse/core/util/simpleFeature'
17
+ import { type Feature } from '@jbrowse/core/util/simpleFeature'
18
+ import { type LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
19
+ import AddIcon from '@mui/icons-material/Add'
20
+
18
21
  import { CreateApolloAnnotation } from '../components/CreateApolloAnnotation'
19
- import { GFF3Feature } from '@gmod/gff'
20
- import { gff3ToAnnotationFeature } from '@apollo-annotation/shared'
21
22
 
22
23
  function simpleFeatureToGFF3Feature(
23
24
  feature: Feature,
@@ -136,6 +137,7 @@ export function annotationFromJBrowseFeature(
136
137
  contextMenuItems() {
137
138
  const session = getSession(self)
138
139
  const assembly = self.getAssembly()
140
+ const region = self.getFirstRegion()
139
141
  const feature = self.contextMenuFeature
140
142
  if (!feature) {
141
143
  return superContextMenuItems()
@@ -157,6 +159,7 @@ export function annotationFromJBrowseFeature(
157
159
  annotationFeature: self.getAnnotationFeature(assembly),
158
160
  assembly,
159
161
  refSeqId: self.getRefSeqId(assembly),
162
+ region,
160
163
  },
161
164
  ],
162
165
  )
@@ -3,22 +3,31 @@
3
3
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-call */
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-return */
6
- import { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
7
- import { AddFeatureChange } from '@apollo-annotation/shared'
8
- import { Assembly } from '@jbrowse/core/assemblyManager/assembly'
9
- import { DisplayType } from '@jbrowse/core/pluggableElementTypes'
10
- import PluggableElementBase from '@jbrowse/core/pluggableElementTypes/PluggableElementBase'
11
- import { getContainingView, getSession } from '@jbrowse/core/util'
12
- import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
6
+ import { type AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
7
+ import { type Assembly } from '@jbrowse/core/assemblyManager/assembly'
8
+ import { type DisplayType } from '@jbrowse/core/pluggableElementTypes'
9
+ import type PluggableElementBase from '@jbrowse/core/pluggableElementTypes/PluggableElementBase'
10
+ import {
11
+ type AbstractSessionModel,
12
+ getContainingView,
13
+ getSession,
14
+ } from '@jbrowse/core/util'
15
+ import { type LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
13
16
  import AddIcon from '@mui/icons-material/Add'
14
17
  import ObjectID from 'bson-objectid'
15
18
 
16
- import { ApolloSessionModel } from '../session'
19
+ import { CreateApolloAnnotation } from '../components/CreateApolloAnnotation'
17
20
 
18
- function parseCigar(cigar: string): [string | undefined, number][] {
19
- return (cigar.toUpperCase().match(/\d+\D/g) ?? []).map((op) => {
20
- return [(/\D/.exec(op) ?? [])[0], Number.parseInt(op, 10)]
21
- })
21
+ function parseCigar(cigar: string): [string, number][] {
22
+ const regex = /(\d+)([MIDNSHPX=])/g
23
+ const result: [string, number][] = []
24
+ let match
25
+
26
+ while ((match = regex.exec(cigar)) !== null) {
27
+ result.push([match[2], Number.parseInt(match[1], 10)])
28
+ }
29
+
30
+ return result
22
31
  }
23
32
 
24
33
  export function annotationFromPileup(pluggableElement: PluggableElementBase) {
@@ -62,55 +71,87 @@ export function annotationFromPileup(pluggableElement: PluggableElementBase) {
62
71
  }
63
72
  return refSeqId
64
73
  },
65
- createFeature() {
74
+ getAnnotationFeature() {
66
75
  const feature = self.contextMenuFeature
67
76
  const assembly = self.getAssembly()
68
77
  const refSeqId = self.getRefSeqId(assembly)
78
+ const start: number = feature.get('start')
79
+ const end: number = feature.get('end')
80
+ const strand = feature.get('strand')
81
+ const name = feature.get('name')
82
+
69
83
  const cigarData: string = feature.get('CIGAR')
70
84
  const ops = parseCigar(cigarData)
71
- let currOffset = 0
72
- const start: number = feature.get('start')
73
- let openStart: number | undefined
85
+ let position = start
86
+ let currentExonStart: number | undefined
74
87
  const exons: {
75
88
  start: number
76
89
  end: number
77
90
  }[] = []
91
+
92
+ // Example: [[96,S], [4,M], [4216,N], [357,M], [1,I], [628,M], [94,S]]
93
+ // Results in 2 exons
94
+ // M, = and X are matches -> exon
95
+ // N is a gap in the reference sequence -> intron
96
+ // I, S, H and P -> not counted in reference position
78
97
  for (const [op, len] of ops) {
79
- // open or continue open
80
- if (op === 'M' || op === '=') {
81
- // if it was closed, then open with start, strand, type
82
- if (openStart === undefined) {
83
- // add subfeature
84
- openStart = currOffset + start
98
+ switch (op) {
99
+ case 'M':
100
+ case '=':
101
+ case 'X': {
102
+ if (currentExonStart === undefined) {
103
+ currentExonStart = position
104
+ }
105
+ position += len
106
+ break
107
+ }
108
+
109
+ case 'N': {
110
+ if (currentExonStart !== undefined) {
111
+ exons.push({
112
+ start: currentExonStart,
113
+ end: position,
114
+ })
115
+ currentExonStart = undefined
116
+ }
117
+ position += len
118
+ break
119
+ }
120
+ case 'D': {
121
+ position += len
122
+ break
123
+ }
124
+ case 'I':
125
+ case 'S':
126
+ case 'H':
127
+ case 'P': {
128
+ // These operations do not affect the position in the reference sequence
129
+ break
130
+ }
131
+ default: {
132
+ throw new Error(`Unknown CIGAR operation: ${op}`)
85
133
  }
86
- } else if (op === 'N' && openStart !== undefined) {
87
- // if it was open, then close and add the subfeature
88
- exons.push({
89
- start: openStart,
90
- end: currOffset + openStart,
91
- })
92
- openStart = undefined
93
- }
94
- if (op !== 'I') {
95
- // we ignore insertions when calculating potential exon length
96
- currOffset += len
97
134
  }
98
135
  }
99
- // if we are still open, then close with the final length and add subfeature
100
- if (openStart !== undefined) {
136
+
137
+ // If still in exon at end
138
+ if (currentExonStart !== undefined) {
101
139
  exons.push({
102
- start: openStart,
103
- end: currOffset + start,
140
+ start: currentExonStart,
141
+ end: position,
104
142
  })
105
143
  }
106
144
 
107
145
  const newFeature: AnnotationFeatureSnapshot = {
108
146
  _id: ObjectID().toHexString(),
109
147
  refSeq: refSeqId,
110
- min: feature.get('start'),
111
- max: feature.get('end'),
148
+ min: start,
149
+ max: end,
112
150
  type: 'mRNA',
113
- strand: feature.get('strand'),
151
+ strand,
152
+ attributes: {
153
+ name: [name],
154
+ },
114
155
  }
115
156
  if (exons.length === 0) {
116
157
  return newFeature
@@ -118,75 +159,28 @@ export function annotationFromPileup(pluggableElement: PluggableElementBase) {
118
159
 
119
160
  const children: Record<string, AnnotationFeatureSnapshot> = {}
120
161
  newFeature.children = children
121
- const [firstExon] = exons
122
- const cdsFeature: AnnotationFeatureSnapshot = {
123
- _id: ObjectID().toHexString(),
124
- refSeq: refSeqId,
125
- min: firstExon.start,
126
- max: firstExon.end,
127
- type: 'CDS',
128
- strand: feature.get('strand'),
129
- }
130
- newFeature.children[cdsFeature._id] = cdsFeature
131
- if (exons.length === 1) {
132
- const exon: AnnotationFeatureSnapshot = {
133
- _id: ObjectID().toHexString(),
134
- refSeq: refSeqId,
135
- min: firstExon.start,
136
- max: firstExon.end,
137
- type: 'exon',
138
- strand: feature.get('strand'),
139
- }
140
- newFeature.children[exon._id] = exon
141
- return newFeature
142
- }
143
162
 
144
- const discontinuousLocations: {
145
- start: number
146
- end: number
147
- phase: 0 | 1 | 2
148
- }[] = []
149
- let phase: 0 | 1 | 2 = 0
150
163
  for (const exon of exons) {
151
- cdsFeature.min = Math.min(cdsFeature.min, exon.start)
152
- cdsFeature.max = Math.max(cdsFeature.max, exon.end)
153
- const { end, start } = exon
154
- discontinuousLocations.push({ start, end, phase })
155
- const localPhase = (end - start) % 3
156
- phase = ((phase + localPhase) % 3) as 0 | 1 | 2
157
164
  const newExon: AnnotationFeatureSnapshot = {
158
165
  _id: ObjectID().toHexString(),
159
166
  refSeq: refSeqId,
160
- min: start,
161
- max: end,
167
+ min: exon.start,
168
+ max: exon.end,
162
169
  type: 'exon',
163
- strand: feature.get('strand'),
170
+ strand,
164
171
  }
165
172
  newFeature.children[newExon._id] = newExon
166
173
  }
167
174
  return newFeature
168
175
  },
169
- async onPileupFeatureContext() {
170
- const newFeature = self.createFeature()
171
- const assembly = self.getAssembly()
172
- const assemblyId = assembly.name
173
- const change = new AddFeatureChange({
174
- changedIds: [newFeature._id],
175
- typeName: 'AddFeatureChange',
176
- assembly: assemblyId,
177
- addedFeature: newFeature,
178
- })
179
- const session = getSession(self)
180
- await (
181
- session as unknown as ApolloSessionModel
182
- ).apolloDataStore.changeManager.submit(change)
183
- session.notify('Annotation added successfully', 'success')
184
- },
185
176
  }))
186
177
  .views((self) => {
187
178
  const superContextMenuItems = self.contextMenuItems
188
179
  return {
189
180
  contextMenuItems() {
181
+ const session = getSession(self)
182
+ const assembly = self.getAssembly()
183
+ const region = self.getFirstRegion()
190
184
  const feature = self.contextMenuFeature
191
185
  if (!feature) {
192
186
  return superContextMenuItems()
@@ -196,7 +190,23 @@ export function annotationFromPileup(pluggableElement: PluggableElementBase) {
196
190
  {
197
191
  label: 'Create Apollo annotation',
198
192
  icon: AddIcon,
199
- onClick: self.onPileupFeatureContext,
193
+ onClick: () => {
194
+ ;(session as unknown as AbstractSessionModel).queueDialog(
195
+ (doneCallback) => [
196
+ CreateApolloAnnotation,
197
+ {
198
+ session,
199
+ handleClose: () => {
200
+ doneCallback()
201
+ },
202
+ annotationFeature: self.getAnnotationFeature(assembly),
203
+ assembly,
204
+ refSeqId: self.getRefSeqId(assembly),
205
+ region,
206
+ },
207
+ ],
208
+ )
209
+ },
200
210
  },
201
211
  ]
202
212
  },
package/src/index.ts CHANGED
@@ -9,41 +9,52 @@ import {
9
9
  changes,
10
10
  validationRegistry,
11
11
  } from '@apollo-annotation/shared'
12
+ import Plugin from '@jbrowse/core/Plugin'
13
+ import type PluginManager from '@jbrowse/core/PluginManager'
12
14
  import { ConfigurationSchema } from '@jbrowse/core/configuration'
13
15
  import {
14
16
  DisplayType,
15
17
  InternetAccountType,
16
- PluggableElementType,
18
+ type PluggableElementType,
17
19
  TrackType,
18
- ViewType,
20
+ type ViewType,
19
21
  WidgetType,
20
22
  createBaseTrackConfig,
21
23
  createBaseTrackModel,
22
24
  } from '@jbrowse/core/pluggableElementTypes'
23
- import Plugin from '@jbrowse/core/Plugin'
24
- import PluginManager from '@jbrowse/core/PluginManager'
25
25
  import {
26
- AbstractSessionModel,
27
- Region,
26
+ type AbstractSessionModel,
27
+ type Region,
28
28
  getSession,
29
29
  isAbstractMenuManager,
30
30
  } from '@jbrowse/core/util'
31
- import { LinearGenomeViewStateModel } from '@jbrowse/plugin-linear-genome-view'
31
+ import { type LinearGenomeViewStateModel } from '@jbrowse/plugin-linear-genome-view'
32
32
  import AddIcon from '@mui/icons-material/Add'
33
33
 
34
34
  import { version } from '../package.json'
35
+
35
36
  import {
36
37
  configSchema as apolloInternetAccountConfigSchema,
37
38
  modelFactory as apolloInternetAccountModelFactory,
38
39
  } from './ApolloInternetAccount'
40
+ import { installApolloRefNameAliasAdapter } from './ApolloRefNameAliasAdapter'
39
41
  import { installApolloSequenceAdapter } from './ApolloSequenceAdapter'
40
- import {
41
- ApolloSixFrameRenderer,
42
- ReactComponent as ApolloSixFrameRendererReactComponent,
43
- configSchema as apolloSixFrameRendererConfigSchema,
44
- } from './ApolloSixFrameRenderer'
45
42
  import { installApolloTextSearchAdapter } from './ApolloTextSearchAdapter'
46
- import { BackendDriver } from './BackendDrivers'
43
+ import { type BackendDriver } from './BackendDrivers'
44
+ import {
45
+ ApolloFeatureDetailsWidget,
46
+ ApolloFeatureDetailsWidgetModel,
47
+ ApolloTranscriptDetailsModel,
48
+ ApolloTranscriptDetailsWidget,
49
+ } from './FeatureDetailsWidget'
50
+ import {
51
+ configSchema as linearApolloDisplayConfigSchema,
52
+ stateModelFactory as LinearApolloDisplayStateModelFactory,
53
+ } from './LinearApolloDisplay'
54
+ import {
55
+ configSchema as linearApolloSixFrameDisplayConfigSchema,
56
+ stateModelFactory as LinearApolloSixFrameDisplayStateModelFactory,
57
+ } from './LinearApolloSixFrameDisplay'
47
58
  import {
48
59
  AddFeature,
49
60
  DownloadGFF3,
@@ -55,29 +66,14 @@ import {
55
66
  } from './components'
56
67
  import ApolloPluginConfigurationSchema from './config'
57
68
  import {
58
- annotationFromPileup,
59
69
  annotationFromJBrowseFeature,
70
+ annotationFromPileup,
60
71
  } from './extensions'
61
72
  import {
62
- ApolloFeatureDetailsWidget,
63
- ApolloFeatureDetailsWidgetModel,
64
- ApolloTranscriptDetailsModel,
65
- ApolloTranscriptDetailsWidget,
66
- } from './FeatureDetailsWidget'
67
- import {
68
- stateModelFactory as LinearApolloDisplayStateModelFactory,
69
- configSchema as linearApolloDisplayConfigSchema,
70
- } from './LinearApolloDisplay'
71
- import {
72
- DisplayComponent,
73
- makeSixFrameDisplayComponent,
73
+ LinearApolloDisplayComponent,
74
+ LinearApolloSixFrameDisplayComponent,
74
75
  } from './makeDisplayComponent'
75
- import { ApolloSessionModel, extendSession } from './session'
76
- import {
77
- stateModelFactory as SixFrameFeatureDisplayStateModelFactory,
78
- configSchemaFactory as sixFrameFeatureDisplayConfigSchemaFactory,
79
- } from './SixFrameFeatureDisplay'
80
- import { installApolloRefNameAliasAdapter } from './ApolloRefNameAliasAdapter'
76
+ import { type ApolloSessionModel, extendSession } from './session'
81
77
 
82
78
  interface RpcHandle {
83
79
  on(event: string, listener: (event: MessageEvent) => void): this
@@ -186,38 +182,25 @@ export default class ApolloPlugin extends Plugin {
186
182
  ),
187
183
  trackType: 'ApolloTrack',
188
184
  viewType: 'LinearGenomeView',
189
- ReactComponent: DisplayComponent,
185
+ ReactComponent: LinearApolloDisplayComponent,
190
186
  })
191
187
  })
192
188
 
193
189
  pluginManager.addDisplayType(() => {
194
- const configSchema =
195
- sixFrameFeatureDisplayConfigSchemaFactory(pluginManager)
196
- const SixFrameDisplayComponent =
197
- makeSixFrameDisplayComponent(pluginManager)
190
+ const configSchema = linearApolloSixFrameDisplayConfigSchema
198
191
  return new DisplayType({
199
- name: 'SixFrameFeatureDisplay',
192
+ name: 'LinearApolloSixFrameDisplay',
200
193
  configSchema,
201
- stateModel: SixFrameFeatureDisplayStateModelFactory(
194
+ stateModel: LinearApolloSixFrameDisplayStateModelFactory(
202
195
  pluginManager,
203
196
  configSchema,
204
197
  ),
205
198
  trackType: 'ApolloTrack',
206
199
  viewType: 'LinearGenomeView',
207
- ReactComponent: SixFrameDisplayComponent,
200
+ ReactComponent: LinearApolloSixFrameDisplayComponent,
208
201
  })
209
202
  })
210
203
 
211
- pluginManager.addRendererType(
212
- () =>
213
- new ApolloSixFrameRenderer({
214
- name: 'ApolloSixFrameRenderer',
215
- ReactComponent: ApolloSixFrameRendererReactComponent,
216
- configSchema: apolloSixFrameRendererConfigSchema,
217
- pluginManager,
218
- }),
219
- )
220
-
221
204
  pluginManager.addToExtensionPoint(
222
205
  'Core-extendSession',
223
206
  // @ts-expect-error not sure how to deal with snapshot model types