@apollo-annotation/shared 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.
- package/dist/Changes/{DeleteFeatureChange.d.ts → AddAndDeleteFeatureChanges.d.ts} +26 -11
- package/dist/Changes/AddAndDeleteFeatureChanges.d.ts.map +1 -0
- package/dist/Changes/AddAndDeleteFeatureChanges.js +117 -0
- package/dist/Changes/AddAndDeleteFeatureChanges.js.map +1 -0
- package/dist/Changes/AddAssemblyAliasesChange.d.ts +1 -4
- package/dist/Changes/AddAssemblyAliasesChange.d.ts.map +1 -1
- package/dist/Changes/AddAssemblyAliasesChange.js +0 -27
- package/dist/Changes/AddAssemblyAliasesChange.js.map +1 -1
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.d.ts +2 -11
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.d.ts.map +1 -1
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js +2 -82
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js.map +1 -1
- package/dist/Changes/AddAssemblyFromExternalChange.d.ts +1 -9
- package/dist/Changes/AddAssemblyFromExternalChange.d.ts.map +1 -1
- package/dist/Changes/AddAssemblyFromExternalChange.js +0 -72
- package/dist/Changes/AddAssemblyFromExternalChange.js.map +1 -1
- package/dist/Changes/AddAssemblyFromFileChange.d.ts +2 -17
- package/dist/Changes/AddAssemblyFromFileChange.d.ts.map +1 -1
- package/dist/Changes/AddAssemblyFromFileChange.js +2 -119
- package/dist/Changes/AddAssemblyFromFileChange.js.map +1 -1
- package/dist/Changes/AddFeaturesFromFileChange.d.ts +2 -11
- package/dist/Changes/AddFeaturesFromFileChange.d.ts.map +1 -1
- package/dist/Changes/AddFeaturesFromFileChange.js +2 -66
- package/dist/Changes/AddFeaturesFromFileChange.js.map +1 -1
- package/dist/Changes/AddRefSeqAliasesChange.d.ts +1 -4
- package/dist/Changes/AddRefSeqAliasesChange.d.ts.map +1 -1
- package/dist/Changes/AddRefSeqAliasesChange.js +0 -34
- package/dist/Changes/AddRefSeqAliasesChange.js.map +1 -1
- package/dist/Changes/DeleteAssemblyChange.d.ts +1 -9
- package/dist/Changes/DeleteAssemblyChange.d.ts.map +1 -1
- package/dist/Changes/DeleteAssemblyChange.js +0 -53
- package/dist/Changes/DeleteAssemblyChange.js.map +1 -1
- package/dist/Changes/DeleteUserChange.d.ts +1 -4
- package/dist/Changes/DeleteUserChange.d.ts.map +1 -1
- package/dist/Changes/DeleteUserChange.js +0 -19
- package/dist/Changes/DeleteUserChange.js.map +1 -1
- package/dist/Changes/FeatureAttributeChange.d.ts +1 -9
- package/dist/Changes/FeatureAttributeChange.d.ts.map +1 -1
- package/dist/Changes/FeatureAttributeChange.js +0 -82
- package/dist/Changes/FeatureAttributeChange.js.map +1 -1
- package/dist/Changes/ImportJBrowseConfigChange.d.ts +1 -4
- package/dist/Changes/ImportJBrowseConfigChange.d.ts.map +1 -1
- package/dist/Changes/ImportJBrowseConfigChange.js +1 -18
- package/dist/Changes/ImportJBrowseConfigChange.js.map +1 -1
- package/dist/Changes/LocationEndChange.d.ts +1 -9
- package/dist/Changes/LocationEndChange.d.ts.map +1 -1
- package/dist/Changes/LocationEndChange.js +0 -90
- package/dist/Changes/LocationEndChange.js.map +1 -1
- package/dist/Changes/LocationStartChange.d.ts +1 -9
- package/dist/Changes/LocationStartChange.d.ts.map +1 -1
- package/dist/Changes/LocationStartChange.js +0 -90
- package/dist/Changes/LocationStartChange.js.map +1 -1
- package/dist/Changes/MergeAndUndoMergeExonsChanges.d.ts +46 -0
- package/dist/Changes/MergeAndUndoMergeExonsChanges.d.ts.map +1 -0
- package/dist/Changes/MergeAndUndoMergeExonsChanges.js +83 -0
- package/dist/Changes/MergeAndUndoMergeExonsChanges.js.map +1 -0
- package/dist/Changes/{MergeTranscriptsChange.d.ts → MergeAndUndoMergeTranscriptsChanges.d.ts} +22 -6
- package/dist/Changes/MergeAndUndoMergeTranscriptsChanges.d.ts.map +1 -0
- package/dist/Changes/{MergeTranscriptsChange.js → MergeAndUndoMergeTranscriptsChanges.js} +40 -50
- package/dist/Changes/MergeAndUndoMergeTranscriptsChanges.js.map +1 -0
- package/dist/Changes/SplitAndUndoSplitExonChanges.d.ts +55 -0
- package/dist/Changes/SplitAndUndoSplitExonChanges.d.ts.map +1 -0
- package/dist/Changes/SplitAndUndoSplitExonChanges.js +115 -0
- package/dist/Changes/SplitAndUndoSplitExonChanges.js.map +1 -0
- package/dist/Changes/StrandChange.d.ts +1 -9
- package/dist/Changes/StrandChange.d.ts.map +1 -1
- package/dist/Changes/StrandChange.js +0 -77
- package/dist/Changes/StrandChange.js.map +1 -1
- package/dist/Changes/TypeChange.d.ts +1 -9
- package/dist/Changes/TypeChange.d.ts.map +1 -1
- package/dist/Changes/TypeChange.js +0 -77
- package/dist/Changes/TypeChange.js.map +1 -1
- package/dist/Changes/UserChange.d.ts +1 -4
- package/dist/Changes/UserChange.d.ts.map +1 -1
- package/dist/Changes/UserChange.js +0 -23
- package/dist/Changes/UserChange.js.map +1 -1
- package/dist/Changes/index.d.ts +29 -22
- package/dist/Changes/index.d.ts.map +1 -1
- package/dist/Changes/index.js +19 -24
- package/dist/Changes/index.js.map +1 -1
- package/dist/Validations/Validation.d.ts +2 -2
- package/dist/Validations/Validation.d.ts.map +1 -1
- package/dist/Validations/Validation.js +1 -1
- package/dist/Validations/Validation.js.map +1 -1
- package/dist/Validations/ValidationSet.d.ts +2 -2
- package/dist/Validations/ValidationSet.d.ts.map +1 -1
- package/dist/Validations/ValidationSet.js +2 -2
- package/dist/Validations/ValidationSet.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -4
- package/src/Changes/{DeleteFeatureChange.ts → AddAndDeleteFeatureChanges.ts} +77 -107
- package/src/Changes/AddAssemblyAliasesChange.ts +0 -35
- package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +5 -108
- package/src/Changes/AddAssemblyFromExternalChange.ts +0 -87
- package/src/Changes/AddAssemblyFromFileChange.ts +5 -169
- package/src/Changes/AddFeaturesFromFileChange.ts +5 -86
- package/src/Changes/AddRefSeqAliasesChange.ts +0 -44
- package/src/Changes/DeleteAssemblyChange.ts +0 -72
- package/src/Changes/DeleteUserChange.ts +0 -25
- package/src/Changes/FeatureAttributeChange.ts +0 -104
- package/src/Changes/ImportJBrowseConfigChange.ts +1 -27
- package/src/Changes/LocationEndChange.ts +0 -100
- package/src/Changes/LocationStartChange.ts +0 -100
- package/src/Changes/{MergeExonsChange.ts → MergeAndUndoMergeExonsChanges.ts} +70 -90
- package/src/Changes/{MergeTranscriptsChange.ts → MergeAndUndoMergeTranscriptsChanges.ts} +74 -66
- package/src/Changes/{SplitExonChange.ts → SplitAndUndoSplitExonChanges.ts} +95 -122
- package/src/Changes/StrandChange.ts +0 -94
- package/src/Changes/TypeChange.ts +0 -94
- package/src/Changes/UserChange.ts +0 -30
- package/src/Changes/index.ts +32 -24
- package/src/Validations/Validation.ts +2 -5
- package/src/Validations/ValidationSet.ts +3 -6
- package/src/index.ts +0 -1
- package/dist/Changes/AddFeatureChange.d.ts +0 -37
- package/dist/Changes/AddFeatureChange.d.ts.map +0 -1
- package/dist/Changes/AddFeatureChange.js +0 -169
- package/dist/Changes/AddFeatureChange.js.map +0 -1
- package/dist/Changes/DeleteFeatureChange.d.ts.map +0 -1
- package/dist/Changes/DeleteFeatureChange.js +0 -161
- package/dist/Changes/DeleteFeatureChange.js.map +0 -1
- package/dist/Changes/FromFileBaseChange.d.ts +0 -12
- package/dist/Changes/FromFileBaseChange.d.ts.map +0 -1
- package/dist/Changes/FromFileBaseChange.js +0 -196
- package/dist/Changes/FromFileBaseChange.js.map +0 -1
- package/dist/Changes/MergeExonsChange.d.ts +0 -30
- package/dist/Changes/MergeExonsChange.d.ts.map +0 -1
- package/dist/Changes/MergeExonsChange.js +0 -110
- package/dist/Changes/MergeExonsChange.js.map +0 -1
- package/dist/Changes/MergeTranscriptsChange.d.ts.map +0 -1
- package/dist/Changes/MergeTranscriptsChange.js.map +0 -1
- package/dist/Changes/SplitExonChange.d.ts +0 -34
- package/dist/Changes/SplitExonChange.d.ts.map +0 -1
- package/dist/Changes/SplitExonChange.js +0 -138
- package/dist/Changes/SplitExonChange.js.map +0 -1
- package/dist/Changes/UndoMergeExonsChange.d.ts +0 -28
- package/dist/Changes/UndoMergeExonsChange.d.ts.map +0 -1
- package/dist/Changes/UndoMergeExonsChange.js +0 -100
- package/dist/Changes/UndoMergeExonsChange.js.map +0 -1
- package/dist/Changes/UndoMergeTranscriptsChange.d.ts +0 -28
- package/dist/Changes/UndoMergeTranscriptsChange.d.ts.map +0 -1
- package/dist/Changes/UndoMergeTranscriptsChange.js +0 -100
- package/dist/Changes/UndoMergeTranscriptsChange.js.map +0 -1
- package/dist/Changes/UndoSplitExonChange.d.ts +0 -33
- package/dist/Changes/UndoSplitExonChange.d.ts.map +0 -1
- package/dist/Changes/UndoSplitExonChange.js +0 -107
- package/dist/Changes/UndoSplitExonChange.js.map +0 -1
- package/dist/Operations/GetAssembliesOperation.d.ts +0 -12
- package/dist/Operations/GetAssembliesOperation.d.ts.map +0 -1
- package/dist/Operations/GetAssembliesOperation.js +0 -16
- package/dist/Operations/GetAssembliesOperation.js.map +0 -1
- package/dist/Operations/GetFeaturesOperation.d.ts +0 -27
- package/dist/Operations/GetFeaturesOperation.d.ts.map +0 -1
- package/dist/Operations/GetFeaturesOperation.js +0 -38
- package/dist/Operations/GetFeaturesOperation.js.map +0 -1
- package/dist/Operations/index.d.ts +0 -9
- package/dist/Operations/index.d.ts.map +0 -1
- package/dist/Operations/index.js +0 -6
- package/dist/Operations/index.js.map +0 -1
- package/src/Changes/AddFeatureChange.ts +0 -236
- package/src/Changes/FromFileBaseChange.ts +0 -231
- package/src/Changes/UndoMergeExonsChange.ts +0 -149
- package/src/Changes/UndoMergeTranscriptsChange.ts +0 -153
- package/src/Changes/UndoSplitExonChange.ts +0 -174
- package/src/Operations/GetAssembliesOperation.ts +0 -28
- package/src/Operations/GetFeaturesOperation.ts +0 -58
- package/src/Operations/index.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo-annotation/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/GMOD/Apollo3.git",
|
|
7
|
+
"directory": "packages/apollo-shared"
|
|
8
|
+
},
|
|
4
9
|
"sideEffects": false,
|
|
5
10
|
"type": "module",
|
|
6
11
|
"exports": "./dist/index.js",
|
|
@@ -12,9 +17,9 @@
|
|
|
12
17
|
"test:ci": "NODE_V8_COVERAGE=./coverage glob -c \"tsx --test --test-reporter spec --experimental-test-coverage \" \"**/*.test.ts\""
|
|
13
18
|
},
|
|
14
19
|
"dependencies": {
|
|
15
|
-
"@apollo-annotation/common": "^0.
|
|
16
|
-
"@apollo-annotation/mst": "^0.
|
|
17
|
-
"@apollo-annotation/schemas": "^0.
|
|
20
|
+
"@apollo-annotation/common": "^1.0.0",
|
|
21
|
+
"@apollo-annotation/mst": "^1.0.0",
|
|
22
|
+
"@apollo-annotation/schemas": "^1.0.0",
|
|
18
23
|
"@gmod/gff": "^2.1.0",
|
|
19
24
|
"@gmod/indexedfasta": "^5.0.2",
|
|
20
25
|
"@jbrowse/core": "^4.1.1",
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
2
|
-
/* eslint-disable @typescript-eslint/require-await */
|
|
3
2
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
4
3
|
import {
|
|
5
4
|
type ChangeOptions,
|
|
6
|
-
type ClientDataStore,
|
|
7
5
|
FeatureChange,
|
|
8
|
-
type LocalGFF3DataStore,
|
|
9
6
|
type SerializedFeatureChange,
|
|
10
|
-
type ServerDataStore,
|
|
11
7
|
} from '@apollo-annotation/common'
|
|
12
8
|
import type { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
|
|
13
9
|
import type { Feature } from '@apollo-annotation/schemas'
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
interface SerializedAddFeatureChangeBase extends SerializedFeatureChange {
|
|
12
|
+
typeName: 'AddFeatureChange'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AddFeatureChangeDetails {
|
|
16
|
+
addedFeature: AnnotationFeatureSnapshot
|
|
17
|
+
parentFeatureId?: string // Parent feature to where feature will be added
|
|
18
|
+
copyFeature?: boolean // Are we copying or adding a new child feature
|
|
19
|
+
allIds?: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface SerializedAddFeatureChangeSingle
|
|
23
|
+
extends SerializedAddFeatureChangeBase,
|
|
24
|
+
AddFeatureChangeDetails {}
|
|
25
|
+
|
|
26
|
+
interface SerializedAddFeatureChangeMultiple
|
|
27
|
+
extends SerializedAddFeatureChangeBase {
|
|
28
|
+
changes: AddFeatureChangeDetails[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type SerializedAddFeatureChange =
|
|
32
|
+
| SerializedAddFeatureChangeSingle
|
|
33
|
+
| SerializedAddFeatureChangeMultiple
|
|
16
34
|
|
|
17
35
|
interface SerializedDeleteFeatureChangeBase extends SerializedFeatureChange {
|
|
18
36
|
typeName: 'DeleteFeatureChange'
|
|
@@ -36,130 +54,82 @@ export type SerializedDeleteFeatureChange =
|
|
|
36
54
|
| SerializedDeleteFeatureChangeSingle
|
|
37
55
|
| SerializedDeleteFeatureChangeMultiple
|
|
38
56
|
|
|
39
|
-
export class
|
|
40
|
-
typeName = '
|
|
41
|
-
changes:
|
|
57
|
+
export class AddFeatureChange extends FeatureChange {
|
|
58
|
+
typeName = 'AddFeatureChange' as const
|
|
59
|
+
changes: AddFeatureChangeDetails[]
|
|
42
60
|
|
|
43
|
-
constructor(json:
|
|
61
|
+
constructor(json: SerializedAddFeatureChange, options?: ChangeOptions) {
|
|
44
62
|
super(json, options)
|
|
45
63
|
this.changes = 'changes' in json ? json.changes : [json]
|
|
46
64
|
}
|
|
47
65
|
// eslint-disable-next-line @typescript-eslint/class-literal-property-style
|
|
48
66
|
get notification() {
|
|
49
|
-
return 'Feature
|
|
67
|
+
return 'Feature added successfully'
|
|
50
68
|
}
|
|
51
69
|
|
|
52
|
-
toJSON():
|
|
70
|
+
toJSON(): SerializedAddFeatureChange {
|
|
53
71
|
const { assembly, changedIds, changes, typeName } = this
|
|
54
72
|
if (changes.length === 1) {
|
|
55
|
-
const [{
|
|
56
|
-
return {
|
|
73
|
+
const [{ addedFeature, allIds, copyFeature, parentFeatureId }] = changes
|
|
74
|
+
return {
|
|
75
|
+
typeName,
|
|
76
|
+
changedIds,
|
|
77
|
+
assembly,
|
|
78
|
+
addedFeature,
|
|
79
|
+
parentFeatureId,
|
|
80
|
+
copyFeature,
|
|
81
|
+
allIds,
|
|
82
|
+
}
|
|
57
83
|
}
|
|
58
84
|
return { typeName, changedIds, assembly, changes }
|
|
59
85
|
}
|
|
60
86
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const { changes, logger } = this
|
|
69
|
-
|
|
70
|
-
const { INDEXED_IDS } = process.env
|
|
71
|
-
let idsToIndex: string[] | undefined
|
|
72
|
-
if (INDEXED_IDS) {
|
|
73
|
-
idsToIndex = INDEXED_IDS.split(',')
|
|
74
|
-
}
|
|
87
|
+
getInverse() {
|
|
88
|
+
const { assembly, changedIds, changes, logger } = this
|
|
89
|
+
const inverseChangedIds = [...changedIds].reverse()
|
|
90
|
+
const inverseChanges = [...changes].reverse().map((addFeatureChange) => ({
|
|
91
|
+
deletedFeature: addFeatureChange.addedFeature,
|
|
92
|
+
parentFeatureId: addFeatureChange.parentFeatureId,
|
|
93
|
+
}))
|
|
75
94
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
logger.error(errMsg)
|
|
88
|
-
throw new Error(errMsg)
|
|
89
|
-
}
|
|
95
|
+
return new DeleteFeatureChange(
|
|
96
|
+
{
|
|
97
|
+
changedIds: inverseChangedIds,
|
|
98
|
+
typeName: 'DeleteFeatureChange',
|
|
99
|
+
changes: inverseChanges,
|
|
100
|
+
assembly,
|
|
101
|
+
},
|
|
102
|
+
{ logger },
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
90
106
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
await featureModel.findByIdAndDelete(featureDoc._id)
|
|
99
|
-
logger.debug?.(
|
|
100
|
-
`Feature "${deletedFeature._id}" deleted from document "${featureDoc._id}". Whole document deleted.`,
|
|
101
|
-
)
|
|
102
|
-
continue
|
|
103
|
-
}
|
|
107
|
+
export function isAddFeatureChange(
|
|
108
|
+
change: unknown,
|
|
109
|
+
): change is AddFeatureChange {
|
|
110
|
+
return (change as AddFeatureChange).typeName === 'AddFeatureChange'
|
|
111
|
+
}
|
|
104
112
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this,
|
|
109
|
-
)
|
|
110
|
-
deletedIds.push(deletedFeature._id)
|
|
111
|
-
featureDoc.allIds = featureDoc.allIds.filter(
|
|
112
|
-
(id) => !deletedIds.includes(id),
|
|
113
|
-
)
|
|
114
|
-
const indexedIds = this.getIndexedIds(featureDoc, idsToIndex)
|
|
115
|
-
if (featureDoc.indexedIds) {
|
|
116
|
-
if (indexedIds.length > 0) {
|
|
117
|
-
featureDoc.indexedIds = indexedIds
|
|
118
|
-
} else {
|
|
119
|
-
delete featureDoc.indexedIds
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
if (indexedIds.length > 0) {
|
|
123
|
-
featureDoc.indexedIds = indexedIds
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// Save updated document in Mongo
|
|
127
|
-
featureDoc.markModified('children') // Mark as modified. Without this save() -method is not updating data in database
|
|
128
|
-
try {
|
|
129
|
-
await featureDoc.save()
|
|
130
|
-
} catch (error) {
|
|
131
|
-
logger.debug?.(`*** FAILED: ${error}`)
|
|
132
|
-
throw error
|
|
133
|
-
}
|
|
113
|
+
export class DeleteFeatureChange extends FeatureChange {
|
|
114
|
+
typeName = 'DeleteFeatureChange' as const
|
|
115
|
+
changes: DeleteFeatureChangeDetails[]
|
|
134
116
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
117
|
+
constructor(json: SerializedDeleteFeatureChange, options?: ChangeOptions) {
|
|
118
|
+
super(json, options)
|
|
119
|
+
this.changes = 'changes' in json ? json.changes : [json]
|
|
139
120
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/class-literal-property-style
|
|
122
|
+
get notification() {
|
|
123
|
+
return 'Feature deleted successfully'
|
|
143
124
|
}
|
|
144
125
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const { deletedFeature, parentFeatureId } = change
|
|
151
|
-
if (parentFeatureId) {
|
|
152
|
-
const parentFeature = dataStore.getFeature(parentFeatureId)
|
|
153
|
-
if (!parentFeature) {
|
|
154
|
-
throw new Error(`Could not find parent feature "${parentFeatureId}"`)
|
|
155
|
-
}
|
|
156
|
-
parentFeature.deleteChild(deletedFeature._id)
|
|
157
|
-
} else {
|
|
158
|
-
if (dataStore.getFeature(deletedFeature._id)) {
|
|
159
|
-
dataStore.deleteFeature(deletedFeature._id)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
126
|
+
toJSON(): SerializedDeleteFeatureChange {
|
|
127
|
+
const { assembly, changedIds, changes, typeName } = this
|
|
128
|
+
if (changes.length === 1) {
|
|
129
|
+
const [{ deletedFeature, parentFeatureId }] = changes
|
|
130
|
+
return { typeName, changedIds, assembly, deletedFeature, parentFeatureId }
|
|
162
131
|
}
|
|
132
|
+
return { typeName, changedIds, assembly, changes }
|
|
163
133
|
}
|
|
164
134
|
|
|
165
135
|
getInverse() {
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
1
|
import {
|
|
5
2
|
AssemblySpecificChange,
|
|
6
3
|
type Change,
|
|
7
4
|
type ChangeOptions,
|
|
8
|
-
type ClientDataStore,
|
|
9
|
-
type LocalGFF3DataStore,
|
|
10
5
|
type SerializedAssemblySpecificChange,
|
|
11
|
-
type ServerDataStore,
|
|
12
6
|
} from '@apollo-annotation/common'
|
|
13
|
-
import { getSession } from '@jbrowse/core/util'
|
|
14
7
|
|
|
15
8
|
export interface SerializedAssemblyAliasesChange
|
|
16
9
|
extends SerializedAssemblySpecificChange {
|
|
@@ -27,16 +20,6 @@ export class AddAssemblyAliasesChange extends AssemblySpecificChange {
|
|
|
27
20
|
this.aliases = json.aliases
|
|
28
21
|
}
|
|
29
22
|
|
|
30
|
-
executeOnClient(clientDataStore: ClientDataStore) {
|
|
31
|
-
const { assemblyManager } = getSession(clientDataStore)
|
|
32
|
-
const assembly = assemblyManager.get(this.assembly)
|
|
33
|
-
if (!assembly) {
|
|
34
|
-
throw new Error(`assembly ${this.assembly} not found`)
|
|
35
|
-
}
|
|
36
|
-
assembly.configuration.aliases.set(this.aliases)
|
|
37
|
-
return Promise.resolve()
|
|
38
|
-
}
|
|
39
|
-
|
|
40
23
|
getInverse(): Change {
|
|
41
24
|
throw new Error('Method not implemented.')
|
|
42
25
|
}
|
|
@@ -46,24 +29,6 @@ export class AddAssemblyAliasesChange extends AssemblySpecificChange {
|
|
|
46
29
|
return { assembly, typeName, aliases }
|
|
47
30
|
}
|
|
48
31
|
|
|
49
|
-
async executeOnServer(backend: ServerDataStore) {
|
|
50
|
-
const { assemblyModel } = backend
|
|
51
|
-
const { assembly, logger, aliases } = this
|
|
52
|
-
logger.debug?.(
|
|
53
|
-
`Updating assembly aliases for assembly: ${assembly}, aliases: ${JSON.stringify(aliases)}`,
|
|
54
|
-
)
|
|
55
|
-
const asm = await assemblyModel.findById(assembly)
|
|
56
|
-
if (!asm) {
|
|
57
|
-
throw new Error(`Assembly with ID ${assembly} not found`)
|
|
58
|
-
}
|
|
59
|
-
asm.aliases = aliases
|
|
60
|
-
await asm.save()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
executeOnLocalGFF3(_backend: LocalGFF3DataStore): Promise<unknown> {
|
|
64
|
-
throw new Error('Method not implemented.')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
32
|
// eslint-disable-next-line @typescript-eslint/class-literal-property-style
|
|
68
33
|
get notification(): string {
|
|
69
34
|
return 'Assembly aliases have been added.'
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/* eslint-disable @typescript-eslint/require-await */
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
ChangeOptions,
|
|
9
|
-
ClientDataStore,
|
|
10
|
-
LocalGFF3DataStore,
|
|
11
|
-
SerializedAssemblySpecificChange,
|
|
12
|
-
ServerDataStore,
|
|
1
|
+
import {
|
|
2
|
+
AssemblySpecificChange,
|
|
3
|
+
type ChangeOptions,
|
|
4
|
+
type SerializedAssemblySpecificChange,
|
|
13
5
|
} from '@apollo-annotation/common'
|
|
14
6
|
|
|
15
|
-
import { FromFileBaseChange } from './FromFileBaseChange.js'
|
|
16
|
-
|
|
17
7
|
export interface SerializedAddAssemblyAndFeaturesFromFileChangeBase
|
|
18
8
|
extends SerializedAssemblySpecificChange {
|
|
19
9
|
typeName: 'AddAssemblyAndFeaturesFromFileChange'
|
|
@@ -38,7 +28,7 @@ export type SerializedAddAssemblyAndFeaturesFromFileChange =
|
|
|
38
28
|
| SerializedAddAssemblyAndFeaturesFromFileChangeSingle
|
|
39
29
|
| SerializedAddAssemblyAndFeaturesFromFileChangeMultiple
|
|
40
30
|
|
|
41
|
-
export class AddAssemblyAndFeaturesFromFileChange extends
|
|
31
|
+
export class AddAssemblyAndFeaturesFromFileChange extends AssemblySpecificChange {
|
|
42
32
|
typeName = 'AddAssemblyAndFeaturesFromFileChange' as const
|
|
43
33
|
changes: AddAssemblyAndFeaturesFromFileChangeDetails[]
|
|
44
34
|
|
|
@@ -63,99 +53,6 @@ export class AddAssemblyAndFeaturesFromFileChange extends FromFileBaseChange {
|
|
|
63
53
|
return { typeName, assembly, changes }
|
|
64
54
|
}
|
|
65
55
|
|
|
66
|
-
/**
|
|
67
|
-
* Applies the required change to database
|
|
68
|
-
* @param backend - parameters from backend
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
71
|
-
async executeOnServer(backend: ServerDataStore) {
|
|
72
|
-
const { assemblyModel, checkModel, fileModel, filesService, user } = backend
|
|
73
|
-
const { assembly, changes, logger } = this
|
|
74
|
-
for (const change of changes) {
|
|
75
|
-
const { assemblyName, fileIds, parseOptions } = change
|
|
76
|
-
const fileId = fileIds.fa
|
|
77
|
-
|
|
78
|
-
const { FILE_UPLOAD_FOLDER } = process.env
|
|
79
|
-
if (!FILE_UPLOAD_FOLDER) {
|
|
80
|
-
throw new Error('No FILE_UPLOAD_FOLDER found in .env file')
|
|
81
|
-
}
|
|
82
|
-
// Get file checksum
|
|
83
|
-
const fileDoc = await fileModel.findById(fileId).exec()
|
|
84
|
-
if (!fileDoc) {
|
|
85
|
-
throw new Error(`File "${fileId}" not found in Mongo`)
|
|
86
|
-
}
|
|
87
|
-
logger.debug?.(`FileId "${fileId}", checksum "${fileDoc.checksum}"`)
|
|
88
|
-
|
|
89
|
-
// Check and add new assembly
|
|
90
|
-
const assemblyDoc = await assemblyModel
|
|
91
|
-
.findOne({ name: assemblyName })
|
|
92
|
-
.exec()
|
|
93
|
-
if (assemblyDoc) {
|
|
94
|
-
throw new Error(`Assembly "${assemblyName}" already exists`)
|
|
95
|
-
}
|
|
96
|
-
// get checks
|
|
97
|
-
const checkDocs = await checkModel.find({ isDefault: true }).exec()
|
|
98
|
-
|
|
99
|
-
const checks = checkDocs.map((checkDoc) => checkDoc._id.toHexString())
|
|
100
|
-
// Add assembly
|
|
101
|
-
const [newAssemblyDoc] = await assemblyModel.create([
|
|
102
|
-
{ _id: assembly, name: assemblyName, user, status: -1, fileId, checks },
|
|
103
|
-
])
|
|
104
|
-
logger.debug?.(
|
|
105
|
-
`Added new assembly "${assemblyName}", docId "${newAssemblyDoc._id.toHexString()}"`,
|
|
106
|
-
)
|
|
107
|
-
logger.debug?.(`File type: "${fileDoc.type}"`)
|
|
108
|
-
|
|
109
|
-
// Add refSeqs
|
|
110
|
-
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
111
|
-
await this.addRefSeqIntoDb(
|
|
112
|
-
fileDoc,
|
|
113
|
-
newAssemblyDoc._id.toString(),
|
|
114
|
-
backend,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
const { bufferSize = 10_000, strict = true } = parseOptions ?? {}
|
|
118
|
-
const featureStream = filesService.parseGFF3(
|
|
119
|
-
filesService.getFileStream(fileDoc),
|
|
120
|
-
{ bufferSize },
|
|
121
|
-
)
|
|
122
|
-
let featureCount = 0
|
|
123
|
-
let errorCount = 0
|
|
124
|
-
for await (const gff3Feature of featureStream) {
|
|
125
|
-
// Add new feature into database
|
|
126
|
-
try {
|
|
127
|
-
await this.addFeatureIntoDb(gff3Feature, backend)
|
|
128
|
-
} catch (error) {
|
|
129
|
-
// if the first feature is an error, assume the file isn't valid and throw
|
|
130
|
-
if (strict || featureCount === 0) {
|
|
131
|
-
throw error
|
|
132
|
-
}
|
|
133
|
-
if (errorCount <= 99) {
|
|
134
|
-
logger.warn('Error parsing feature')
|
|
135
|
-
logger.warn(error)
|
|
136
|
-
if (errorCount === 99) {
|
|
137
|
-
logger.warn(
|
|
138
|
-
'Reached 100 parsing errors, omitting further warnings from log',
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
errorCount++
|
|
143
|
-
}
|
|
144
|
-
featureCount++
|
|
145
|
-
if (featureCount % 1000 === 0) {
|
|
146
|
-
logger.debug?.(`Processed ${featureCount} features`)
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async executeOnLocalGFF3(_backend: LocalGFF3DataStore) {
|
|
153
|
-
throw new Error('executeOnLocalGFF3 not implemented')
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
157
|
-
async executeOnClient(_dataStore: ClientDataStore) {}
|
|
158
|
-
|
|
159
56
|
getInverse() {
|
|
160
57
|
const { assembly, changes, logger, typeName } = this
|
|
161
58
|
return new AddAssemblyAndFeaturesFromFileChange(
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
4
|
-
|
|
5
|
-
/* eslint-disable @typescript-eslint/require-await */
|
|
6
1
|
import {
|
|
7
2
|
AssemblySpecificChange,
|
|
8
3
|
type ChangeOptions,
|
|
9
|
-
type ClientDataStore,
|
|
10
|
-
type LocalGFF3DataStore,
|
|
11
4
|
type SerializedAssemblySpecificChange,
|
|
12
|
-
type ServerDataStore,
|
|
13
5
|
} from '@apollo-annotation/common'
|
|
14
|
-
import { BgzipIndexedFasta, IndexedFasta } from '@gmod/indexedfasta'
|
|
15
|
-
import { RemoteFile } from 'generic-filehandle2'
|
|
16
6
|
|
|
17
7
|
export interface SerializedAddAssemblyFromExternalChangeBase
|
|
18
8
|
extends SerializedAssemblySpecificChange {
|
|
@@ -62,83 +52,6 @@ export class AddAssemblyFromExternalChange extends AssemblySpecificChange {
|
|
|
62
52
|
return { typeName, assembly, changes }
|
|
63
53
|
}
|
|
64
54
|
|
|
65
|
-
/**
|
|
66
|
-
* Applies the required change to database
|
|
67
|
-
* @param backend - parameters from backend
|
|
68
|
-
* @returns
|
|
69
|
-
*/
|
|
70
|
-
async executeOnServer(backend: ServerDataStore) {
|
|
71
|
-
const { assemblyModel, checkModel, refSeqModel, user } = backend
|
|
72
|
-
const { assembly, changes, logger } = this
|
|
73
|
-
const { CHUNK_SIZE } = process.env
|
|
74
|
-
const customChunkSize = CHUNK_SIZE && Number(CHUNK_SIZE)
|
|
75
|
-
|
|
76
|
-
for (const change of changes) {
|
|
77
|
-
const { assemblyName, externalLocation } = change
|
|
78
|
-
const { fa, fai, gzi } = externalLocation
|
|
79
|
-
const sequenceAdapter = gzi
|
|
80
|
-
? new BgzipIndexedFasta({
|
|
81
|
-
fasta: new RemoteFile(fa, { fetch }),
|
|
82
|
-
fai: new RemoteFile(fai, { fetch }),
|
|
83
|
-
gzi: new RemoteFile(gzi, { fetch }),
|
|
84
|
-
})
|
|
85
|
-
: new IndexedFasta({
|
|
86
|
-
fasta: new RemoteFile(fa, { fetch }),
|
|
87
|
-
fai: new RemoteFile(fai, { fetch }),
|
|
88
|
-
})
|
|
89
|
-
const allSequenceSizes = await sequenceAdapter.getSequenceSizes()
|
|
90
|
-
|
|
91
|
-
if (!allSequenceSizes) {
|
|
92
|
-
throw new Error('No data read from indexed fasta getSequenceSizes')
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const assemblyDoc = await assemblyModel
|
|
96
|
-
.findOne({ name: assemblyName })
|
|
97
|
-
.exec()
|
|
98
|
-
if (assemblyDoc) {
|
|
99
|
-
throw new Error(`Assembly "${assemblyName}" already exists`)
|
|
100
|
-
}
|
|
101
|
-
const checkDocs = await checkModel.find({ default: true }).exec()
|
|
102
|
-
const checks = checkDocs.map((checkDoc) => checkDoc._id.toHexString())
|
|
103
|
-
const [newAssemblyDoc] = await assemblyModel.create([
|
|
104
|
-
{
|
|
105
|
-
_id: assembly,
|
|
106
|
-
name: assemblyName,
|
|
107
|
-
user,
|
|
108
|
-
status: -1,
|
|
109
|
-
externalLocation,
|
|
110
|
-
checks,
|
|
111
|
-
},
|
|
112
|
-
])
|
|
113
|
-
logger.debug?.(
|
|
114
|
-
`Added new assembly "${assemblyName}", docId "${newAssemblyDoc._id}"`,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
for (const sequenceName in allSequenceSizes) {
|
|
118
|
-
const [newRefSeqDoc] = await refSeqModel.create([
|
|
119
|
-
{
|
|
120
|
-
name: sequenceName,
|
|
121
|
-
assembly: newAssemblyDoc._id,
|
|
122
|
-
length: allSequenceSizes[sequenceName],
|
|
123
|
-
...(customChunkSize ? { chunkSize: customChunkSize } : null),
|
|
124
|
-
user,
|
|
125
|
-
status: -1,
|
|
126
|
-
},
|
|
127
|
-
])
|
|
128
|
-
logger.debug?.(
|
|
129
|
-
`Added new refSeq "${sequenceName}", docId "${newRefSeqDoc._id}"`,
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async executeOnLocalGFF3(_backend: LocalGFF3DataStore) {
|
|
136
|
-
throw new Error('executeOnLocalGFF3 not implemented')
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
140
|
-
async executeOnClient(_dataStore: ClientDataStore) {}
|
|
141
|
-
|
|
142
55
|
getInverse() {
|
|
143
56
|
const { assembly, changes, logger, typeName } = this
|
|
144
57
|
return new AddAssemblyFromExternalChange(
|