@apollo-annotation/shared 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.
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.d.ts +33 -0
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js +83 -0
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js.map +1 -0
- package/dist/Changes/AddAssemblyFromExternalChange.d.ts +34 -0
- package/dist/Changes/AddAssemblyFromExternalChange.js +97 -0
- package/dist/Changes/AddAssemblyFromExternalChange.js.map +1 -0
- package/dist/Changes/AddAssemblyFromFileChange.d.ts +43 -0
- package/dist/Changes/AddAssemblyFromFileChange.js +140 -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 +17 -8
- package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +13 -9
- package/src/Changes/AddAssemblyFromFileChange.ts +129 -43
- package/src/Changes/AddFeatureChange.ts +2 -3
- package/src/Changes/AddFeaturesFromFileChange.ts +8 -3
- package/src/Changes/AddRefSeqAliasesChange.ts +88 -0
- package/src/Changes/DeleteAssemblyChange.ts +1 -1
- package/src/Changes/DeleteFeatureChange.ts +1 -1
- package/src/Changes/FeatureAttributeChange.ts +1 -1
- package/src/Changes/FromFileBaseChange.ts +221 -0
- package/src/Changes/ImportJBrowseConfigChange.ts +116 -0
- package/src/Changes/LocationEndChange.ts +25 -18
- package/src/Changes/LocationStartChange.ts +25 -18
- package/src/Changes/TypeChange.ts +1 -1
- package/src/Changes/index.ts +6 -6
- package/src/Checks/CDSCheck.ts +125 -173
- package/src/Common/jwtPayload.ts +1 -1
- package/src/GFF3/gff3ToAnnotationFeature.test.ts +209 -0
- package/src/GFF3/gff3ToAnnotationFeature.ts +257 -0
- package/src/GFF3/gffReservedKeys.ts +61 -0
- package/src/GFF3/index.ts +2 -0
- package/src/Operations/GetFeaturesOperation.ts +2 -2
- package/src/Validations/ParentChildValidation.ts +5 -5
- package/src/index.ts +1 -0
- package/src/util.ts +16 -12
- 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
- package/tsconfig.json +4 -4
- package/src/Changes/DiscontinuousLocationEndChange.ts +0 -182
- package/src/Changes/DiscontinuousLocationStartChange.ts +0 -182
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AnnotationFeatureSnapshot } from '@apollo-annotation/mst';
|
|
2
|
+
import { GFF3Feature } from '@gmod/gff';
|
|
3
|
+
export declare function makeGFF3Feature(feature: AnnotationFeatureSnapshot, parentId?: string, refSeqNames?: Record<string, string | undefined>): GFF3Feature;
|
|
4
|
+
export declare function splitStringIntoChunks(input: string, chunkSize: number): string[];
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.makeGFF3Feature = makeGFF3Feature;
|
|
5
|
+
exports.splitStringIntoChunks = splitStringIntoChunks;
|
|
6
|
+
function makeGFF3Feature(feature, parentId, refSeqNames) {
|
|
7
|
+
const locations = [{ start: feature.min, end: feature.max }];
|
|
8
|
+
// const locations = feature.discontinuousLocations?.length
|
|
9
|
+
// ? feature.discontinuousLocations
|
|
10
|
+
// : [{ start: feature.start, end: feature.end, phase: feature.phase }]
|
|
11
|
+
const attributes = JSON.parse(JSON.stringify(feature.attributes));
|
|
12
|
+
const ontologyTerms = [];
|
|
13
|
+
const source = feature.attributes?.source?.[0] ?? null;
|
|
14
|
+
delete attributes.source;
|
|
15
|
+
if (parentId) {
|
|
16
|
+
attributes.Parent = [parentId];
|
|
17
|
+
}
|
|
18
|
+
if (attributes._id) {
|
|
19
|
+
attributes.ID = attributes._id;
|
|
20
|
+
delete attributes._id;
|
|
21
|
+
}
|
|
22
|
+
if (attributes.gff_name) {
|
|
23
|
+
attributes.Name = attributes.gff_name;
|
|
24
|
+
delete attributes.gff_name;
|
|
25
|
+
}
|
|
26
|
+
if (attributes.gff_alias) {
|
|
27
|
+
attributes.Alias = attributes.gff_alias;
|
|
28
|
+
delete attributes.gff_alias;
|
|
29
|
+
}
|
|
30
|
+
if (attributes.gff_target) {
|
|
31
|
+
attributes.Target = attributes.gff_target;
|
|
32
|
+
delete attributes.gff_target;
|
|
33
|
+
}
|
|
34
|
+
if (attributes.gff_gap) {
|
|
35
|
+
attributes.Gap = attributes.gff_gap;
|
|
36
|
+
delete attributes.gff_gap;
|
|
37
|
+
}
|
|
38
|
+
if (attributes.gff_derives_from) {
|
|
39
|
+
attributes.Derives_from = attributes.gff_derives_from;
|
|
40
|
+
delete attributes.gff_derives_from;
|
|
41
|
+
}
|
|
42
|
+
if (attributes.gff_note) {
|
|
43
|
+
attributes.Note = attributes.gff_note;
|
|
44
|
+
delete attributes.gff_note;
|
|
45
|
+
}
|
|
46
|
+
if (attributes.gff_dbxref) {
|
|
47
|
+
attributes.Dbxref = attributes.gff_dbxref;
|
|
48
|
+
delete attributes.gff_dbxref;
|
|
49
|
+
}
|
|
50
|
+
if (attributes.gff_is_circular) {
|
|
51
|
+
attributes.Is_circular = attributes.gff_is_circular;
|
|
52
|
+
delete attributes.gff_is_circular;
|
|
53
|
+
}
|
|
54
|
+
if (attributes.gff_ontology_term) {
|
|
55
|
+
ontologyTerms.push(...attributes.gff_ontology_term);
|
|
56
|
+
delete attributes.gff_ontology_term;
|
|
57
|
+
}
|
|
58
|
+
if (attributes['Gene Ontology']) {
|
|
59
|
+
ontologyTerms.push(...attributes['Gene Ontology']);
|
|
60
|
+
delete attributes['Gene Ontology'];
|
|
61
|
+
}
|
|
62
|
+
if (attributes['Sequence Ontology']) {
|
|
63
|
+
ontologyTerms.push(...attributes['Sequence Ontology']);
|
|
64
|
+
delete attributes['Sequence Ontology'];
|
|
65
|
+
}
|
|
66
|
+
if (ontologyTerms.length > 0) {
|
|
67
|
+
attributes.Ontology_term = ontologyTerms;
|
|
68
|
+
}
|
|
69
|
+
return locations.map((location) => ({
|
|
70
|
+
start: location.start + 1,
|
|
71
|
+
end: location.end,
|
|
72
|
+
seq_id: refSeqNames ? refSeqNames[feature.refSeq] ?? null : feature.refSeq,
|
|
73
|
+
source,
|
|
74
|
+
type: feature.type,
|
|
75
|
+
score: null,
|
|
76
|
+
// score: feature.score ?? null,
|
|
77
|
+
strand: feature.strand ? (feature.strand === 1 ? '+' : '-') : null,
|
|
78
|
+
phase: null,
|
|
79
|
+
// phase:
|
|
80
|
+
// location.phase === 0
|
|
81
|
+
// ? '0'
|
|
82
|
+
// : location.phase === 1
|
|
83
|
+
// ? '1'
|
|
84
|
+
// : location.phase === 2
|
|
85
|
+
// ? '2'
|
|
86
|
+
// : null,
|
|
87
|
+
attributes: Object.keys(attributes).length > 0 ? attributes : null,
|
|
88
|
+
derived_features: [],
|
|
89
|
+
child_features: feature.children
|
|
90
|
+
? Object.values(feature.children).map((child) => makeGFF3Feature(child, attributes.ID?.[0], refSeqNames))
|
|
91
|
+
: [],
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
function splitStringIntoChunks(input, chunkSize) {
|
|
95
|
+
const chunks = [];
|
|
96
|
+
for (let i = 0; i < input.length; i += chunkSize) {
|
|
97
|
+
const chunk = input.slice(i, i + chunkSize);
|
|
98
|
+
chunks.push(chunk);
|
|
99
|
+
}
|
|
100
|
+
return chunks;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA,4DAA4D;;AAK5D,0CA+FC;AAED,sDAUC;AA3GD,SAAgB,eAAe,CAC7B,OAAkC,EAClC,QAAiB,EACjB,WAAgD;IAEhD,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IAC5D,2DAA2D;IAC3D,qCAAqC;IACrC,yEAA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AAC,GAAG,SAAS,CAAC,CAAA;QAC3C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo-annotation/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"start": "tsc --build --watch",
|
|
7
6
|
"build": "yarn clean && tsc --build",
|
|
8
|
-
"clean": "rimraf dist"
|
|
7
|
+
"clean": "rimraf dist",
|
|
8
|
+
"start": "tsc --build --watch",
|
|
9
|
+
"test": "glob -c \"tsx --test --test-reporter spec \" \"**/*.test.ts\"",
|
|
10
|
+
"test:ci": "NODE_V8_COVERAGE=./coverage glob -c \"tsx --test --test-reporter spec --experimental-test-coverage \" \"**/*.test.ts\""
|
|
9
11
|
},
|
|
10
12
|
"dependencies": {
|
|
11
|
-
"@apollo-annotation/common": "^0.1.
|
|
12
|
-
"@apollo-annotation/mst": "^0.1.
|
|
13
|
-
"@apollo-annotation/schemas": "^0.1.
|
|
13
|
+
"@apollo-annotation/common": "^0.1.20",
|
|
14
|
+
"@apollo-annotation/mst": "^0.1.20",
|
|
15
|
+
"@apollo-annotation/schemas": "^0.1.20",
|
|
14
16
|
"@gmod/gff": "1.2.0",
|
|
15
17
|
"@gmod/indexedfasta": "^2.0.4",
|
|
16
|
-
"@jbrowse/core": "^2.
|
|
18
|
+
"@jbrowse/core": "^2.13.1",
|
|
17
19
|
"bson-objectid": "^2.0.4",
|
|
18
20
|
"generic-filehandle": "^3.0.0",
|
|
19
21
|
"jwt-decode": "^3.1.2",
|
|
@@ -24,13 +26,20 @@
|
|
|
24
26
|
"devDependencies": {
|
|
25
27
|
"@nestjs/common": "^10.1.0",
|
|
26
28
|
"@nestjs/core": "^10.1.0",
|
|
29
|
+
"@types/chai": "^4.3.19",
|
|
27
30
|
"@types/node": "^18.14.2",
|
|
28
31
|
"@types/rimraf": "^3",
|
|
32
|
+
"chai": "^5.1.1",
|
|
33
|
+
"chai-exclude": "^3.0.0",
|
|
34
|
+
"glob": "^11.0.0",
|
|
29
35
|
"mobx": "^6.6.1",
|
|
30
36
|
"mobx-state-tree": "^5.1.7",
|
|
31
37
|
"mongoose": "^6.12.0",
|
|
38
|
+
"react-dom": "^18.2.0",
|
|
32
39
|
"rimraf": "^3.0.2",
|
|
33
|
-
"
|
|
40
|
+
"rxjs": "^7.4.0",
|
|
41
|
+
"tsx": "^4.6.2",
|
|
42
|
+
"typescript": "^5.5.3"
|
|
34
43
|
},
|
|
35
44
|
"peerDependencies": {
|
|
36
45
|
"@mui/material": "^5.11.14",
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
2
1
|
/* eslint-disable @typescript-eslint/require-await */
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
|
-
AssemblySpecificChange,
|
|
6
4
|
ChangeOptions,
|
|
7
5
|
ClientDataStore,
|
|
8
6
|
LocalGFF3DataStore,
|
|
@@ -11,6 +9,8 @@ import {
|
|
|
11
9
|
} from '@apollo-annotation/common'
|
|
12
10
|
import { GFF3Feature } from '@gmod/gff'
|
|
13
11
|
|
|
12
|
+
import { FromFileBaseChange } from './FromFileBaseChange'
|
|
13
|
+
|
|
14
14
|
export interface SerializedAddAssemblyAndFeaturesFromFileChangeBase
|
|
15
15
|
extends SerializedAssemblySpecificChange {
|
|
16
16
|
typeName: 'AddAssemblyAndFeaturesFromFileChange'
|
|
@@ -18,7 +18,7 @@ export interface SerializedAddAssemblyAndFeaturesFromFileChangeBase
|
|
|
18
18
|
|
|
19
19
|
export interface AddAssemblyAndFeaturesFromFileChangeDetails {
|
|
20
20
|
assemblyName: string
|
|
21
|
-
|
|
21
|
+
fileIds: { fa: string }
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface SerializedAddAssemblyAndFeaturesFromFileChangeSingle
|
|
@@ -34,7 +34,7 @@ export type SerializedAddAssemblyAndFeaturesFromFileChange =
|
|
|
34
34
|
| SerializedAddAssemblyAndFeaturesFromFileChangeSingle
|
|
35
35
|
| SerializedAddAssemblyAndFeaturesFromFileChangeMultiple
|
|
36
36
|
|
|
37
|
-
export class AddAssemblyAndFeaturesFromFileChange extends
|
|
37
|
+
export class AddAssemblyAndFeaturesFromFileChange extends FromFileBaseChange {
|
|
38
38
|
typeName = 'AddAssemblyAndFeaturesFromFileChange' as const
|
|
39
39
|
changes: AddAssemblyAndFeaturesFromFileChangeDetails[]
|
|
40
40
|
|
|
@@ -53,8 +53,8 @@ export class AddAssemblyAndFeaturesFromFileChange extends AssemblySpecificChange
|
|
|
53
53
|
toJSON(): SerializedAddAssemblyAndFeaturesFromFileChange {
|
|
54
54
|
const { assembly, changes, typeName } = this
|
|
55
55
|
if (changes.length === 1) {
|
|
56
|
-
const [{ assemblyName,
|
|
57
|
-
return { typeName, assembly, assemblyName,
|
|
56
|
+
const [{ assemblyName, fileIds }] = changes
|
|
57
|
+
return { typeName, assembly, assemblyName, fileIds }
|
|
58
58
|
}
|
|
59
59
|
return { typeName, assembly, changes }
|
|
60
60
|
}
|
|
@@ -68,7 +68,8 @@ export class AddAssemblyAndFeaturesFromFileChange extends AssemblySpecificChange
|
|
|
68
68
|
const { assemblyModel, fileModel, filesService, user } = backend
|
|
69
69
|
const { assembly, changes, logger } = this
|
|
70
70
|
for (const change of changes) {
|
|
71
|
-
const { assemblyName,
|
|
71
|
+
const { assemblyName, fileIds } = change
|
|
72
|
+
const fileId = fileIds.fa
|
|
72
73
|
|
|
73
74
|
const { FILE_UPLOAD_FOLDER } = process.env
|
|
74
75
|
if (!FILE_UPLOAD_FOLDER) {
|
|
@@ -90,10 +91,10 @@ export class AddAssemblyAndFeaturesFromFileChange extends AssemblySpecificChange
|
|
|
90
91
|
}
|
|
91
92
|
// Add assembly
|
|
92
93
|
const [newAssemblyDoc] = await assemblyModel.create([
|
|
93
|
-
{ _id: assembly, name: assemblyName, user, status: -1 },
|
|
94
|
+
{ _id: assembly, name: assemblyName, user, status: -1, fileId },
|
|
94
95
|
])
|
|
95
96
|
logger.debug?.(
|
|
96
|
-
`Added new assembly "${assemblyName}", docId "${newAssemblyDoc._id}"`,
|
|
97
|
+
`Added new assembly "${assemblyName}", docId "${newAssemblyDoc._id.toHexString()}"`,
|
|
97
98
|
)
|
|
98
99
|
logger.debug?.(`File type: "${fileDoc.type}"`)
|
|
99
100
|
|
|
@@ -106,6 +107,9 @@ export class AddAssemblyAndFeaturesFromFileChange extends AssemblySpecificChange
|
|
|
106
107
|
)
|
|
107
108
|
|
|
108
109
|
// Loop all features
|
|
110
|
+
logger.debug?.(
|
|
111
|
+
`**************** LOOPATAAN KAIKKI FEATURET SEURAAVAKSI File type: "${fileDoc.type}"`,
|
|
112
|
+
)
|
|
109
113
|
const featureStream = filesService.parseGFF3(
|
|
110
114
|
filesService.getFileStream(fileDoc),
|
|
111
115
|
)
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
2
2
|
/* eslint-disable @typescript-eslint/require-await */
|
|
3
3
|
import {
|
|
4
|
-
AssemblySpecificChange,
|
|
5
4
|
ChangeOptions,
|
|
6
5
|
ClientDataStore,
|
|
7
6
|
LocalGFF3DataStore,
|
|
8
7
|
SerializedAssemblySpecificChange,
|
|
9
8
|
ServerDataStore,
|
|
10
9
|
} from '@apollo-annotation/common'
|
|
10
|
+
import { BgzipIndexedFasta } from '@gmod/indexedfasta'
|
|
11
|
+
|
|
12
|
+
import { FromFileBaseChange } from './FromFileBaseChange'
|
|
11
13
|
|
|
12
14
|
export interface SerializedAddAssemblyFromFileChangeBase
|
|
13
15
|
extends SerializedAssemblySpecificChange {
|
|
@@ -16,7 +18,7 @@ export interface SerializedAddAssemblyFromFileChangeBase
|
|
|
16
18
|
|
|
17
19
|
export interface AddAssemblyFromFileChangeDetails {
|
|
18
20
|
assemblyName: string
|
|
19
|
-
|
|
21
|
+
fileIds: { fa: string } | { fa: string; fai: string; gzi: string }
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export interface SerializedAddAssemblyFromFileChangeSingle
|
|
@@ -32,7 +34,7 @@ export type SerializedAddAssemblyFromFileChange =
|
|
|
32
34
|
| SerializedAddAssemblyFromFileChangeSingle
|
|
33
35
|
| SerializedAddAssemblyFromFileChangeMultiple
|
|
34
36
|
|
|
35
|
-
export class AddAssemblyFromFileChange extends
|
|
37
|
+
export class AddAssemblyFromFileChange extends FromFileBaseChange {
|
|
36
38
|
typeName = 'AddAssemblyFromFileChange' as const
|
|
37
39
|
changes: AddAssemblyFromFileChangeDetails[]
|
|
38
40
|
|
|
@@ -51,8 +53,8 @@ export class AddAssemblyFromFileChange extends AssemblySpecificChange {
|
|
|
51
53
|
toJSON(): SerializedAddAssemblyFromFileChange {
|
|
52
54
|
const { assembly, changes, typeName } = this
|
|
53
55
|
if (changes.length === 1) {
|
|
54
|
-
const [{ assemblyName,
|
|
55
|
-
return { typeName, assembly, assemblyName,
|
|
56
|
+
const [{ assemblyName, fileIds }] = changes
|
|
57
|
+
return { typeName, assembly, assemblyName, fileIds }
|
|
56
58
|
}
|
|
57
59
|
return { typeName, assembly, changes }
|
|
58
60
|
}
|
|
@@ -63,49 +65,133 @@ export class AddAssemblyFromFileChange extends AssemblySpecificChange {
|
|
|
63
65
|
* @returns
|
|
64
66
|
*/
|
|
65
67
|
async executeOnServer(backend: ServerDataStore) {
|
|
66
|
-
const {
|
|
67
|
-
const { assembly, changes, logger } = this
|
|
68
|
-
|
|
68
|
+
const { changes } = this
|
|
69
69
|
for (const change of changes) {
|
|
70
|
-
const { assemblyName,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
const { assemblyName, fileIds } = change
|
|
71
|
+
await ('gzi' in fileIds
|
|
72
|
+
? this.executeOnServerIndexed(backend, assemblyName, fileIds)
|
|
73
|
+
: this.executeOnServerFasta(backend, assemblyName, fileIds.fa))
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async executeOnServerIndexed(
|
|
78
|
+
backend: ServerDataStore,
|
|
79
|
+
assemblyName: string,
|
|
80
|
+
fileIds: { fa: string; fai: string; gzi: string },
|
|
81
|
+
) {
|
|
82
|
+
const { CHUNK_SIZE } = process.env
|
|
83
|
+
const customChunkSize = CHUNK_SIZE && Number(CHUNK_SIZE)
|
|
84
|
+
|
|
85
|
+
const { FILE_UPLOAD_FOLDER } = process.env
|
|
86
|
+
if (!FILE_UPLOAD_FOLDER) {
|
|
87
|
+
throw new Error('No FILE_UPLOAD_FOLDER found in .env file')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const { fa, fai, gzi } = fileIds
|
|
91
|
+
const { assemblyModel, fileModel, filesService, refSeqModel, user } =
|
|
92
|
+
backend
|
|
93
|
+
|
|
94
|
+
const faDoc = await fileModel.findById(fa)
|
|
95
|
+
const faChecksum = faDoc?.checksum
|
|
96
|
+
if (!faChecksum) {
|
|
97
|
+
throw new Error(`No checksum for file document ${faDoc}`)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const faiDoc = await fileModel.findById(fai)
|
|
101
|
+
const faiChecksum = faiDoc?.checksum
|
|
102
|
+
if (!faiChecksum) {
|
|
103
|
+
throw new Error(`No checksum for file document ${faiDoc}`)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const gziDoc = await fileModel.findById(gzi)
|
|
107
|
+
const gziChecksum = gziDoc?.checksum
|
|
108
|
+
if (!gziChecksum) {
|
|
109
|
+
throw new Error(`No checksum for file document ${gziDoc}`)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const sequenceAdapter = new BgzipIndexedFasta({
|
|
113
|
+
fasta: filesService.getFileHandle(faDoc),
|
|
114
|
+
fai: filesService.getFileHandle(faiDoc),
|
|
115
|
+
gzi: filesService.getFileHandle(gziDoc),
|
|
116
|
+
})
|
|
117
|
+
const allSequenceSizes = await sequenceAdapter.getSequenceSizes()
|
|
118
|
+
|
|
119
|
+
const assemblyDoc = await assemblyModel
|
|
120
|
+
.findOne({ name: assemblyName })
|
|
121
|
+
.exec()
|
|
122
|
+
if (assemblyDoc) {
|
|
123
|
+
throw new Error(`Assembly "${assemblyName}" already exists`)
|
|
124
|
+
}
|
|
125
|
+
const [newAssemblyDoc] = await assemblyModel.create([
|
|
126
|
+
{
|
|
127
|
+
_id: this.assembly,
|
|
128
|
+
name: assemblyName,
|
|
129
|
+
user,
|
|
130
|
+
status: -1,
|
|
131
|
+
fileIds,
|
|
132
|
+
},
|
|
133
|
+
])
|
|
134
|
+
this.logger.debug?.(
|
|
135
|
+
`Added new assembly "${assemblyName}", docId "${newAssemblyDoc._id}"`,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
for (const sequenceName in allSequenceSizes) {
|
|
139
|
+
const [newRefSeqDoc] = await refSeqModel.create([
|
|
140
|
+
{
|
|
141
|
+
name: sequenceName,
|
|
142
|
+
assembly: newAssemblyDoc._id,
|
|
143
|
+
length: allSequenceSizes[sequenceName],
|
|
144
|
+
...(customChunkSize ? { chunkSize: customChunkSize } : null),
|
|
145
|
+
user,
|
|
146
|
+
status: -1,
|
|
147
|
+
},
|
|
93
148
|
])
|
|
94
|
-
logger.debug?.(
|
|
95
|
-
`Added new
|
|
96
|
-
)
|
|
97
|
-
logger.debug?.(
|
|
98
|
-
`File type: "${fileDoc.type}", assemblyId: "${newAssemblyDoc._id}"`,
|
|
149
|
+
this.logger.debug?.(
|
|
150
|
+
`Added new refSeq "${sequenceName}", docId "${newRefSeqDoc._id}"`,
|
|
99
151
|
)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
100
154
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
155
|
+
async executeOnServerFasta(
|
|
156
|
+
backend: ServerDataStore,
|
|
157
|
+
assemblyName: string,
|
|
158
|
+
fileId: string,
|
|
159
|
+
) {
|
|
160
|
+
const { assemblyModel, fileModel, user } = backend
|
|
161
|
+
// Get file checksum
|
|
162
|
+
const fileDoc = await fileModel.findById(fileId).exec()
|
|
163
|
+
if (!fileDoc) {
|
|
164
|
+
throw new Error(`File "${fileId}" not found in Mongo`)
|
|
165
|
+
}
|
|
166
|
+
this.logger.debug?.(`FileId "${fileId}", checksum "${fileDoc.checksum}"`)
|
|
167
|
+
|
|
168
|
+
// Check and add new assembly
|
|
169
|
+
const assemblyDoc = await assemblyModel
|
|
170
|
+
.findOne({ name: assemblyName })
|
|
171
|
+
.exec()
|
|
172
|
+
if (assemblyDoc) {
|
|
173
|
+
throw new Error(`Assembly "${assemblyName}" already exists`)
|
|
108
174
|
}
|
|
175
|
+
// Add assembly
|
|
176
|
+
const [newAssemblyDoc] = await assemblyModel.create([
|
|
177
|
+
{
|
|
178
|
+
_id: this.assembly,
|
|
179
|
+
name: assemblyName,
|
|
180
|
+
user,
|
|
181
|
+
status: -1,
|
|
182
|
+
fileIds: { fa: fileId },
|
|
183
|
+
},
|
|
184
|
+
])
|
|
185
|
+
this.logger.debug?.(
|
|
186
|
+
`Added new assembly "${assemblyName}", docId "${newAssemblyDoc._id}"`,
|
|
187
|
+
)
|
|
188
|
+
this.logger.debug?.(
|
|
189
|
+
`File type: "${fileDoc.type}", assemblyId: "${newAssemblyDoc._id}"`,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
// Add refSeqs
|
|
193
|
+
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
194
|
+
await this.addRefSeqIntoDb(fileDoc, newAssemblyDoc._id.toString(), backend)
|
|
109
195
|
}
|
|
110
196
|
|
|
111
197
|
async executeOnLocalGFF3(_backend: LocalGFF3DataStore) {
|
|
@@ -34,7 +34,7 @@ interface SerializedAddFeatureChangeMultiple
|
|
|
34
34
|
changes: AddFeatureChangeDetails[]
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
type SerializedAddFeatureChange =
|
|
37
|
+
export type SerializedAddFeatureChange =
|
|
38
38
|
| SerializedAddFeatureChangeSingle
|
|
39
39
|
| SerializedAddFeatureChangeMultiple
|
|
40
40
|
|
|
@@ -113,7 +113,6 @@ export class AddFeatureChange extends FeatureChange {
|
|
|
113
113
|
)
|
|
114
114
|
featureCnt++
|
|
115
115
|
} else {
|
|
116
|
-
addedFeature.gffId = _id // User added manually new feature so then gffId = _id
|
|
117
116
|
// Adding new child feature
|
|
118
117
|
if (parentFeatureId) {
|
|
119
118
|
const topLevelFeature = await featureModel
|
|
@@ -158,7 +157,7 @@ export class AddFeatureChange extends FeatureChange {
|
|
|
158
157
|
// Child features should be sorted for click and drag of gene glyphs to work properly
|
|
159
158
|
parentFeature.children = new Map(
|
|
160
159
|
[...parentFeature.children.entries()].sort(
|
|
161
|
-
(a, b) => a[1].
|
|
160
|
+
(a, b) => a[1].min - b[1].min,
|
|
162
161
|
),
|
|
163
162
|
)
|
|
164
163
|
const childIds = this.getChildFeatureIds(addedFeature)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/require-await */
|
|
2
2
|
import {
|
|
3
|
-
AssemblySpecificChange,
|
|
4
3
|
ChangeOptions,
|
|
5
4
|
ClientDataStore,
|
|
6
5
|
LocalGFF3DataStore,
|
|
@@ -9,6 +8,8 @@ import {
|
|
|
9
8
|
} from '@apollo-annotation/common'
|
|
10
9
|
import { GFF3Feature } from '@gmod/gff'
|
|
11
10
|
|
|
11
|
+
import { FromFileBaseChange } from './FromFileBaseChange'
|
|
12
|
+
|
|
12
13
|
export interface SerializedAddFeaturesFromFileChangeBase
|
|
13
14
|
extends SerializedAssemblySpecificChange {
|
|
14
15
|
typeName: 'AddFeaturesFromFileChange'
|
|
@@ -32,7 +33,7 @@ export type SerializedAddFeaturesFromFileChange =
|
|
|
32
33
|
| SerializedAddFeaturesFromFileChangeSingle
|
|
33
34
|
| SerializedAddFeaturesFromFileChangeMultiple
|
|
34
35
|
|
|
35
|
-
export class AddFeaturesFromFileChange extends
|
|
36
|
+
export class AddFeaturesFromFileChange extends FromFileBaseChange {
|
|
36
37
|
typeName = 'AddFeaturesFromFileChange' as const
|
|
37
38
|
changes: AddFeaturesFromFileChangeDetails[]
|
|
38
39
|
deleteExistingFeatures = false
|
|
@@ -91,13 +92,17 @@ export class AddFeaturesFromFileChange extends AssemblySpecificChange {
|
|
|
91
92
|
const featureStream = filesService.parseGFF3(
|
|
92
93
|
filesService.getFileStream(fileDoc),
|
|
93
94
|
)
|
|
95
|
+
let featureCount = 0
|
|
94
96
|
for await (const f of featureStream) {
|
|
95
97
|
const gff3Feature = f as GFF3Feature
|
|
96
|
-
logger.verbose?.(`ENTRY=${JSON.stringify(gff3Feature)}`)
|
|
97
98
|
|
|
98
99
|
// Add new feature into database
|
|
99
100
|
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
|
|
100
101
|
await this.addFeatureIntoDb(gff3Feature, backend)
|
|
102
|
+
featureCount++
|
|
103
|
+
if (featureCount % 1000 === 0) {
|
|
104
|
+
logger.debug?.(`Processed ${featureCount} features`)
|
|
105
|
+
}
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
108
|
logger.debug?.('New features added into database!')
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssemblySpecificChange,
|
|
3
|
+
Change,
|
|
4
|
+
ChangeOptions,
|
|
5
|
+
ClientDataStore,
|
|
6
|
+
LocalGFF3DataStore,
|
|
7
|
+
SerializedAssemblySpecificChange,
|
|
8
|
+
ServerDataStore,
|
|
9
|
+
} from '@apollo-annotation/common'
|
|
10
|
+
import { getSession } from '@jbrowse/core/util'
|
|
11
|
+
|
|
12
|
+
export interface SerializedRefSeqAliases {
|
|
13
|
+
refName: string
|
|
14
|
+
aliases: string[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SerializedRefSeqAliasesChange
|
|
18
|
+
extends SerializedAssemblySpecificChange {
|
|
19
|
+
typeName: 'AddRefSeqAliasesChange'
|
|
20
|
+
refSeqAliases: SerializedRefSeqAliases[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class AddRefSeqAliasesChange extends AssemblySpecificChange {
|
|
24
|
+
typeName = 'AddRefSeqAliasesChange' as const
|
|
25
|
+
refSeqAliases: SerializedRefSeqAliases[]
|
|
26
|
+
|
|
27
|
+
constructor(json: SerializedRefSeqAliasesChange, options?: ChangeOptions) {
|
|
28
|
+
super(json, options)
|
|
29
|
+
this.refSeqAliases = json.refSeqAliases
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
executeOnClient(clientDataStore: ClientDataStore) {
|
|
33
|
+
const { assemblyManager } = getSession(clientDataStore)
|
|
34
|
+
const assembly = assemblyManager.get(this.assembly)
|
|
35
|
+
if (!assembly) {
|
|
36
|
+
throw new Error(`assembly ${this.assembly} not found`)
|
|
37
|
+
}
|
|
38
|
+
const sessionAliases = assembly.refNameAliases
|
|
39
|
+
const sessionLCAliases = assembly.lowerCaseRefNameAliases
|
|
40
|
+
|
|
41
|
+
if (!sessionAliases || !sessionLCAliases) {
|
|
42
|
+
throw new Error('Session refNameAliases not found in assembly')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for (const refSeqAlias of this.refSeqAliases) {
|
|
46
|
+
const { aliases, refName } = refSeqAlias
|
|
47
|
+
for (const alias of aliases) {
|
|
48
|
+
sessionAliases[alias] = refName
|
|
49
|
+
sessionLCAliases[alias.toLowerCase()] = refName
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
assembly.setRefNameAliases(sessionAliases, sessionLCAliases)
|
|
53
|
+
return Promise.resolve()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getInverse(): Change {
|
|
57
|
+
throw new Error('Method not implemented.')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
toJSON(): SerializedRefSeqAliasesChange {
|
|
61
|
+
const { assembly, refSeqAliases, typeName } = this
|
|
62
|
+
return { assembly, typeName, refSeqAliases }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async executeOnServer(backend: ServerDataStore) {
|
|
66
|
+
const { refSeqModel, session } = backend
|
|
67
|
+
const { assembly, logger, refSeqAliases } = this
|
|
68
|
+
|
|
69
|
+
for (const refSeqAlias of refSeqAliases) {
|
|
70
|
+
logger.debug?.(
|
|
71
|
+
`Updating Refname alias for assembly: ${assembly}, refSeqAlias: ${JSON.stringify(refSeqAlias)}`,
|
|
72
|
+
)
|
|
73
|
+
const { aliases, refName } = refSeqAlias
|
|
74
|
+
await refSeqModel
|
|
75
|
+
.updateOne({ assembly, name: refName }, { $set: { aliases } })
|
|
76
|
+
.session(session)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
executeOnLocalGFF3(_backend: LocalGFF3DataStore): Promise<unknown> {
|
|
81
|
+
throw new Error('Method not implemented.')
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/class-literal-property-style
|
|
85
|
+
get notification(): string {
|
|
86
|
+
return 'RefSeq aliases have been added.'
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@apollo-annotation/common'
|
|
12
12
|
import { getSession } from '@jbrowse/core/util'
|
|
13
13
|
|
|
14
|
-
interface SerializedDeleteAssemblyChange
|
|
14
|
+
export interface SerializedDeleteAssemblyChange
|
|
15
15
|
extends SerializedAssemblySpecificChange {
|
|
16
16
|
typeName: 'DeleteAssemblyChange'
|
|
17
17
|
}
|
|
@@ -32,7 +32,7 @@ interface SerializedDeleteFeatureChangeMultiple
|
|
|
32
32
|
changes: DeleteFeatureChangeDetails[]
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
type SerializedDeleteFeatureChange =
|
|
35
|
+
export type SerializedDeleteFeatureChange =
|
|
36
36
|
| SerializedDeleteFeatureChangeSingle
|
|
37
37
|
| SerializedDeleteFeatureChangeMultiple
|
|
38
38
|
|
|
@@ -29,7 +29,7 @@ interface SerializedFeatureAttributeChangeMultiple
|
|
|
29
29
|
changes: FeatureAttributeChangeDetails[]
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
type SerializedFeatureAttributeChange =
|
|
32
|
+
export type SerializedFeatureAttributeChange =
|
|
33
33
|
| SerializedFeatureAttributeChangeSingle
|
|
34
34
|
| SerializedFeatureAttributeChangeMultiple
|
|
35
35
|
|