@apollo-annotation/jbrowse-plugin-apollo 0.1.18 → 0.1.20

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 (85) hide show
  1. package/dist/index.esm.js +3189 -3575
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/jbrowse-plugin-apollo.cjs.development.js +3185 -3570
  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 +14884 -15905
  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 +33 -33
  12. package/src/ApolloInternetAccount/addMenuItems.ts +18 -0
  13. package/src/ApolloInternetAccount/components/AuthTypeSelector.tsx +1 -0
  14. package/src/ApolloInternetAccount/configSchema.ts +5 -2
  15. package/src/ApolloInternetAccount/model.ts +14 -5
  16. package/src/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.ts +94 -0
  17. package/src/ApolloRefNameAliasAdapter/configSchema.ts +12 -0
  18. package/src/ApolloRefNameAliasAdapter/index.ts +21 -0
  19. package/src/ApolloSequenceAdapter/ApolloSequenceAdapter.ts +1 -0
  20. package/src/ApolloSixFrameRenderer/components/ApolloRendering.tsx +10 -10
  21. package/src/ApolloTextSearchAdapter/ApolloTextSearchAdapter.ts +35 -32
  22. package/src/BackendDrivers/BackendDriver.ts +8 -0
  23. package/src/BackendDrivers/CollaborationServerDriver.ts +49 -1
  24. package/src/BackendDrivers/DesktopFileDriver.ts +14 -1
  25. package/src/BackendDrivers/InMemoryFileDriver.ts +17 -1
  26. package/src/ChangeManager.ts +1 -1
  27. package/src/FeatureDetailsWidget/ApolloFeatureDetailsWidget.tsx +5 -25
  28. package/src/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.tsx +82 -0
  29. package/src/FeatureDetailsWidget/Attributes.tsx +11 -3
  30. package/src/FeatureDetailsWidget/BasicInformation.tsx +38 -30
  31. package/src/FeatureDetailsWidget/Sequence.tsx +7 -7
  32. package/src/FeatureDetailsWidget/TranscriptBasic.tsx +446 -0
  33. package/src/FeatureDetailsWidget/TranscriptSequence.tsx +365 -0
  34. package/src/FeatureDetailsWidget/index.ts +2 -0
  35. package/src/FeatureDetailsWidget/model.ts +77 -9
  36. package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +0 -2
  37. package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +453 -380
  38. package/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +520 -0
  39. package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +138 -134
  40. package/src/LinearApolloDisplay/glyphs/Glyph.ts +38 -370
  41. package/src/LinearApolloDisplay/glyphs/index.ts +1 -2
  42. package/src/LinearApolloDisplay/stateModel/base.ts +3 -6
  43. package/src/LinearApolloDisplay/stateModel/getGlyph.ts +30 -30
  44. package/src/LinearApolloDisplay/stateModel/index.ts +5 -1
  45. package/src/LinearApolloDisplay/stateModel/layouts.ts +32 -24
  46. package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +206 -217
  47. package/src/LinearApolloDisplay/stateModel/rendering.ts +43 -67
  48. package/src/OntologyManager/OntologyStore/fulltext.ts +1 -1
  49. package/src/OntologyManager/OntologyStore/index.ts +2 -1
  50. package/src/OntologyManager/index.ts +6 -2
  51. package/src/OntologyManager/util.ts +2 -2
  52. package/src/SixFrameFeatureDisplay/stateModel.ts +15 -10
  53. package/src/TabularEditor/HybridGrid/ChangeHandling.ts +21 -46
  54. package/src/TabularEditor/HybridGrid/Feature.tsx +31 -82
  55. package/src/TabularEditor/HybridGrid/FeatureAttributes.tsx +3 -2
  56. package/src/TabularEditor/HybridGrid/HybridGrid.tsx +2 -3
  57. package/src/TabularEditor/HybridGrid/NumberCell.tsx +1 -0
  58. package/src/TabularEditor/HybridGrid/featureContextMenuItems.ts +46 -5
  59. package/src/TabularEditor/model.ts +5 -3
  60. package/src/components/AddAssembly.tsx +15 -9
  61. package/src/components/AddChildFeature.tsx +7 -73
  62. package/src/components/AddFeature.tsx +2 -57
  63. package/src/components/AddRefSeqAliases.tsx +285 -0
  64. package/src/components/CopyFeature.tsx +16 -33
  65. package/src/components/DeleteFeature.tsx +4 -6
  66. package/src/components/ImportFeatures.tsx +6 -3
  67. package/src/components/LogOut.tsx +105 -0
  68. package/src/components/ManageChecks.tsx +1 -0
  69. package/src/components/ManageUsers.tsx +21 -1
  70. package/src/components/ModifyFeatureAttribute.tsx +2 -2
  71. package/src/components/OntologyTermAutocomplete.tsx +0 -2
  72. package/src/components/OntologyTermMultiSelect.tsx +1 -0
  73. package/src/components/OpenLocalFile.tsx +6 -5
  74. package/src/components/ViewChangeLog.tsx +1 -0
  75. package/src/components/ViewCheckResults.tsx +1 -0
  76. package/src/components/index.ts +4 -0
  77. package/src/extensions/annotationFromPileup.ts +10 -16
  78. package/src/index.ts +57 -3
  79. package/src/session/ClientDataStore.ts +49 -46
  80. package/src/session/session.ts +186 -114
  81. package/src/util/loadAssemblyIntoClient.ts +4 -210
  82. package/src/FeatureDetailsWidget/RelatedFeature.tsx +0 -97
  83. package/src/LinearApolloDisplay/glyphs/CanonicalGeneGlyph.ts +0 -1204
  84. package/src/LinearApolloDisplay/glyphs/ImplicitExonGeneGlyph.ts +0 -716
  85. package/src/LinearApolloDisplay/stateModel/glyphs.ts +0 -47
