@apollo-annotation/shared 0.1.19 → 0.1.21
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/AddAssemblyAndFeaturesFromFileChange.d.ts +33 -0
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js +86 -0
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js.map +1 -0
- package/dist/Changes/AddAssemblyFromExternalChange.d.ts +34 -0
- package/dist/Changes/AddAssemblyFromExternalChange.js +100 -0
- package/dist/Changes/AddAssemblyFromExternalChange.js.map +1 -0
- package/dist/Changes/AddAssemblyFromFileChange.d.ts +43 -0
- package/dist/Changes/AddAssemblyFromFileChange.js +146 -0
- package/dist/Changes/AddAssemblyFromFileChange.js.map +1 -0
- package/dist/Changes/AddFeatureChange.d.ts +35 -0
- package/dist/Changes/AddFeatureChange.js +169 -0
- package/dist/Changes/AddFeatureChange.js.map +1 -0
- package/dist/Changes/AddFeaturesFromFileChange.d.ts +32 -0
- package/dist/Changes/AddFeaturesFromFileChange.js +76 -0
- package/dist/Changes/AddFeaturesFromFileChange.js.map +1 -0
- package/dist/Changes/AddRefSeqAliasesChange.d.ts +20 -0
- package/dist/Changes/AddRefSeqAliasesChange.js +61 -0
- package/dist/Changes/AddRefSeqAliasesChange.js.map +1 -0
- package/dist/Changes/DeleteAssemblyChange.d.ts +18 -0
- package/dist/Changes/DeleteAssemblyChange.js +72 -0
- package/dist/Changes/DeleteAssemblyChange.js.map +1 -0
- package/dist/Changes/DeleteFeatureChange.d.ts +42 -0
- package/dist/Changes/DeleteFeatureChange.js +143 -0
- package/dist/Changes/DeleteFeatureChange.js.map +1 -0
- package/dist/Changes/DeleteUserChange.d.ts +25 -0
- package/dist/Changes/DeleteUserChange.js +53 -0
- package/dist/Changes/DeleteUserChange.js.map +1 -0
- package/dist/Changes/FeatureAttributeChange.d.ts +31 -0
- package/dist/Changes/FeatureAttributeChange.js +112 -0
- package/dist/Changes/FeatureAttributeChange.js.map +1 -0
- package/dist/Changes/FromFileBaseChange.d.ts +9 -0
- package/dist/Changes/FromFileBaseChange.js +187 -0
- package/dist/Changes/FromFileBaseChange.js.map +1 -0
- package/dist/Changes/ImportJBrowseConfigChange.d.ts +43 -0
- package/dist/Changes/ImportJBrowseConfigChange.js +67 -0
- package/dist/Changes/ImportJBrowseConfigChange.js.map +1 -0
- package/dist/Changes/LocationEndChange.d.ts +32 -0
- package/dist/Changes/LocationEndChange.js +129 -0
- package/dist/Changes/LocationEndChange.js.map +1 -0
- package/dist/Changes/LocationStartChange.d.ts +32 -0
- package/dist/Changes/LocationStartChange.js +129 -0
- package/dist/Changes/LocationStartChange.js.map +1 -0
- package/dist/Changes/StrandChange.d.ts +31 -0
- package/dist/Changes/StrandChange.js +114 -0
- package/dist/Changes/StrandChange.js.map +1 -0
- package/dist/Changes/TypeChange.d.ts +31 -0
- package/dist/Changes/TypeChange.js +114 -0
- package/dist/Changes/TypeChange.js.map +1 -0
- package/dist/Changes/UserChange.d.ts +25 -0
- package/dist/Changes/UserChange.js +51 -0
- package/dist/Changes/UserChange.js.map +1 -0
- package/dist/Changes/index.d.ts +50 -0
- package/dist/Changes/index.js +55 -0
- package/dist/Changes/index.js.map +1 -0
- package/dist/Checks/CDSCheck.d.ts +8 -0
- package/dist/Checks/CDSCheck.js +197 -0
- package/dist/Checks/CDSCheck.js.map +1 -0
- package/dist/Checks/index.d.ts +1 -0
- package/dist/Checks/index.js +5 -0
- package/dist/Checks/index.js.map +1 -0
- package/dist/Common/index.d.ts +1 -0
- package/dist/Common/index.js +5 -0
- package/dist/Common/index.js.map +1 -0
- package/dist/Common/jwtPayload.d.ts +12 -0
- package/dist/Common/jwtPayload.js +16 -0
- package/dist/Common/jwtPayload.js.map +1 -0
- package/dist/GFF3/gff3ToAnnotationFeature.d.ts +3 -0
- package/dist/GFF3/gff3ToAnnotationFeature.js +211 -0
- package/dist/GFF3/gff3ToAnnotationFeature.js.map +1 -0
- package/dist/GFF3/gff3ToAnnotationFeature.test.d.ts +1 -0
- package/dist/GFF3/gff3ToAnnotationFeature.test.js +174 -0
- package/dist/GFF3/gff3ToAnnotationFeature.test.js.map +1 -0
- package/dist/GFF3/gffReservedKeys.d.ts +5 -0
- package/dist/GFF3/gffReservedKeys.js +34 -0
- package/dist/GFF3/gffReservedKeys.js.map +1 -0
- package/dist/GFF3/index.d.ts +2 -0
- package/dist/GFF3/index.js +6 -0
- package/dist/GFF3/index.js.map +1 -0
- package/dist/Messages.d.ts +28 -0
- package/dist/Messages.js +3 -0
- package/dist/Messages.js.map +1 -0
- package/dist/Operations/GetAssembliesOperation.d.ts +13 -0
- package/dist/Operations/GetAssembliesOperation.js +20 -0
- package/dist/Operations/GetAssembliesOperation.js.map +1 -0
- package/dist/Operations/GetFeaturesOperation.d.ts +26 -0
- package/dist/Operations/GetFeaturesOperation.js +42 -0
- package/dist/Operations/GetFeaturesOperation.js.map +1 -0
- package/dist/Operations/index.d.ts +8 -0
- package/dist/Operations/index.js +10 -0
- package/dist/Operations/index.js.map +1 -0
- package/dist/Validations/CoreValidation.d.ts +17 -0
- package/dist/Validations/CoreValidation.js +36 -0
- package/dist/Validations/CoreValidation.js.map +1 -0
- package/dist/Validations/ParentChildValidation.d.ts +17 -0
- package/dist/Validations/ParentChildValidation.js +61 -0
- package/dist/Validations/ParentChildValidation.js.map +1 -0
- package/dist/Validations/Validation.d.ts +27 -0
- package/dist/Validations/Validation.js +27 -0
- package/dist/Validations/Validation.js.map +1 -0
- package/dist/Validations/ValidationSet.d.ts +24 -0
- package/dist/Validations/ValidationSet.js +86 -0
- package/dist/Validations/ValidationSet.js.map +1 -0
- package/dist/Validations/index.d.ts +4 -0
- package/dist/Validations/index.js +8 -0
- package/dist/Validations/index.js.map +1 -0
- package/dist/Validations/soSequenceTypes.d.ts +2 -0
- package/dist/Validations/soSequenceTypes.js +1868 -0
- package/dist/Validations/soSequenceTypes.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/util.d.ts +4 -0
- package/dist/util.js +102 -0
- package/dist/util.js.map +1 -0
- package/package.json +8 -5
- package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +10 -6
- package/src/Changes/AddAssemblyFromExternalChange.ts +4 -1
- package/src/Changes/AddAssemblyFromFileChange.ts +138 -41
- package/src/Changes/ImportJBrowseConfigChange.ts +2 -1
- package/src/Checks/CDSCheck.ts +202 -252
- package/src/GFF3/gff3ToAnnotationFeature.test.ts +165 -5
- package/src/GFF3/gff3ToAnnotationFeature.ts +16 -16
- package/src/util.ts +1 -0
- package/test_data/braker.gff +13 -0
- package/test_data/example01.gff3 +26 -0
- package/test_data/example01.json +236 -0
- package/test_data/example02.json +225 -0
- package/test_data/example04.json +225 -0
- package/test_data/example05.gff3 +30 -0
- package/test_data/example06.gff3 +30 -0
- package/test_data/example07.gff3 +30 -0
- package/test_data/gene_mrna.gff3 +4 -0
- package/test_data/gene_representations.gff3 +1781 -0
- package/test_data/one_cds.gff3 +9 -0
- package/test_data/one_cds.json +67 -0
- package/test_data/two_cds.gff3 +9 -0
- package/test_data/two_cds.json +67 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteFeatureChange = void 0;
|
|
4
|
+
exports.isDeleteFeatureChange = isDeleteFeatureChange;
|
|
5
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
6
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
8
|
+
const common_1 = require("@apollo-annotation/common");
|
|
9
|
+
const AddFeatureChange_1 = require("./AddFeatureChange");
|
|
10
|
+
class DeleteFeatureChange extends common_1.FeatureChange {
|
|
11
|
+
typeName = 'DeleteFeatureChange';
|
|
12
|
+
changes;
|
|
13
|
+
constructor(json, options) {
|
|
14
|
+
super(json, options);
|
|
15
|
+
this.changes = 'changes' in json ? json.changes : [json];
|
|
16
|
+
}
|
|
17
|
+
toJSON() {
|
|
18
|
+
const { assembly, changedIds, changes, typeName } = this;
|
|
19
|
+
if (changes.length === 1) {
|
|
20
|
+
const [{ deletedFeature, parentFeatureId }] = changes;
|
|
21
|
+
return { typeName, changedIds, assembly, deletedFeature, parentFeatureId };
|
|
22
|
+
}
|
|
23
|
+
return { typeName, changedIds, assembly, changes };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Applies the required change to database
|
|
27
|
+
* @param backend - parameters from backend
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
async executeOnServer(backend) {
|
|
31
|
+
const { featureModel, session } = backend;
|
|
32
|
+
const { changes, logger } = this;
|
|
33
|
+
// Loop the changes
|
|
34
|
+
for (const change of changes) {
|
|
35
|
+
const { deletedFeature, parentFeatureId } = change;
|
|
36
|
+
// Search feature
|
|
37
|
+
const featureDoc = await featureModel
|
|
38
|
+
.findOne({ allIds: deletedFeature._id })
|
|
39
|
+
.session(session)
|
|
40
|
+
.exec();
|
|
41
|
+
if (!featureDoc) {
|
|
42
|
+
const errMsg = `*** ERROR: The following featureId was not found in database ='${deletedFeature._id}'`;
|
|
43
|
+
logger.error(errMsg);
|
|
44
|
+
throw new Error(errMsg);
|
|
45
|
+
}
|
|
46
|
+
// Check if feature is on top level, then simply delete the whole document (i.e. not just sub-feature inside document)
|
|
47
|
+
if (featureDoc._id.equals(deletedFeature._id)) {
|
|
48
|
+
if (parentFeatureId) {
|
|
49
|
+
throw new Error(`Feature "${deletedFeature._id}" is top-level, but received a parent feature ID`);
|
|
50
|
+
}
|
|
51
|
+
await featureModel.findByIdAndDelete(featureDoc._id);
|
|
52
|
+
logger.debug?.(`Feature "${deletedFeature._id}" deleted from document "${featureDoc._id}". Whole document deleted.`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const deletedIds = this.findAndDeleteChildFeature(featureDoc, deletedFeature._id);
|
|
56
|
+
deletedIds.push(deletedFeature._id);
|
|
57
|
+
featureDoc.allIds = featureDoc.allIds.filter((id) => !deletedIds.includes(id));
|
|
58
|
+
// Save updated document in Mongo
|
|
59
|
+
featureDoc.markModified('children'); // Mark as modified. Without this save() -method is not updating data in database
|
|
60
|
+
try {
|
|
61
|
+
await featureDoc.save();
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
logger.debug?.(`*** FAILED: ${error}`);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
logger.debug?.(`Feature "${deletedFeature._id}" deleted from document "${featureDoc._id}"`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Delete feature's subfeatures that match an ID and return the IDs of any
|
|
72
|
+
* sub-subfeatures that were deleted
|
|
73
|
+
* @param feature -
|
|
74
|
+
* @param featureIdToDelete -
|
|
75
|
+
* @returns - list of deleted feature IDs
|
|
76
|
+
*/
|
|
77
|
+
findAndDeleteChildFeature(feature, featureIdToDelete) {
|
|
78
|
+
if (!feature.children) {
|
|
79
|
+
throw new Error(`Feature ${feature._id} has no children`);
|
|
80
|
+
}
|
|
81
|
+
const { _id, children } = feature;
|
|
82
|
+
const child = children.get(featureIdToDelete);
|
|
83
|
+
if (child) {
|
|
84
|
+
const deletedIds = this.getChildFeatureIds(child);
|
|
85
|
+
children.delete(featureIdToDelete);
|
|
86
|
+
return deletedIds;
|
|
87
|
+
}
|
|
88
|
+
for (const [, childFeature] of children) {
|
|
89
|
+
try {
|
|
90
|
+
return this.findAndDeleteChildFeature(childFeature, featureIdToDelete);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// pass
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`Feature "${featureIdToDelete}" not found in ${_id}`);
|
|
97
|
+
}
|
|
98
|
+
async executeOnLocalGFF3(_backend) {
|
|
99
|
+
throw new Error('executeOnLocalGFF3 not implemented');
|
|
100
|
+
}
|
|
101
|
+
async executeOnClient(dataStore) {
|
|
102
|
+
if (!dataStore) {
|
|
103
|
+
throw new Error('No data store');
|
|
104
|
+
}
|
|
105
|
+
for (const change of this.changes) {
|
|
106
|
+
const { deletedFeature, parentFeatureId } = change;
|
|
107
|
+
if (parentFeatureId) {
|
|
108
|
+
const parentFeature = dataStore.getFeature(parentFeatureId);
|
|
109
|
+
if (!parentFeature) {
|
|
110
|
+
throw new Error(`Could not find parent feature "${parentFeatureId}"`);
|
|
111
|
+
}
|
|
112
|
+
parentFeature.deleteChild(deletedFeature._id);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (dataStore.getFeature(deletedFeature._id)) {
|
|
116
|
+
dataStore.deleteFeature(deletedFeature._id);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
getInverse() {
|
|
122
|
+
const { assembly, changedIds, changes, logger } = this;
|
|
123
|
+
const inverseChangedIds = [...changedIds].reverse();
|
|
124
|
+
const inverseChanges = [...changes]
|
|
125
|
+
.reverse()
|
|
126
|
+
.map((deleteFeatuerChange) => ({
|
|
127
|
+
addedFeature: deleteFeatuerChange.deletedFeature,
|
|
128
|
+
parentFeatureId: deleteFeatuerChange.parentFeatureId,
|
|
129
|
+
}));
|
|
130
|
+
logger.debug?.(`INVERSE CHANGE '${JSON.stringify(inverseChanges)}'`);
|
|
131
|
+
return new AddFeatureChange_1.AddFeatureChange({
|
|
132
|
+
changedIds: inverseChangedIds,
|
|
133
|
+
typeName: 'AddFeatureChange',
|
|
134
|
+
changes: inverseChanges,
|
|
135
|
+
assembly,
|
|
136
|
+
}, { logger });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.DeleteFeatureChange = DeleteFeatureChange;
|
|
140
|
+
function isDeleteFeatureChange(change) {
|
|
141
|
+
return change.typeName === 'DeleteFeatureChange';
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=DeleteFeatureChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteFeatureChange.js","sourceRoot":"","sources":["../../src/Changes/DeleteFeatureChange.ts"],"names":[],"mappings":";;;AAmMA,sDAIC;AAvMD,qEAAqE;AACrE,qDAAqD;AACrD,gEAAgE;AAChE,sDAOkC;AAIlC,yDAAqD;AAwBrD,MAAa,mBAAoB,SAAQ,sBAAa;IACpD,QAAQ,GAAG,qBAA8B,CAAA;IACzC,OAAO,CAA8B;IAErC,YAAY,IAAmC,EAAE,OAAuB;QACtE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;QACxD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC,GAAG,OAAO,CAAA;YACrD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,CAAA;QAC5E,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAC,OAAwB;QAC5C,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QACzC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAEhC,mBAAmB;QACnB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,EAAE,cAAc,E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OAAO,IAAI,mCAAgB,CACzB;YACE,UAAU,EAAE,iBAAiB;YAC7B,QAAQ,EAAE,kBAAkB;YAC5B,OAAO,EAAE,cAAc;YACvB,QAAQ;SACT,EACD,EAAE,MAAM,EAAE,CACX,CAAA;IACH,CAAC;CACF;AA3JD,kDA2JC;AAED,SAAgB,qBAAqB,CACnC,MAAe;IAEf,OAAQ,MAA8B,CAAC,QAAQ,KAAK,qBAAqB,CAAA;AAC3E,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Change, ChangeOptions, ClientDataStore, LocalGFF3DataStore, SerializedChange, ServerDataStore } from '@apollo-annotation/common';
|
|
2
|
+
export interface SerializedDeleteUserChangeBase extends SerializedChange {
|
|
3
|
+
typeName: 'DeleteUserChange';
|
|
4
|
+
userId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DeleteUserChangeDetails {
|
|
7
|
+
}
|
|
8
|
+
interface SerializedDeleteUserChangeSingle extends SerializedDeleteUserChangeBase, DeleteUserChangeDetails {
|
|
9
|
+
}
|
|
10
|
+
interface SerializedDeleteUserChangeMultiple extends SerializedDeleteUserChangeBase {
|
|
11
|
+
changes: DeleteUserChangeDetails[];
|
|
12
|
+
}
|
|
13
|
+
export type SerializedDeleteUserChange = SerializedDeleteUserChangeSingle | SerializedDeleteUserChangeMultiple;
|
|
14
|
+
export declare class DeleteUserChange extends Change {
|
|
15
|
+
typeName: "DeleteUserChange";
|
|
16
|
+
changes: DeleteUserChangeDetails[];
|
|
17
|
+
userId: string;
|
|
18
|
+
constructor(json: SerializedDeleteUserChange, options?: ChangeOptions);
|
|
19
|
+
toJSON(): SerializedDeleteUserChange;
|
|
20
|
+
executeOnServer(backend: ServerDataStore): Promise<void>;
|
|
21
|
+
executeOnLocalGFF3(_backend: LocalGFF3DataStore): Promise<void>;
|
|
22
|
+
executeOnClient(_dataStore: ClientDataStore): Promise<void>;
|
|
23
|
+
getInverse(): DeleteUserChange;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteUserChange = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
5
|
+
const common_1 = require("@apollo-annotation/common");
|
|
6
|
+
class DeleteUserChange extends common_1.Change {
|
|
7
|
+
typeName = 'DeleteUserChange';
|
|
8
|
+
changes;
|
|
9
|
+
userId;
|
|
10
|
+
constructor(json, options) {
|
|
11
|
+
super(json, options);
|
|
12
|
+
this.changes = 'changes' in json ? json.changes : [json];
|
|
13
|
+
this.userId = json.userId;
|
|
14
|
+
}
|
|
15
|
+
toJSON() {
|
|
16
|
+
const { typeName, userId } = this;
|
|
17
|
+
return { typeName, userId };
|
|
18
|
+
}
|
|
19
|
+
async executeOnServer(backend) {
|
|
20
|
+
const { session, userModel } = backend;
|
|
21
|
+
const { logger, userId } = this;
|
|
22
|
+
const user = await userModel
|
|
23
|
+
.findOneAndDelete({ _id: userId })
|
|
24
|
+
.session(session)
|
|
25
|
+
.exec();
|
|
26
|
+
if (!user) {
|
|
27
|
+
const errMsg = `*** ERROR: User with id "${userId}" not found`;
|
|
28
|
+
logger.error(errMsg);
|
|
29
|
+
throw new Error(errMsg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async executeOnLocalGFF3(_backend) {
|
|
33
|
+
throw new Error('executeOnLocalGFF3 not implemented');
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
36
|
+
async executeOnClient(_dataStore) { }
|
|
37
|
+
getInverse() {
|
|
38
|
+
const { logger, typeName, userId } = this;
|
|
39
|
+
return new DeleteUserChange({ typeName, userId }, { logger });
|
|
40
|
+
// const inverseChangedIds = this.changedIds.slice().reverse()
|
|
41
|
+
// const inverseChanges = this.changes
|
|
42
|
+
// .slice()
|
|
43
|
+
// .reverse()
|
|
44
|
+
// .map((deleteUserChange) => ({
|
|
45
|
+
// addedUser: deleteUserChange.userId,
|
|
46
|
+
// }))
|
|
47
|
+
// this.logger.debug?.(`INVERSE CHANGE '${JSON.stringify(inverseChanges)}'`)
|
|
48
|
+
// // return new AddUserChange()
|
|
49
|
+
// }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.DeleteUserChange = DeleteUserChange;
|
|
53
|
+
//# sourceMappingURL=DeleteUserChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteUserChange.js","sourceRoot":"","sources":["../../src/Changes/DeleteUserChange.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,sDAOkC;AAuBlC,MAAa,gBAAiB,SAAQ,eAAM;IAC1C,QAAQ,GAAG,kBAA2B,CAAA;IACtC,OAAO,CAA2B;IAClC,MAAM,CAAQ;IAEd,YAAY,IAAgC,EAAE,OAAuB;QACnE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IAC3B,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAwB;QAC5C,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;QACtC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAC/B,MAAM,IAAI,GAAG,MAAM,SAAS;aACzB,gBAAgB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;aACjC,OAAO,CAAC,OAAO,CAAC;aAChB,IAAI,EAAE,CAAA;QACT,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,MAAM,GAAG,4BAA4B,MAAM,aAAa,CAAA;YAC9D,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA4B;QACnD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;IAED,gEAAgE;IAChE,KAAK,CAAC,eAAe,CAAC,UAA2B,IAAG,CAAC;IAErD,UAAU;QACR,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QACzC,OAAO,IAAI,gBAAgB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAC7D,gEAAgE;QAChE,wCAAwC;QACxC,eAAe;QACf,iBAAiB;QACjB,oCAAoC;QACpC,4CAA4C;QAC5C,UAAU;QACV,8EAA8E;QAC9E,kCAAkC;QAClC,IAAI;IACN,CAAC;CACF;AAnDD,4CAmDC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChangeOptions, ClientDataStore, FeatureChange, LocalGFF3DataStore, SerializedFeatureChange, ServerDataStore } from '@apollo-annotation/common';
|
|
2
|
+
interface SerializedFeatureAttributeChangeBase extends SerializedFeatureChange {
|
|
3
|
+
typeName: 'FeatureAttributeChange';
|
|
4
|
+
}
|
|
5
|
+
export interface FeatureAttributeChangeDetails {
|
|
6
|
+
featureId: string;
|
|
7
|
+
attributes: Record<string, string[]>;
|
|
8
|
+
}
|
|
9
|
+
interface SerializedFeatureAttributeChangeSingle extends SerializedFeatureAttributeChangeBase, FeatureAttributeChangeDetails {
|
|
10
|
+
}
|
|
11
|
+
interface SerializedFeatureAttributeChangeMultiple extends SerializedFeatureAttributeChangeBase {
|
|
12
|
+
changes: FeatureAttributeChangeDetails[];
|
|
13
|
+
}
|
|
14
|
+
export type SerializedFeatureAttributeChange = SerializedFeatureAttributeChangeSingle | SerializedFeatureAttributeChangeMultiple;
|
|
15
|
+
export declare class FeatureAttributeChange extends FeatureChange {
|
|
16
|
+
typeName: "FeatureAttributeChange";
|
|
17
|
+
changes: FeatureAttributeChangeDetails[];
|
|
18
|
+
constructor(json: SerializedFeatureAttributeChange, options?: ChangeOptions);
|
|
19
|
+
toJSON(): SerializedFeatureAttributeChange;
|
|
20
|
+
/**
|
|
21
|
+
* Applies the required change to database
|
|
22
|
+
* @param backend - parameters from backend
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
executeOnServer(backend: ServerDataStore): Promise<void>;
|
|
26
|
+
executeOnLocalGFF3(_backend: LocalGFF3DataStore): Promise<void>;
|
|
27
|
+
executeOnClient(dataStore: ClientDataStore): Promise<void>;
|
|
28
|
+
getInverse(): FeatureAttributeChange;
|
|
29
|
+
}
|
|
30
|
+
export declare function isFeatureAttributeChange(change: unknown): change is FeatureAttributeChange;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FeatureAttributeChange = void 0;
|
|
4
|
+
exports.isFeatureAttributeChange = isFeatureAttributeChange;
|
|
5
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
6
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
8
|
+
const common_1 = require("@apollo-annotation/common");
|
|
9
|
+
class FeatureAttributeChange extends common_1.FeatureChange {
|
|
10
|
+
typeName = 'FeatureAttributeChange';
|
|
11
|
+
changes;
|
|
12
|
+
constructor(json, options) {
|
|
13
|
+
super(json, options);
|
|
14
|
+
this.changes = 'changes' in json ? json.changes : [json];
|
|
15
|
+
}
|
|
16
|
+
toJSON() {
|
|
17
|
+
const { assembly, changedIds, changes, typeName } = this;
|
|
18
|
+
if (changes.length === 1) {
|
|
19
|
+
const [{ attributes, featureId }] = changes;
|
|
20
|
+
return { typeName, changedIds, assembly, featureId, attributes };
|
|
21
|
+
}
|
|
22
|
+
return { typeName, changedIds, assembly, changes };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Applies the required change to database
|
|
26
|
+
* @param backend - parameters from backend
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
async executeOnServer(backend) {
|
|
30
|
+
const { featureModel, session } = backend;
|
|
31
|
+
const { changes, logger } = this;
|
|
32
|
+
const featuresForChanges = [];
|
|
33
|
+
// Loop the changes and check that all features are found
|
|
34
|
+
for (const change of changes) {
|
|
35
|
+
const { featureId } = change;
|
|
36
|
+
// Search correct feature
|
|
37
|
+
const topLevelFeature = await featureModel
|
|
38
|
+
.findOne({ allIds: featureId })
|
|
39
|
+
.session(session)
|
|
40
|
+
.exec();
|
|
41
|
+
if (!topLevelFeature) {
|
|
42
|
+
const errMsg = `*** ERROR: The following featureId was not found in database ='${featureId}'`;
|
|
43
|
+
logger.error(errMsg);
|
|
44
|
+
throw new Error(errMsg);
|
|
45
|
+
// throw new NotFoundException(errMsg) -- This is causing runtime error because Exception comes from @nestjs/common!!!
|
|
46
|
+
}
|
|
47
|
+
logger.debug?.(`*** Feature found: ${JSON.stringify(topLevelFeature)}`);
|
|
48
|
+
const foundFeature = this.getFeatureFromId(topLevelFeature, featureId);
|
|
49
|
+
if (!foundFeature) {
|
|
50
|
+
const errMsg = 'ERROR when searching feature by featureId';
|
|
51
|
+
logger.error(errMsg);
|
|
52
|
+
throw new Error(errMsg);
|
|
53
|
+
}
|
|
54
|
+
logger.debug?.(`*** Found feature: ${JSON.stringify(foundFeature)}`);
|
|
55
|
+
featuresForChanges.push({ feature: foundFeature, topLevelFeature });
|
|
56
|
+
}
|
|
57
|
+
// Let's update objects
|
|
58
|
+
for (const [idx, change] of changes.entries()) {
|
|
59
|
+
const { attributes } = change;
|
|
60
|
+
const { feature, topLevelFeature } = featuresForChanges[idx];
|
|
61
|
+
feature.attributes = attributes;
|
|
62
|
+
if (topLevelFeature._id.equals(feature._id)) {
|
|
63
|
+
topLevelFeature.markModified('attributes'); // Mark as modified. Without this save() -method is not updating data in database
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
topLevelFeature.markModified('children'); // Mark as modified. Without this save() -method is not updating data in database
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
await topLevelFeature.save();
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger.debug?.(`*** FAILED: ${error}`);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
logger.debug?.(`*** Feature attributes modified (added, edited or deleted), docId: ${JSON.stringify(topLevelFeature)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async executeOnLocalGFF3(_backend) {
|
|
79
|
+
throw new Error('applyToLocalGFF3 not implemented');
|
|
80
|
+
}
|
|
81
|
+
async executeOnClient(dataStore) {
|
|
82
|
+
if (!dataStore) {
|
|
83
|
+
throw new Error('No data store');
|
|
84
|
+
}
|
|
85
|
+
for (const [idx, changedId] of this.changedIds.entries()) {
|
|
86
|
+
const feature = dataStore.getFeature(changedId);
|
|
87
|
+
if (!feature) {
|
|
88
|
+
throw new Error(`Could not find feature with identifier "${changedId}"`);
|
|
89
|
+
}
|
|
90
|
+
feature.setAttributes(new Map(Object.entries(this.changes[idx].attributes)));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
getInverse() {
|
|
94
|
+
const { assembly, changedIds, changes, logger } = this;
|
|
95
|
+
const inverseChangedIds = [...changedIds].reverse();
|
|
96
|
+
const inverseChanges = [...changes].reverse().map((oneChange) => ({
|
|
97
|
+
featureId: oneChange.featureId,
|
|
98
|
+
attributes: oneChange.attributes,
|
|
99
|
+
}));
|
|
100
|
+
return new FeatureAttributeChange({
|
|
101
|
+
changedIds: inverseChangedIds,
|
|
102
|
+
typeName: 'FeatureAttributeChange',
|
|
103
|
+
changes: inverseChanges,
|
|
104
|
+
assembly,
|
|
105
|
+
}, { logger });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.FeatureAttributeChange = FeatureAttributeChange;
|
|
109
|
+
function isFeatureAttributeChange(change) {
|
|
110
|
+
return (change.typeName === 'FeatureAttributeChange');
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=FeatureAttributeChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FeatureAttributeChange.js","sourceRoot":"","sources":["../../src/Changes/FeatureAttributeChange.ts"],"names":[],"mappings":";;;AA6JA,4DAMC;AAnKD,qEAAqE;AACrE,qDAAqD;AACrD,gEAAgE;AAChE,sDAOkC;AAyBlC,MAAa,sBAAuB,SAAQ,sBAAa;IACvD,QAAQ,GAAG,wBAAiC,CAAA;IAC5C,OAAO,CAAiC;IAExC,YAAY,IAAsC,EAAE,OAAuB;QACzE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;QACxD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAA;YAC3C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,CAAA;QAClE,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;IACpD,CAAC;IAED;;;;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GAAG,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;YAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,SAAS,GAAG,CAAC,CAAA;YAC1E,CAAC;YACD,OAAO,CAAC,aAAa,CACnB,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CACtD,CAAA;QACH,CAAC;IACH,CAAC;IAED,UAAU;QACR,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QACtD,MAAM,iBAAiB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,OAAO,EAAE,CAAA;QACnD,MAAM,cAAc,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAChE,SAAS,EAAE,SAAS,CAAC,SAAS;YAC9B,UAAU,EAAE,SAAS,CAAC,UAAU;SACjC,CAAC,CAAC,CAAA;QACH,OAAO,IAAI,sBAAsB,CAC/B;YACE,UAAU,EAAE,iBAAiB;YAC7B,QAAQ,EAAE,wBAAwB;YAClC,OAAO,EAAE,cAAc;YACvB,QAAQ;SACT,EACD,EAAE,MAAM,EAAE,CACX,CAAA;IACH,CAAC;CACF;AAxHD,wDAwHC;AAED,SAAgB,wBAAwB,CACtC,MAAe;IAEf,OAAO,CACJ,MAAiC,CAAC,QAAQ,KAAK,wBAAwB,CACzE,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AssemblySpecificChange, ServerDataStore } from '@apollo-annotation/common';
|
|
2
|
+
import { FileDocument } from '@apollo-annotation/schemas';
|
|
3
|
+
import { GFF3Feature } from '@gmod/gff';
|
|
4
|
+
export declare abstract class FromFileBaseChange extends AssemblySpecificChange {
|
|
5
|
+
addRefSeqIntoDb(fileDoc: FileDocument, assembly: string, backend: ServerDataStore): Promise<void>;
|
|
6
|
+
private refSeqCache;
|
|
7
|
+
removeExistingFeatures(backend: ServerDataStore): Promise<void>;
|
|
8
|
+
addFeatureIntoDb(gff3Feature: GFF3Feature, backend: ServerDataStore): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FromFileBaseChange = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
9
|
+
const common_1 = require("@apollo-annotation/common");
|
|
10
|
+
const GFF3_1 = require("../GFF3");
|
|
11
|
+
class FromFileBaseChange extends common_1.AssemblySpecificChange {
|
|
12
|
+
async addRefSeqIntoDb(fileDoc, assembly, backend) {
|
|
13
|
+
const { logger } = this;
|
|
14
|
+
const { filesService, refSeqChunkModel, refSeqModel, user } = backend;
|
|
15
|
+
const { CHUNK_SIZE } = process.env;
|
|
16
|
+
const customChunkSize = CHUNK_SIZE && Number(CHUNK_SIZE);
|
|
17
|
+
let chunkIndex = 0;
|
|
18
|
+
let refSeqLen = 0;
|
|
19
|
+
let refSeqDoc;
|
|
20
|
+
let fastaInfoStarted = fileDoc.type !== 'text/x-gff3';
|
|
21
|
+
// Read data from compressed file and parse the content
|
|
22
|
+
const sequenceStream = filesService.getFileStream(fileDoc);
|
|
23
|
+
let sequenceBuffer = '';
|
|
24
|
+
let incompleteLine = '';
|
|
25
|
+
let lastLineIsIncomplete = true;
|
|
26
|
+
let parsingStarted = false;
|
|
27
|
+
logger.debug?.('starting sequence stream');
|
|
28
|
+
let lineCount = 0;
|
|
29
|
+
for await (const data of sequenceStream) {
|
|
30
|
+
const chunk = data.toString();
|
|
31
|
+
lastLineIsIncomplete = !chunk.endsWith('\n');
|
|
32
|
+
// chunk is small enough that you can split the whole thing into lines without having to make it into smaller chunks first.
|
|
33
|
+
const lines = chunk.split(/\r?\n/);
|
|
34
|
+
if (incompleteLine) {
|
|
35
|
+
lines[0] = `${incompleteLine}${lines[0]}`;
|
|
36
|
+
incompleteLine = '';
|
|
37
|
+
}
|
|
38
|
+
if (lastLineIsIncomplete) {
|
|
39
|
+
incompleteLine = lines.pop() || '';
|
|
40
|
+
}
|
|
41
|
+
for await (const line of lines) {
|
|
42
|
+
lineCount++;
|
|
43
|
+
if (lineCount % 1_000_000 === 0) {
|
|
44
|
+
logger.debug?.(`Processed ${lineCount} lines`);
|
|
45
|
+
}
|
|
46
|
+
// In case of GFF3 file we start to read sequence after '##FASTA' is found
|
|
47
|
+
if (!fastaInfoStarted) {
|
|
48
|
+
if (line.trim() === '##FASTA') {
|
|
49
|
+
fastaInfoStarted = true;
|
|
50
|
+
}
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const refSeqInfoLine = /^>\s*(\S+)\s*(.*)/.exec(line);
|
|
54
|
+
// Add new ref sequence info if we are reference seq info line
|
|
55
|
+
if (refSeqInfoLine) {
|
|
56
|
+
parsingStarted = true;
|
|
57
|
+
logger.debug?.(`Reference sequence information line "${refSeqInfoLine[0]}"`);
|
|
58
|
+
// If there is sequence from previous reference sequence then we need to add it to previous ref seq
|
|
59
|
+
if (sequenceBuffer !== '') {
|
|
60
|
+
if (!refSeqDoc) {
|
|
61
|
+
throw new Error('No refSeq document found');
|
|
62
|
+
}
|
|
63
|
+
refSeqLen += sequenceBuffer.length;
|
|
64
|
+
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
65
|
+
await refSeqChunkModel.create([
|
|
66
|
+
{
|
|
67
|
+
refSeq: refSeqDoc._id,
|
|
68
|
+
n: chunkIndex,
|
|
69
|
+
sequence: sequenceBuffer,
|
|
70
|
+
user,
|
|
71
|
+
status: -1,
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
sequenceBuffer = '';
|
|
75
|
+
}
|
|
76
|
+
await refSeqDoc?.updateOne({ length: refSeqLen });
|
|
77
|
+
// await refSeqDoc?.updateOne({ length: refSeqLen }, { session })
|
|
78
|
+
refSeqLen = 0;
|
|
79
|
+
chunkIndex = 0;
|
|
80
|
+
const name = refSeqInfoLine[1].trim();
|
|
81
|
+
const description = refSeqInfoLine[2] ? refSeqInfoLine[2].trim() : '';
|
|
82
|
+
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
83
|
+
const [newRefSeqDoc] = await refSeqModel.create([
|
|
84
|
+
{
|
|
85
|
+
name,
|
|
86
|
+
description,
|
|
87
|
+
assembly,
|
|
88
|
+
length: 0,
|
|
89
|
+
...(customChunkSize ? { chunkSize: customChunkSize } : null),
|
|
90
|
+
user,
|
|
91
|
+
status: -1,
|
|
92
|
+
},
|
|
93
|
+
]);
|
|
94
|
+
logger.debug?.(`Added new refSeq "${name}", desc "${description}", docId "${newRefSeqDoc._id}"`);
|
|
95
|
+
refSeqDoc = newRefSeqDoc;
|
|
96
|
+
}
|
|
97
|
+
else if (/\S/.test(line)) {
|
|
98
|
+
if (!refSeqDoc) {
|
|
99
|
+
throw new Error('No refSeq document found');
|
|
100
|
+
}
|
|
101
|
+
const { _id, chunkSize } = refSeqDoc;
|
|
102
|
+
sequenceBuffer += line.replaceAll(/\s/g, '');
|
|
103
|
+
// If sequence block > chunk size then save chunk into Mongo
|
|
104
|
+
while (sequenceBuffer.length >= chunkSize) {
|
|
105
|
+
const sequence = sequenceBuffer.slice(0, chunkSize);
|
|
106
|
+
refSeqLen += sequence.length;
|
|
107
|
+
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
108
|
+
await refSeqChunkModel.create([
|
|
109
|
+
{ refSeq: _id, n: chunkIndex, sequence, user, status: -1 },
|
|
110
|
+
]);
|
|
111
|
+
chunkIndex++;
|
|
112
|
+
// Set remaining sequence
|
|
113
|
+
sequenceBuffer = sequenceBuffer.slice(chunkSize);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!parsingStarted) {
|
|
119
|
+
throw new Error('No reference sequences found in file');
|
|
120
|
+
}
|
|
121
|
+
if (sequenceBuffer || lastLineIsIncomplete) {
|
|
122
|
+
if (!refSeqDoc) {
|
|
123
|
+
throw new Error('No refSeq document found');
|
|
124
|
+
}
|
|
125
|
+
// If the file did not end with line break so the last line is incomplete
|
|
126
|
+
if (lastLineIsIncomplete) {
|
|
127
|
+
sequenceBuffer += incompleteLine;
|
|
128
|
+
}
|
|
129
|
+
refSeqLen += sequenceBuffer.length;
|
|
130
|
+
logger.verbose?.(`*** Add the very last chunk to ref seq ("${refSeqDoc._id}", index ${chunkIndex} and total length for ref seq is ${refSeqLen}): "${sequenceBuffer}"`);
|
|
131
|
+
logger.debug?.(`Creating refSeq chunk number ${chunkIndex} of "${refSeqDoc._id}"`);
|
|
132
|
+
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
133
|
+
await refSeqChunkModel.create([
|
|
134
|
+
{
|
|
135
|
+
refSeq: refSeqDoc._id,
|
|
136
|
+
n: chunkIndex,
|
|
137
|
+
sequence: sequenceBuffer,
|
|
138
|
+
user,
|
|
139
|
+
status: -1,
|
|
140
|
+
},
|
|
141
|
+
]);
|
|
142
|
+
await refSeqDoc.updateOne({ length: refSeqLen });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
refSeqCache = new Map();
|
|
146
|
+
async removeExistingFeatures(backend) {
|
|
147
|
+
const { featureModel, refSeqModel } = backend;
|
|
148
|
+
const { assembly, logger } = this;
|
|
149
|
+
logger.debug?.(`Removing existing features for assembly = ${assembly}`);
|
|
150
|
+
const refSeqs = await refSeqModel
|
|
151
|
+
.find({ assembly })
|
|
152
|
+
.exec();
|
|
153
|
+
for (const refSeq of refSeqs) {
|
|
154
|
+
await featureModel.deleteMany({ refSeq: refSeq._id });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async addFeatureIntoDb(gff3Feature, backend) {
|
|
158
|
+
const { featureModel, refSeqModel, user } = backend;
|
|
159
|
+
const { assembly, refSeqCache } = this;
|
|
160
|
+
const [{ seq_id: refName }] = gff3Feature;
|
|
161
|
+
if (!refName) {
|
|
162
|
+
throw new Error(`Valid seq_id not found in feature ${JSON.stringify(gff3Feature)}`);
|
|
163
|
+
}
|
|
164
|
+
let refSeqDoc = refSeqCache.get(refName);
|
|
165
|
+
if (!refSeqDoc) {
|
|
166
|
+
refSeqDoc =
|
|
167
|
+
(await refSeqModel.findOne({ assembly, name: refName }).exec()) ??
|
|
168
|
+
undefined;
|
|
169
|
+
if (refSeqDoc) {
|
|
170
|
+
refSeqCache.set(refName, refSeqDoc);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!refSeqDoc) {
|
|
174
|
+
throw new Error(`RefSeq was not found by assembly "${assembly}" and seq_id "${refName}" not found`);
|
|
175
|
+
}
|
|
176
|
+
// Let's add featureId to parent feature
|
|
177
|
+
const featureIds = [];
|
|
178
|
+
const newFeature = (0, GFF3_1.gff3ToAnnotationFeature)(gff3Feature, refSeqDoc._id, featureIds);
|
|
179
|
+
// Add into Mongo
|
|
180
|
+
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
181
|
+
await featureModel.create([
|
|
182
|
+
{ allIds: featureIds, ...newFeature, user, status: -1 },
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.FromFileBaseChange = FromFileBaseChange;
|
|
187
|
+
//# sourceMappingURL=FromFileBaseChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FromFileBaseChange.js","sourceRoot":"","sources":["../../src/Changes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AC;QACD,IAAI,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;gBACP,CAAC,MAAM,WAAW,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;oBAC/D,SAAS,CAAA;YACX,IAAI,SAAS,EAAE,CAAC;gBACd,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,qCAAqC,QAAQ,iBAAiB,OAAO,aAAa,CACnF,CAAA;QACH,CAAC;QACD,wCAAwC;QACxC,MAAM,UAAU,GAAa,EAAE,CAAA;QAE/B,MAAM,UAAU,GAAG,IAAA,8BAAuB,EACxC,WAAW,EACX,SAAS,CAAC,GAAG,EACb,UAAU,CACX,CAAA;QAED,iBAAiB;QACjB,iGAAiG;QACjG,MAAM,YAAY,CAAC,MAAM,CAAC;YACxB,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE;SACxD,CAAC,CAAA;IACJ,CAAC;CACF;AA9MD,gDA8MC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Change, ChangeOptions, ClientDataStore, LocalGFF3DataStore, ServerDataStore } from '@apollo-annotation/common';
|
|
2
|
+
interface JBrowseAssembly {
|
|
3
|
+
sequence: {
|
|
4
|
+
adapter: {
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
interface JBrowseTrack {
|
|
10
|
+
type: string;
|
|
11
|
+
trackId: string;
|
|
12
|
+
}
|
|
13
|
+
interface JBrowsePlugin {
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
interface JBrowseInternetAccount {
|
|
17
|
+
type: string;
|
|
18
|
+
}
|
|
19
|
+
export interface JBrowseConfig {
|
|
20
|
+
assemblies?: JBrowseAssembly[];
|
|
21
|
+
tracks?: JBrowseTrack[];
|
|
22
|
+
plugins?: JBrowsePlugin[];
|
|
23
|
+
internetAccounts?: JBrowseInternetAccount[];
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface SerializedImportJBrowseConfigChange {
|
|
27
|
+
typeName: 'ImportJBrowseConfigChange';
|
|
28
|
+
oldJBrowseConfig?: JBrowseConfig;
|
|
29
|
+
newJBrowseConfig?: JBrowseConfig;
|
|
30
|
+
}
|
|
31
|
+
export declare function filterJBrowseConfig(config: JBrowseConfig): JBrowseConfig;
|
|
32
|
+
export declare class ImportJBrowseConfigChange extends Change {
|
|
33
|
+
typeName: "ImportJBrowseConfigChange";
|
|
34
|
+
oldJBrowseConfig?: JBrowseConfig;
|
|
35
|
+
newJBrowseConfig?: JBrowseConfig;
|
|
36
|
+
constructor(json: SerializedImportJBrowseConfigChange, options?: ChangeOptions);
|
|
37
|
+
toJSON(): SerializedImportJBrowseConfigChange;
|
|
38
|
+
executeOnServer(backend: ServerDataStore): Promise<void>;
|
|
39
|
+
executeOnLocalGFF3(_backend: LocalGFF3DataStore): Promise<void>;
|
|
40
|
+
executeOnClient(_dataStore: ClientDataStore): Promise<void>;
|
|
41
|
+
getInverse(): ImportJBrowseConfigChange;
|
|
42
|
+
}
|
|
43
|
+
export {};
|