@apollo-annotation/shared 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +49 -0
- package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +135 -0
- package/src/Changes/AddAssemblyFromExternalChange.ts +145 -0
- package/src/Changes/AddAssemblyFromFileChange.ts +125 -0
- package/src/Changes/AddFeatureChange.ts +233 -0
- package/src/Changes/AddFeaturesFromFileChange.ts +120 -0
- package/src/Changes/DeleteAssemblyChange.ts +100 -0
- package/src/Changes/DeleteFeatureChange.ts +200 -0
- package/src/Changes/DeleteUserChange.ts +83 -0
- package/src/Changes/DiscontinuousLocationEndChange.ts +182 -0
- package/src/Changes/DiscontinuousLocationStartChange.ts +182 -0
- package/src/Changes/FeatureAttributeChange.ts +164 -0
- package/src/Changes/LocationEndChange.ts +175 -0
- package/src/Changes/LocationStartChange.ts +175 -0
- package/src/Changes/StrandChange.ts +159 -0
- package/src/Changes/TypeChange.ts +159 -0
- package/src/Changes/UserChange.ts +82 -0
- package/src/Changes/index.ts +52 -0
- package/src/Checks/CDSCheck.ts +275 -0
- package/src/Checks/index.ts +1 -0
- package/src/Common/index.ts +1 -0
- package/src/Common/jwtPayload.ts +25 -0
- package/src/Messages.ts +32 -0
- package/src/Operations/GetAssembliesOperation.ts +28 -0
- package/src/Operations/GetFeaturesOperation.ts +58 -0
- package/src/Operations/index.ts +6 -0
- package/src/Validations/CoreValidation.ts +37 -0
- package/src/Validations/ParentChildValidation.ts +88 -0
- package/src/Validations/Validation.ts +55 -0
- package/src/Validations/ValidationSet.ts +106 -0
- package/src/Validations/index.ts +4 -0
- package/src/Validations/soSequenceTypes.ts +1865 -0
- package/src/index.ts +7 -0
- package/src/util.ts +109 -0
- package/tsconfig.json +19 -0
package/src/index.ts
ADDED
package/src/util.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
+
import { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
|
|
3
|
+
import { GFF3Feature } from '@gmod/gff'
|
|
4
|
+
|
|
5
|
+
export function makeGFF3Feature(
|
|
6
|
+
feature: AnnotationFeatureSnapshot,
|
|
7
|
+
parentId?: string,
|
|
8
|
+
refSeqNames?: Record<string, string | undefined>,
|
|
9
|
+
): GFF3Feature {
|
|
10
|
+
const locations = feature.discontinuousLocations?.length
|
|
11
|
+
? feature.discontinuousLocations
|
|
12
|
+
: [{ start: feature.start, end: feature.end, phase: feature.phase }]
|
|
13
|
+
const attributes: Record<string, string[] | undefined> = JSON.parse(
|
|
14
|
+
JSON.stringify(feature.attributes),
|
|
15
|
+
)
|
|
16
|
+
const ontologyTerms: string[] = []
|
|
17
|
+
const source = feature.attributes?.source?.[0] ?? null
|
|
18
|
+
delete attributes.source
|
|
19
|
+
if (parentId) {
|
|
20
|
+
attributes.Parent = [parentId]
|
|
21
|
+
}
|
|
22
|
+
if (attributes._id) {
|
|
23
|
+
attributes.ID = attributes._id
|
|
24
|
+
delete attributes._id
|
|
25
|
+
}
|
|
26
|
+
if (attributes.gff_name) {
|
|
27
|
+
attributes.Name = attributes.gff_name
|
|
28
|
+
delete attributes.gff_name
|
|
29
|
+
}
|
|
30
|
+
if (attributes.gff_alias) {
|
|
31
|
+
attributes.Alias = attributes.gff_alias
|
|
32
|
+
delete attributes.gff_alias
|
|
33
|
+
}
|
|
34
|
+
if (attributes.gff_target) {
|
|
35
|
+
attributes.Target = attributes.gff_target
|
|
36
|
+
delete attributes.gff_target
|
|
37
|
+
}
|
|
38
|
+
if (attributes.gff_gap) {
|
|
39
|
+
attributes.Gap = attributes.gff_gap
|
|
40
|
+
delete attributes.gff_gap
|
|
41
|
+
}
|
|
42
|
+
if (attributes.gff_derives_from) {
|
|
43
|
+
attributes.Derives_from = attributes.gff_derives_from
|
|
44
|
+
delete attributes.gff_derives_from
|
|
45
|
+
}
|
|
46
|
+
if (attributes.gff_note) {
|
|
47
|
+
attributes.Note = attributes.gff_note
|
|
48
|
+
delete attributes.gff_note
|
|
49
|
+
}
|
|
50
|
+
if (attributes.gff_dbxref) {
|
|
51
|
+
attributes.Dbxref = attributes.gff_dbxref
|
|
52
|
+
delete attributes.gff_dbxref
|
|
53
|
+
}
|
|
54
|
+
if (attributes.gff_is_circular) {
|
|
55
|
+
attributes.Is_circular = attributes.gff_is_circular
|
|
56
|
+
delete attributes.gff_is_circular
|
|
57
|
+
}
|
|
58
|
+
if (attributes.gff_ontology_term) {
|
|
59
|
+
ontologyTerms.push(...attributes.gff_ontology_term)
|
|
60
|
+
delete attributes.gff_ontology_term
|
|
61
|
+
}
|
|
62
|
+
if (attributes['Gene Ontology']) {
|
|
63
|
+
ontologyTerms.push(...attributes['Gene Ontology'])
|
|
64
|
+
delete attributes['Gene Ontology']
|
|
65
|
+
}
|
|
66
|
+
if (attributes['Sequence Ontology']) {
|
|
67
|
+
ontologyTerms.push(...attributes['Sequence Ontology'])
|
|
68
|
+
delete attributes['Sequence Ontology']
|
|
69
|
+
}
|
|
70
|
+
if (ontologyTerms.length > 0) {
|
|
71
|
+
attributes.Ontology_term = ontologyTerms
|
|
72
|
+
}
|
|
73
|
+
return locations.map((location) => ({
|
|
74
|
+
start: location.start + 1,
|
|
75
|
+
end: location.end,
|
|
76
|
+
seq_id: refSeqNames ? refSeqNames[feature.refSeq] ?? null : feature.refSeq,
|
|
77
|
+
source,
|
|
78
|
+
type: feature.type,
|
|
79
|
+
score: feature.score ?? null,
|
|
80
|
+
strand: feature.strand ? (feature.strand === 1 ? '+' : '-') : null,
|
|
81
|
+
phase:
|
|
82
|
+
location.phase === 0
|
|
83
|
+
? '0'
|
|
84
|
+
: location.phase === 1
|
|
85
|
+
? '1'
|
|
86
|
+
: location.phase === 2
|
|
87
|
+
? '2'
|
|
88
|
+
: null,
|
|
89
|
+
attributes: Object.keys(attributes).length > 0 ? attributes : null,
|
|
90
|
+
derived_features: [],
|
|
91
|
+
child_features: feature.children
|
|
92
|
+
? Object.values(feature.children).map((child) =>
|
|
93
|
+
makeGFF3Feature(child, attributes.ID?.[0], refSeqNames),
|
|
94
|
+
)
|
|
95
|
+
: [],
|
|
96
|
+
}))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function splitStringIntoChunks(
|
|
100
|
+
input: string,
|
|
101
|
+
chunkSize: number,
|
|
102
|
+
): string[] {
|
|
103
|
+
const chunks: string[] = []
|
|
104
|
+
for (let i = 0; i < input.length; i += chunkSize) {
|
|
105
|
+
const chunk = input.slice(i, i + chunkSize)
|
|
106
|
+
chunks.push(chunk)
|
|
107
|
+
}
|
|
108
|
+
return chunks
|
|
109
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"incremental": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"target": "ES2022",
|
|
9
|
+
"lib": ["ES2022", "DOM"],
|
|
10
|
+
"module": "CommonJS",
|
|
11
|
+
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo",
|
|
12
|
+
},
|
|
13
|
+
"include": ["./src"],
|
|
14
|
+
"references": [
|
|
15
|
+
{ "path": "../apollo-mst"},
|
|
16
|
+
{ "path": "../apollo-schemas"},
|
|
17
|
+
{ "path": "../apollo-common"},
|
|
18
|
+
]
|
|
19
|
+
}
|