@@ -1,12 +1,8 @@
1
1
  import { ClientDataStore, checkRegistry } from '@apollo-annotation/common'
2
- import {
3
- AnnotationFeatureSnapshot,
4
- ApolloAssemblyI,
5
- CheckResultSnapshot,
6
- } from '@apollo-annotation/mst'
2
+ import { ApolloAssemblyI, CheckResultSnapshot } from '@apollo-annotation/mst'
3
+ import { gff3ToAnnotationFeature } from '@apollo-annotation/shared'
7
4
  import gff, { GFF3Comment, GFF3Feature, GFF3Sequence } from '@gmod/gff'
8
5
  import { getSnapshot } from 'mobx-state-tree'
9
- import { nanoid } from 'nanoid'
10
6
 
11
7
  export async function loadAssemblyIntoClient(
12
8
  assemblyId: string,
@@ -27,13 +23,13 @@ export async function loadAssemblyIntoClient(
27
23
  let sequenceFeatureCount = 0
28
24
  let assembly = apolloDataStore.assemblies.get(assemblyId)
29
25
  if (!assembly) {
30
- assembly = apolloDataStore.addAssembly(assemblyId)
26
+ assembly = apolloDataStore.addAssembly(assemblyId, 'InMemoryFileDriver')
31
27
  }
32
28
 
33
29
  for (const seqLine of featuresAndSequences) {
34
30
  if (Array.isArray(seqLine)) {
35
31
  // regular feature
36
- const feature = createFeature(seqLine)
32
+ const feature = gff3ToAnnotationFeature(seqLine)
37
33
 
38
34
  const ref =
39
35
  assembly.refSeqs.get(feature.refSeq) ??
@@ -88,205 +84,3 @@ export async function checkFeatures(
88
84
  }
89
85
  return checkResults
90
86
  }
91
-
92
- function createFeature(gff3Feature: GFF3Feature): AnnotationFeatureSnapshot {
93
- const [firstFeature] = gff3Feature
94
- const {
95
- attributes,
96
- child_features: childFeatures,
97
- end,
98
- phase,
99
- score,
100
- seq_id: refName,
101
- source,
102
- start,
103
- strand,
104
- type,
105
- } = firstFeature
106
- if (!refName) {
107
- throw new Error(
108
- `feature does not have seq_id: ${JSON.stringify(firstFeature)}`,
109
- )
110
- }
111
- if (!type) {
112
- throw new Error(
113
- `feature does not have type: ${JSON.stringify(firstFeature)}`,
114
- )
115
- }
116
- if (start === null) {
117
- throw new Error(
118
- `feature does not have start: ${JSON.stringify(firstFeature)}`,
119
- )
120
- }
121
- if (end === null) {
122
- throw new Error(
123
- `feature does not have end: ${JSON.stringify(firstFeature)}`,
124
- )
125
- }
126
- const feature: AnnotationFeatureSnapshot = {
127
- _id: nanoid(),
128
- gffId: '',
129
- refSeq: refName,
130
- type,
131
- start: start - 1,
132
- end,
133
- }
134
- if (gff3Feature.length > 1) {
135
- feature.discontinuousLocations = gff3Feature.map((f) => {
136
- const { end: subEnd, phase: locationPhase, start: subStart } = f
137
- if (subStart === null || subEnd === null) {
138
- throw new Error(
139
- `feature does not have start and/or end: ${JSON.stringify(f)}`,
140
- )
141
- }
142
- let parsedPhase: 0 | 1 | 2 | undefined
143
- if (locationPhase) {
144
- switch (locationPhase) {
145
- case '0': {
146
- parsedPhase = 0
147
-
148
- break
149
- }
150
- case '1': {
151
- parsedPhase = 1
152
-
153
- break
154
- }
155
- case '2': {
156
- parsedPhase = 2
157
-
158
- break
159
- }
160
- default: {
161
- throw new Error(`Unknown phase: "${locationPhase}"`)
162
- }
163
- }
164
- }
165
- return { start: subStart - 1, end: subEnd, phase: parsedPhase }
166
- })
167
- }
168
- if (strand) {
169
- if (strand === '+') {
170
- feature.strand = 1
171
- } else if (strand === '-') {
172
- feature.strand = -1
173
- } else {
174
- throw new Error(`Unknown strand: "${strand}"`)
175
- }
176
- }
177
- if (score !== null) {
178
- feature.score = score
179
- }
180
- if (phase) {
181
- switch (phase) {
182
- case '0': {
183
- feature.phase = 0
184
-
185
- break
186
- }
187
- case '1': {
188
- feature.phase = 1
189
-
190
- break
191
- }
192
- case '2': {
193
- feature.phase = 2
194
-
195
- break
196
- }
197
- default: {
198
- throw new Error(`Unknown phase: "${phase}"`)
199
- }
200
- }
201
- }
202
-
203
- if (childFeatures.length > 0) {
204
- const children: Record<string, AnnotationFeatureSnapshot> = {}
205
- for (const childFeature of childFeatures) {
206
- const child = createFeature(childFeature)
207
- children[child._id] = child
208
- // Add value to gffId
209
- child.attributes?._id
210
- ? (child.gffId = child.attributes._id.toString())
211
- : (child.gffId = child._id)
212
- }
213
- feature.children = children
214
- }
215
- if (source ?? attributes) {
216
- const attrs: Record<string, string[]> = {}
217
- if (source) {
218
- attrs.source = [source]
219
- }
220
- if (attributes) {
221
- for (const [key, val] of Object.entries(attributes)) {
222
- if (val) {
223
- const newKey = key.toLowerCase()
224
- if (newKey !== 'parent') {
225
- // attrs[key.toLowerCase()] = val
226
- switch (key) {
227
- case 'ID': {
228
- attrs._id = val
229
- break
230
- }
231
- case 'Name': {
232
- attrs.gff_name = val
233
- break
234
- }
235
- case 'Alias': {
236
- attrs.gff_alias = val
237
- break
238
- }
239
- case 'Target': {
240
- attrs.gff_target = val
241
- break
242
- }
243
- case 'Gap': {
244
- attrs.gff_gap = val
245
- break
246
- }
247
- case 'Derives_from': {
248
- attrs.gff_derives_from = val
249
- break
250
- }
251
- case 'Note': {
252
- attrs.gff_note = val
253
- break
254
- }
255
- case 'Dbxref': {
256
- attrs.gff_dbxref = val
257
- break
258
- }
259
- case 'Ontology_term': {
260
- const goTerms: string[] = []
261
- const otherTerms: string[] = []
262
- for (const v of val) {
263
- if (v.startsWith('GO:')) {
264
- goTerms.push(v)
265
- } else {
266
- otherTerms.push(v)
267
- }
268
- }
269
- if (goTerms.length > 0) {
270
- attrs['Gene Ontology'] = goTerms
271
- }
272
- if (otherTerms.length > 0) {
273
- attrs.gff_ontology_term = otherTerms
274
- }
275
- break
276
- }
277
- case 'Is_circular': {
278
- attrs.gff_is_circular = val
279
- break
280
- }
281
- default: {
282
- attrs[key.toLowerCase()] = val
283
- }
284
- }
285
- }
286
- }
287
- }
288
- }
289
- feature.attributes = attrs
290
- }
291
- return feature
292
- }
@@ -1,97 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
3
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
4
- import { AnnotationFeature, AnnotationFeatureI } from '@apollo-annotation/mst'
5
- import { SessionWithWidgets } from '@jbrowse/core/util'
6
- import { Button, Paper, Typography } from '@mui/material'
7
- import { observer } from 'mobx-react'
8
- import { IMSTMap } from 'mobx-state-tree'
9
- import React from 'react'
10
- import { makeStyles } from 'tss-react/mui'
11
-
12
- import { ApolloSessionModel } from '../session'
13
-
14
- const useStyles = makeStyles()((theme) => ({
15
- paper: {
16
- margin: theme.spacing(2),
17
- padding: theme.spacing(2),
18
- display: 'flex',
19
- flexDirection: 'column',
20
- },
21
- }))
22
-
23
- export const RelatedFeatures = observer(function RelatedFeatures({
24
- assembly,
25
- feature,
26
- refName,
27
- session,
28
- }: {
29
- feature: AnnotationFeatureI
30
- refName: string
31
- session: ApolloSessionModel
32
- assembly: string
33
- }) {
34
- const { classes } = useStyles()
35
- const { parent } = feature
36
- const { children } = feature as {
37
- children?: IMSTMap<typeof AnnotationFeature>
38
- }
39
-
40
- const onButtonClick = (newFeature: AnnotationFeatureI) => {
41
- if (parent) {
42
- const apolloFeatureWidget = (
43
- session as unknown as SessionWithWidgets
44
- ).addWidget('ApolloFeatureDetailsWidget', 'apolloFeatureDetailsWidget', {
45
- feature: newFeature,
46
- assembly,
47
- refName,
48
- })
49
- ;(session as unknown as SessionWithWidgets).showWidget(
50
- apolloFeatureWidget,
51
- )
52
- }
53
- }
54
-
55
- if (!(parent || (children && children.size > 0))) {
56
- return null
57
- }
58
- return (
59
- <>
60
- <Typography variant="h4">Related features</Typography>
61
- {parent && (
62
- <>
63
- <Typography variant="h5">Parent</Typography>
64
- <Paper elevation={6} className={classes.paper}>
65
- {`Start: ${parent.start}, End: ${parent.end}, Type: ${parent.type}`}
66
- <Button
67
- variant="contained"
68
- onClick={() => {
69
- onButtonClick(parent)
70
- }}
71
- >
72
- Go to parent
73
- </Button>
74
- </Paper>
75
- </>
76
- )}
77
- {children && children.size > 0 && (
78
- <>
79
- <Typography variant="h5">Children</Typography>
80
- {[...children.values()].map((child) => (
81
- <Paper elevation={6} className={classes.paper} key={child._id}>
82
- {`Start: ${child.start}, End: ${child.end}, Type: ${child.type}`}
83
- <Button
84
- variant="contained"
85
- onClick={() => {
86
- onButtonClick(child)
87
- }}
88
- >
89
- Go to child
90
- </Button>
91
- </Paper>
92
- ))}
93
- </>
94
- )}
95
- </>
96
- )
97
- })