@apollo-annotation/jbrowse-plugin-apollo 0.1.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.
- package/README.md +76 -0
- package/dist/index.esm.js +10248 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/jbrowse-plugin-apollo.cjs.development.js +10298 -0
- package/dist/jbrowse-plugin-apollo.cjs.development.js.map +1 -0
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js +2 -0
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js.map +1 -0
- package/dist/jbrowse-plugin-apollo.umd.development.js +46957 -0
- package/dist/jbrowse-plugin-apollo.umd.development.js.map +1 -0
- package/dist/jbrowse-plugin-apollo.umd.production.min.js +2 -0
- package/dist/jbrowse-plugin-apollo.umd.production.min.js.map +1 -0
- package/package.json +130 -0
- package/src/ApolloInternetAccount/addMenuItems.ts +94 -0
- package/src/ApolloInternetAccount/components/AuthTypeSelector.tsx +121 -0
- package/src/ApolloInternetAccount/components/LoginButtons.tsx +62 -0
- package/src/ApolloInternetAccount/components/LoginIcons.tsx +74 -0
- package/src/ApolloInternetAccount/configSchema.ts +26 -0
- package/src/ApolloInternetAccount/index.ts +2 -0
- package/src/ApolloInternetAccount/model.ts +448 -0
- package/src/ApolloJobModel.ts +117 -0
- package/src/ApolloSequenceAdapter/ApolloSequenceAdapter.ts +186 -0
- package/src/ApolloSequenceAdapter/configSchema.ts +12 -0
- package/src/ApolloSequenceAdapter/index.ts +21 -0
- package/src/ApolloSixFrameRenderer/ApolloSixFrameRenderer.tsx +12 -0
- package/src/ApolloSixFrameRenderer/components/ApolloRendering.tsx +692 -0
- package/src/ApolloSixFrameRenderer/configSchema.ts +7 -0
- package/src/ApolloSixFrameRenderer/index.ts +3 -0
- package/src/ApolloTextSearchAdapter/ApolloTextSearchAdapter.ts +64 -0
- package/src/ApolloTextSearchAdapter/configSchema.ts +24 -0
- package/src/ApolloTextSearchAdapter/index.ts +18 -0
- package/src/BackendDrivers/BackendDriver.ts +31 -0
- package/src/BackendDrivers/CollaborationServerDriver.ts +318 -0
- package/src/BackendDrivers/DesktopFileDriver.ts +170 -0
- package/src/BackendDrivers/InMemoryFileDriver.ts +76 -0
- package/src/BackendDrivers/index.ts +4 -0
- package/src/ChangeManager.ts +148 -0
- package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +248 -0
- package/src/LinearApolloDisplay/components/index.ts +1 -0
- package/src/LinearApolloDisplay/configSchema.ts +16 -0
- package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +422 -0
- package/src/LinearApolloDisplay/glyphs/CanonicalGeneGlyph.ts +1191 -0
- package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +151 -0
- package/src/LinearApolloDisplay/glyphs/Glyph.ts +382 -0
- package/src/LinearApolloDisplay/glyphs/ImplicitExonGeneGlyph.ts +697 -0
- package/src/LinearApolloDisplay/glyphs/index.ts +4 -0
- package/src/LinearApolloDisplay/index.ts +2 -0
- package/src/LinearApolloDisplay/stateModel/base.ts +146 -0
- package/src/LinearApolloDisplay/stateModel/getGlyph.ts +39 -0
- package/src/LinearApolloDisplay/stateModel/glyphs.ts +45 -0
- package/src/LinearApolloDisplay/stateModel/index.ts +20 -0
- package/src/LinearApolloDisplay/stateModel/layouts.ts +230 -0
- package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +513 -0
- package/src/LinearApolloDisplay/stateModel/rendering.ts +441 -0
- package/src/LinearApolloDisplay/stateModel/trackHeightMixin.ts +43 -0
- package/src/LinearApolloDisplay/types.ts +1 -0
- package/src/OntologyManager/OntologyStore/__snapshots__/fulltext.test.ts.snap +208 -0
- package/src/OntologyManager/OntologyStore/__snapshots__/index.test.ts.snap +18846 -0
- package/src/OntologyManager/OntologyStore/fulltext-stopwords.ts +137 -0
- package/src/OntologyManager/OntologyStore/fulltext.test.ts +94 -0
- package/src/OntologyManager/OntologyStore/fulltext.ts +264 -0
- package/src/OntologyManager/OntologyStore/index.test.ts +130 -0
- package/src/OntologyManager/OntologyStore/index.ts +526 -0
- package/src/OntologyManager/OntologyStore/indexeddb-schema.ts +89 -0
- package/src/OntologyManager/OntologyStore/indexeddb-storage.ts +180 -0
- package/src/OntologyManager/OntologyStore/obo-graph-json-schema.ts +110 -0
- package/src/OntologyManager/OntologyStore/prefixes.ts +35 -0
- package/src/OntologyManager/index.ts +173 -0
- package/src/SixFrameFeatureDisplay/components/TrackLines.tsx +19 -0
- package/src/SixFrameFeatureDisplay/components/index.ts +1 -0
- package/src/SixFrameFeatureDisplay/configSchema.ts +21 -0
- package/src/SixFrameFeatureDisplay/index.ts +2 -0
- package/src/SixFrameFeatureDisplay/stateModel.ts +413 -0
- package/src/TabularEditor/HybridGrid/ChangeHandling.ts +88 -0
- package/src/TabularEditor/HybridGrid/Feature.tsx +346 -0
- package/src/TabularEditor/HybridGrid/FeatureAttributes.tsx +34 -0
- package/src/TabularEditor/HybridGrid/Highlight.tsx +40 -0
- package/src/TabularEditor/HybridGrid/HybridGrid.tsx +138 -0
- package/src/TabularEditor/HybridGrid/NumberCell.tsx +77 -0
- package/src/TabularEditor/HybridGrid/ToolBar.tsx +59 -0
- package/src/TabularEditor/HybridGrid/featureContextMenuItems.ts +119 -0
- package/src/TabularEditor/HybridGrid/index.ts +1 -0
- package/src/TabularEditor/TabularEditorPane.tsx +34 -0
- package/src/TabularEditor/index.ts +3 -0
- package/src/TabularEditor/model.ts +44 -0
- package/src/TabularEditor/types.ts +3 -0
- package/src/components/AddAssembly.tsx +464 -0
- package/src/components/AddChildFeature.tsx +247 -0
- package/src/components/AddFeature.tsx +252 -0
- package/src/components/CopyFeature.tsx +328 -0
- package/src/components/DeleteAssembly.tsx +185 -0
- package/src/components/DeleteFeature.tsx +90 -0
- package/src/components/Dialog.tsx +47 -0
- package/src/components/DownloadGFF3.tsx +213 -0
- package/src/components/ImportFeatures.tsx +295 -0
- package/src/components/ManageChecks.tsx +280 -0
- package/src/components/ManageUsers.tsx +218 -0
- package/src/components/ModifyFeatureAttribute.tsx +457 -0
- package/src/components/OntologyTermAutocomplete.tsx +240 -0
- package/src/components/OntologyTermMultiSelect.tsx +349 -0
- package/src/components/OpenLocalFile.tsx +178 -0
- package/src/components/ViewChangeLog.tsx +208 -0
- package/src/components/ViewCheckResults.tsx +151 -0
- package/src/components/index.ts +12 -0
- package/src/config.ts +10 -0
- package/src/declare.d.ts +3 -0
- package/src/extensions/annotationFromPileup.ts +208 -0
- package/src/extensions/index.ts +1 -0
- package/src/index.ts +394 -0
- package/src/makeDisplayComponent.tsx +244 -0
- package/src/session/ClientDataStore.ts +282 -0
- package/src/session/index.ts +1 -0
- package/src/session/session.ts +373 -0
- package/src/types.ts +10 -0
- package/src/util/index.ts +31 -0
- package/src/util/loadAssemblyIntoClient.ts +291 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import gff, { GFF3Comment, GFF3Feature, GFF3Sequence } from '@gmod/gff'
|
|
2
|
+
import { ClientDataStore, checkRegistry } from 'apollo-common'
|
|
3
|
+
import {
|
|
4
|
+
AnnotationFeatureSnapshot,
|
|
5
|
+
ApolloAssemblyI,
|
|
6
|
+
CheckResultSnapshot,
|
|
7
|
+
} from 'apollo-mst'
|
|
8
|
+
import { getSnapshot } from 'mobx-state-tree'
|
|
9
|
+
import { nanoid } from 'nanoid'
|
|
10
|
+
|
|
11
|
+
export async function loadAssemblyIntoClient(
|
|
12
|
+
assemblyId: string,
|
|
13
|
+
gff3FileText: string,
|
|
14
|
+
apolloDataStore: ClientDataStore,
|
|
15
|
+
) {
|
|
16
|
+
const featuresAndSequences: (GFF3Feature | GFF3Sequence | GFF3Comment)[] =
|
|
17
|
+
gff.parseStringSync(gff3FileText, {
|
|
18
|
+
parseSequences: true,
|
|
19
|
+
parseComments: true,
|
|
20
|
+
parseDirectives: false,
|
|
21
|
+
parseFeatures: true,
|
|
22
|
+
})
|
|
23
|
+
if (featuresAndSequences.length === 0) {
|
|
24
|
+
throw new Error('No features found in GFF3 file')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let sequenceFeatureCount = 0
|
|
28
|
+
let assembly = apolloDataStore.assemblies.get(assemblyId)
|
|
29
|
+
if (!assembly) {
|
|
30
|
+
assembly = apolloDataStore.addAssembly(assemblyId)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const seqLine of featuresAndSequences) {
|
|
34
|
+
if (Array.isArray(seqLine)) {
|
|
35
|
+
// regular feature
|
|
36
|
+
const feature = createFeature(seqLine)
|
|
37
|
+
|
|
38
|
+
const ref =
|
|
39
|
+
assembly.refSeqs.get(feature.refSeq) ??
|
|
40
|
+
assembly.addRefSeq(feature.refSeq, feature.refSeq)
|
|
41
|
+
if (!ref.features.has(feature._id)) {
|
|
42
|
+
ref.addFeature(feature)
|
|
43
|
+
}
|
|
44
|
+
} else if ('comment' in seqLine) {
|
|
45
|
+
assembly.addComment(seqLine.comment)
|
|
46
|
+
} else {
|
|
47
|
+
sequenceFeatureCount++
|
|
48
|
+
// sequence feature
|
|
49
|
+
let ref = assembly.refSeqs.get(seqLine.id)
|
|
50
|
+
if (!ref) {
|
|
51
|
+
ref = assembly.addRefSeq(seqLine.id, seqLine.id, seqLine.description)
|
|
52
|
+
}
|
|
53
|
+
if (seqLine.description && !ref.description) {
|
|
54
|
+
ref.setDescription(seqLine.description)
|
|
55
|
+
}
|
|
56
|
+
ref.addSequence({
|
|
57
|
+
start: 0,
|
|
58
|
+
stop: seqLine.sequence.length,
|
|
59
|
+
sequence: seqLine.sequence,
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (sequenceFeatureCount === 0) {
|
|
65
|
+
throw new Error('No embedded FASTA section found in GFF3')
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const checkResults: CheckResultSnapshot[] = await checkFeatures(assembly)
|
|
69
|
+
apolloDataStore.addCheckResults(checkResults)
|
|
70
|
+
return assembly
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function checkFeatures(
|
|
74
|
+
assembly: ApolloAssemblyI,
|
|
75
|
+
): Promise<CheckResultSnapshot[]> {
|
|
76
|
+
const checkResults: CheckResultSnapshot[] = []
|
|
77
|
+
for (const ref of assembly.refSeqs.values()) {
|
|
78
|
+
for (const feature of ref.features.values()) {
|
|
79
|
+
for (const check of checkRegistry.getChecks().values()) {
|
|
80
|
+
const result: CheckResultSnapshot[] = await check.checkFeature(
|
|
81
|
+
getSnapshot(feature),
|
|
82
|
+
async (start: number, stop: number) => ref.getSequence(start, stop),
|
|
83
|
+
)
|
|
84
|
+
checkResults.push(...result)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return checkResults
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function createFeature(gff3Feature: GFF3Feature): AnnotationFeatureSnapshot {
|
|
92
|
+
const [firstFeature] = gff3Feature
|
|
93
|
+
const {
|
|
94
|
+
attributes,
|
|
95
|
+
child_features: childFeatures,
|
|
96
|
+
end,
|
|
97
|
+
phase,
|
|
98
|
+
score,
|
|
99
|
+
seq_id: refName,
|
|
100
|
+
source,
|
|
101
|
+
start,
|
|
102
|
+
strand,
|
|
103
|
+
type,
|
|
104
|
+
} = firstFeature
|
|
105
|
+
if (!refName) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`feature does not have seq_id: ${JSON.stringify(firstFeature)}`,
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
if (!type) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`feature does not have type: ${JSON.stringify(firstFeature)}`,
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
if (start === null) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`feature does not have start: ${JSON.stringify(firstFeature)}`,
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
if (end === null) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`feature does not have end: ${JSON.stringify(firstFeature)}`,
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
const feature: AnnotationFeatureSnapshot = {
|
|
126
|
+
_id: nanoid(),
|
|
127
|
+
gffId: '',
|
|
128
|
+
refSeq: refName,
|
|
129
|
+
type,
|
|
130
|
+
start: start - 1,
|
|
131
|
+
end,
|
|
132
|
+
}
|
|
133
|
+
if (gff3Feature.length > 1) {
|
|
134
|
+
feature.discontinuousLocations = gff3Feature.map((f) => {
|
|
135
|
+
const { end: subEnd, phase: locationPhase, start: subStart } = f
|
|
136
|
+
if (subStart === null || subEnd === null) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`feature does not have start and/or end: ${JSON.stringify(f)}`,
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
let parsedPhase: 0 | 1 | 2 | undefined
|
|
142
|
+
if (locationPhase) {
|
|
143
|
+
switch (locationPhase) {
|
|
144
|
+
case '0': {
|
|
145
|
+
parsedPhase = 0
|
|
146
|
+
|
|
147
|
+
break
|
|
148
|
+
}
|
|
149
|
+
case '1': {
|
|
150
|
+
parsedPhase = 1
|
|
151
|
+
|
|
152
|
+
break
|
|
153
|
+
}
|
|
154
|
+
case '2': {
|
|
155
|
+
parsedPhase = 2
|
|
156
|
+
|
|
157
|
+
break
|
|
158
|
+
}
|
|
159
|
+
default: {
|
|
160
|
+
throw new Error(`Unknown phase: "${locationPhase}"`)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return { start: subStart - 1, end: subEnd, phase: parsedPhase }
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
if (strand) {
|
|
168
|
+
if (strand === '+') {
|
|
169
|
+
feature.strand = 1
|
|
170
|
+
} else if (strand === '-') {
|
|
171
|
+
feature.strand = -1
|
|
172
|
+
} else {
|
|
173
|
+
throw new Error(`Unknown strand: "${strand}"`)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (score !== null) {
|
|
177
|
+
feature.score = score
|
|
178
|
+
}
|
|
179
|
+
if (phase) {
|
|
180
|
+
switch (phase) {
|
|
181
|
+
case '0': {
|
|
182
|
+
feature.phase = 0
|
|
183
|
+
|
|
184
|
+
break
|
|
185
|
+
}
|
|
186
|
+
case '1': {
|
|
187
|
+
feature.phase = 1
|
|
188
|
+
|
|
189
|
+
break
|
|
190
|
+
}
|
|
191
|
+
case '2': {
|
|
192
|
+
feature.phase = 2
|
|
193
|
+
|
|
194
|
+
break
|
|
195
|
+
}
|
|
196
|
+
default: {
|
|
197
|
+
throw new Error(`Unknown phase: "${phase}"`)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (childFeatures?.length) {
|
|
203
|
+
const children: Record<string, AnnotationFeatureSnapshot> = {}
|
|
204
|
+
for (const childFeature of childFeatures) {
|
|
205
|
+
const child = createFeature(childFeature)
|
|
206
|
+
children[child._id] = child
|
|
207
|
+
// Add value to gffId
|
|
208
|
+
child.attributes?._id
|
|
209
|
+
? (child.gffId = child.attributes?._id.toString())
|
|
210
|
+
: (child.gffId = child._id)
|
|
211
|
+
}
|
|
212
|
+
feature.children = children
|
|
213
|
+
}
|
|
214
|
+
if (source ?? attributes) {
|
|
215
|
+
const attrs: Record<string, string[]> = {}
|
|
216
|
+
if (source) {
|
|
217
|
+
attrs.source = [source]
|
|
218
|
+
}
|
|
219
|
+
if (attributes) {
|
|
220
|
+
for (const [key, val] of Object.entries(attributes)) {
|
|
221
|
+
if (val) {
|
|
222
|
+
const newKey = key.toLowerCase()
|
|
223
|
+
if (newKey !== 'parent') {
|
|
224
|
+
// attrs[key.toLowerCase()] = val
|
|
225
|
+
switch (key) {
|
|
226
|
+
case 'ID': {
|
|
227
|
+
attrs._id = val
|
|
228
|
+
break
|
|
229
|
+
}
|
|
230
|
+
case 'Name': {
|
|
231
|
+
attrs.gff_name = val
|
|
232
|
+
break
|
|
233
|
+
}
|
|
234
|
+
case 'Alias': {
|
|
235
|
+
attrs.gff_alias = val
|
|
236
|
+
break
|
|
237
|
+
}
|
|
238
|
+
case 'Target': {
|
|
239
|
+
attrs.gff_target = val
|
|
240
|
+
break
|
|
241
|
+
}
|
|
242
|
+
case 'Gap': {
|
|
243
|
+
attrs.gff_gap = val
|
|
244
|
+
break
|
|
245
|
+
}
|
|
246
|
+
case 'Derives_from': {
|
|
247
|
+
attrs.gff_derives_from = val
|
|
248
|
+
break
|
|
249
|
+
}
|
|
250
|
+
case 'Note': {
|
|
251
|
+
attrs.gff_note = val
|
|
252
|
+
break
|
|
253
|
+
}
|
|
254
|
+
case 'Dbxref': {
|
|
255
|
+
attrs.gff_dbxref = val
|
|
256
|
+
break
|
|
257
|
+
}
|
|
258
|
+
case 'Ontology_term': {
|
|
259
|
+
const goTerms: string[] = []
|
|
260
|
+
const otherTerms: string[] = []
|
|
261
|
+
for (const v of val) {
|
|
262
|
+
if (v.startsWith('GO:')) {
|
|
263
|
+
goTerms.push(v)
|
|
264
|
+
} else {
|
|
265
|
+
otherTerms.push(v)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (goTerms.length > 0) {
|
|
269
|
+
attrs['Gene Ontology'] = goTerms
|
|
270
|
+
}
|
|
271
|
+
if (otherTerms.length > 0) {
|
|
272
|
+
attrs.gff_ontology_term = otherTerms
|
|
273
|
+
}
|
|
274
|
+
break
|
|
275
|
+
}
|
|
276
|
+
case 'Is_circular': {
|
|
277
|
+
attrs.gff_is_circular = val
|
|
278
|
+
break
|
|
279
|
+
}
|
|
280
|
+
default: {
|
|
281
|
+
attrs[key.toLowerCase()] = val
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
feature.attributes = attrs
|
|
289
|
+
}
|
|
290
|
+
return feature
|
|
291
|
+
}
|