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

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 (71) hide show
  1. package/dist/index.esm.js +2371 -1642
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/jbrowse-plugin-apollo.cjs.development.js +2384 -1641
  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 +4387 -2952
  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 +15 -15
  12. package/src/ApolloInternetAccount/model.ts +48 -13
  13. package/src/BackendDrivers/CollaborationServerDriver.ts +23 -2
  14. package/src/ChangeManager.ts +33 -13
  15. package/src/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.tsx +64 -5
  16. package/src/FeatureDetailsWidget/TranscriptSequence.tsx +70 -73
  17. package/src/FeatureDetailsWidget/TranscriptWidgetEditLocation.tsx +33 -31
  18. package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +60 -72
  19. package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +50 -194
  20. package/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +441 -180
  21. package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +53 -34
  22. package/src/LinearApolloDisplay/glyphs/Glyph.ts +7 -9
  23. package/src/LinearApolloDisplay/stateModel/base.ts +34 -43
  24. package/src/LinearApolloDisplay/stateModel/layouts.ts +3 -2
  25. package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +32 -261
  26. package/src/LinearApolloDisplay/stateModel/rendering.ts +43 -343
  27. package/src/LinearApolloReferenceSequenceDisplay/components/LinearApolloReferenceSequenceDisplay.tsx +87 -0
  28. package/src/LinearApolloReferenceSequenceDisplay/components/index.ts +1 -0
  29. package/src/LinearApolloReferenceSequenceDisplay/configSchema.ts +7 -0
  30. package/src/LinearApolloReferenceSequenceDisplay/index.ts +3 -0
  31. package/src/LinearApolloReferenceSequenceDisplay/stateModel/base.ts +227 -0
  32. package/src/LinearApolloReferenceSequenceDisplay/stateModel/index.ts +25 -0
  33. package/src/LinearApolloReferenceSequenceDisplay/stateModel/rendering.ts +481 -0
  34. package/src/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.tsx +95 -38
  35. package/src/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.ts +221 -201
  36. package/src/LinearApolloSixFrameDisplay/glyphs/Glyph.ts +12 -8
  37. package/src/LinearApolloSixFrameDisplay/stateModel/base.ts +42 -4
  38. package/src/LinearApolloSixFrameDisplay/stateModel/layouts.ts +4 -8
  39. package/src/LinearApolloSixFrameDisplay/stateModel/mouseEvents.ts +73 -97
  40. package/src/LinearApolloSixFrameDisplay/stateModel/rendering.ts +49 -61
  41. package/src/TabularEditor/HybridGrid/Feature.tsx +16 -14
  42. package/src/TabularEditor/HybridGrid/HybridGrid.tsx +7 -5
  43. package/src/components/AddAssembly.tsx +1 -1
  44. package/src/components/AddAssemblyAliases.tsx +1 -1
  45. package/src/components/AddChildFeature.tsx +5 -2
  46. package/src/components/AddFeature.tsx +9 -3
  47. package/src/components/AddRefSeqAliases.tsx +9 -9
  48. package/src/components/CopyFeature.tsx +3 -1
  49. package/src/components/CreateApolloAnnotation.tsx +1 -0
  50. package/src/components/DeleteAssembly.tsx +1 -1
  51. package/src/components/EditZoomThresholdDialog.tsx +69 -0
  52. package/src/components/FilterFeatures.tsx +7 -7
  53. package/src/components/FilterTranscripts.tsx +6 -6
  54. package/src/components/ImportFeatures.tsx +1 -1
  55. package/src/components/ManageChecks.tsx +1 -1
  56. package/src/components/MergeTranscripts.tsx +12 -15
  57. package/src/components/OntologyTermMultiSelect.tsx +11 -11
  58. package/src/components/OpenLocalFile.tsx +11 -7
  59. package/src/components/ViewCheckResults.tsx +1 -1
  60. package/src/components/index.ts +1 -0
  61. package/src/config.ts +6 -0
  62. package/src/index.ts +42 -105
  63. package/src/makeDisplayComponent.tsx +0 -1
  64. package/src/menus/index.ts +1 -0
  65. package/src/{ApolloInternetAccount/addMenuItems.ts → menus/topLevelMenu.ts} +56 -47
  66. package/src/menus/topLevelMenuAdmin.ts +154 -0
  67. package/src/session/session.ts +162 -116
  68. package/src/util/annotationFeatureUtils.ts +15 -21
  69. package/src/util/displayUtils.ts +149 -0
  70. package/src/util/glyphUtils.ts +152 -0
  71. package/src/util/mouseEventsUtils.ts +32 -0
@@ -2,8 +2,16 @@ import {
2
2
  type AnnotationFeature,
3
3
  type TranscriptPartCoding,
4
4
  } from '@apollo-annotation/mst'
5
+ import { type MenuItem } from '@jbrowse/core/ui'
6
+ import { type AbstractSessionModel } from '@jbrowse/core/util'
5
7
  import { type LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
6
8
 
9
+ import { type LinearApolloDisplayMouseEvents } from '../LinearApolloDisplay/stateModel/mouseEvents'
10
+ import { type LinearApolloSixFrameDisplayMouseEvents } from '../LinearApolloSixFrameDisplay/stateModel/mouseEvents'
11
+ import { AddChildFeature, CopyFeature, DeleteFeature } from '../components'
12
+
13
+ type NavLocation = Parameters<LinearGenomeViewModel['navTo']>[0]
14
+
7
15
  export function getMinAndMaxPx(
8
16
  feature: AnnotationFeature | TranscriptPartCoding,
9
17
  refName: string,
@@ -47,3 +55,147 @@ export function getOverlappingEdge(
47
55
  }
48
56
  return
49
57
  }
58
+
59
+ export function isSelectedFeature(
60
+ feature: AnnotationFeature,
61
+ selectedFeature: AnnotationFeature | undefined,
62
+ ) {
63
+ return Boolean(selectedFeature && feature._id === selectedFeature._id)
64
+ }
65
+
66
+ export function containsSelectedFeature(
67
+ feature: AnnotationFeature,
68
+ selectedFeature: AnnotationFeature | undefined,
69
+ ): boolean {
70
+ if (!selectedFeature) {
71
+ return false
72
+ }
73
+ if (feature._id === selectedFeature._id) {
74
+ return true
75
+ }
76
+ return feature.hasDescendant(selectedFeature._id)
77
+ }
78
+
79
+ function makeFeatureLabel(feature: AnnotationFeature) {
80
+ let name: string | undefined
81
+ if (feature.attributes.get('gff_name')) {
82
+ name = feature.attributes.get('gff_name')?.join(',')
83
+ } else if (feature.attributes.get('gff_id')) {
84
+ name = feature.attributes.get('gff_id')?.join(',')
85
+ } else {
86
+ name = feature._id
87
+ }
88
+ const coords = `(${(feature.min + 1).toLocaleString('en')}..${feature.max.toLocaleString('en')})`
89
+ const maxLen = 60
90
+ if (name && name.length + coords.length > maxLen + 5) {
91
+ const trim = maxLen - coords.length
92
+ name = trim > 0 ? name.slice(0, trim) : ''
93
+ name = `${name}[...]`
94
+ }
95
+ return `${name} ${coords}`
96
+ }
97
+
98
+ export function getContextMenuItemsForFeature(
99
+ display:
100
+ | LinearApolloSixFrameDisplayMouseEvents
101
+ | LinearApolloDisplayMouseEvents,
102
+ sourceFeature: AnnotationFeature,
103
+ ): MenuItem[] {
104
+ const {
105
+ apolloInternetAccount: internetAccount,
106
+ changeManager,
107
+ regions,
108
+ selectedFeature,
109
+ session,
110
+ } = display
111
+ const menuItems: MenuItem[] = []
112
+ const role = internetAccount ? internetAccount.role : 'admin'
113
+ const admin = role === 'admin'
114
+ const readOnly = !(role && ['admin', 'user'].includes(role))
115
+ const [region] = regions
116
+ const sourceAssemblyId = display.getAssemblyId(region.assemblyName)
117
+ const currentAssemblyId = display.getAssemblyId(region.assemblyName)
118
+ menuItems.push(
119
+ {
120
+ label: makeFeatureLabel(sourceFeature),
121
+ type: 'subHeader',
122
+ },
123
+ {
124
+ label: 'Add child feature',
125
+ disabled: readOnly,
126
+ onClick: () => {
127
+ ;(session as unknown as AbstractSessionModel).queueDialog(
128
+ (doneCallback) => [
129
+ AddChildFeature,
130
+ {
131
+ session,
132
+ handleClose: () => {
133
+ doneCallback()
134
+ },
135
+ changeManager,
136
+ sourceFeature,
137
+ sourceAssemblyId,
138
+ internetAccount,
139
+ },
140
+ ],
141
+ )
142
+ },
143
+ },
144
+ {
145
+ label: 'Copy features and annotations',
146
+ disabled: readOnly,
147
+ onClick: () => {
148
+ ;(session as unknown as AbstractSessionModel).queueDialog(
149
+ (doneCallback) => [
150
+ CopyFeature,
151
+ {
152
+ session,
153
+ handleClose: () => {
154
+ doneCallback()
155
+ },
156
+ changeManager,
157
+ sourceFeature,
158
+ sourceAssemblyId: currentAssemblyId,
159
+ },
160
+ ],
161
+ )
162
+ },
163
+ },
164
+ {
165
+ label: 'Delete feature',
166
+ disabled: !admin,
167
+ onClick: () => {
168
+ ;(session as unknown as AbstractSessionModel).queueDialog(
169
+ (doneCallback) => [
170
+ DeleteFeature,
171
+ {
172
+ session,
173
+ handleClose: () => {
174
+ doneCallback()
175
+ },
176
+ changeManager,
177
+ sourceFeature,
178
+ sourceAssemblyId: currentAssemblyId,
179
+ selectedFeature,
180
+ setSelectedFeature: (feature?: AnnotationFeature) => {
181
+ display.setSelectedFeature(feature)
182
+ },
183
+ },
184
+ ],
185
+ )
186
+ },
187
+ },
188
+ )
189
+ return menuItems
190
+ }
191
+
192
+ export function navToFeatureCenter(
193
+ feature: AnnotationFeature,
194
+ paddingPct: number,
195
+ refSeqLength: number,
196
+ ): NavLocation {
197
+ const paddingBp = (feature.max - feature.min) * paddingPct
198
+ const start = Math.max(feature.min - paddingBp, 1)
199
+ const end = Math.min(feature.max + paddingBp, refSeqLength)
200
+ return { refName: feature.refSeq, start, end }
201
+ }
@@ -1,4 +1,5 @@
1
1
  import { type AnnotationFeature } from '@apollo-annotation/mst'
2
+ import { type LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
2
3
 
3
4
  type MinEdge = 'min'
4
5
  type MaxEdge = 'max'
@@ -111,3 +112,34 @@ export function getPropagatedLocationChanges(
111
112
  }
112
113
  return expandFeatures(feature, newLocation, edge)
113
114
  }
115
+
116
+ /** extended information about the position of the mouse on the canvas, including the refName, bp, and displayedRegion number */
117
+ export interface MousePosition {
118
+ x: number
119
+ y: number
120
+ refName: string
121
+ bp: number
122
+ regionNumber: number
123
+ feature?: AnnotationFeature
124
+ }
125
+
126
+ export type MousePositionWithFeature = Required<MousePosition>
127
+
128
+ export function isMousePositionWithFeature(
129
+ mousePosition: MousePosition,
130
+ ): mousePosition is MousePositionWithFeature {
131
+ return 'feature' in mousePosition
132
+ }
133
+
134
+ export function getMousePosition(
135
+ event: React.MouseEvent,
136
+ lgv: LinearGenomeViewModel,
137
+ ): MousePosition {
138
+ const canvas = event.currentTarget
139
+ const { clientX, clientY } = event
140
+ const { left, top } = canvas.getBoundingClientRect()
141
+ const x = clientX - left
142
+ const y = clientY - top
143
+ const { coord: bp, index: regionNumber, refName } = lgv.pxToBp(x)
144
+ return { x, y, refName, bp, regionNumber }
145
+ }