@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.
Files changed (36) hide show
  1. package/README.md +1 -0
  2. package/package.json +49 -0
  3. package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +135 -0
  4. package/src/Changes/AddAssemblyFromExternalChange.ts +145 -0
  5. package/src/Changes/AddAssemblyFromFileChange.ts +125 -0
  6. package/src/Changes/AddFeatureChange.ts +233 -0
  7. package/src/Changes/AddFeaturesFromFileChange.ts +120 -0
  8. package/src/Changes/DeleteAssemblyChange.ts +100 -0
  9. package/src/Changes/DeleteFeatureChange.ts +200 -0
  10. package/src/Changes/DeleteUserChange.ts +83 -0
  11. package/src/Changes/DiscontinuousLocationEndChange.ts +182 -0
  12. package/src/Changes/DiscontinuousLocationStartChange.ts +182 -0
  13. package/src/Changes/FeatureAttributeChange.ts +164 -0
  14. package/src/Changes/LocationEndChange.ts +175 -0
  15. package/src/Changes/LocationStartChange.ts +175 -0
  16. package/src/Changes/StrandChange.ts +159 -0
  17. package/src/Changes/TypeChange.ts +159 -0
  18. package/src/Changes/UserChange.ts +82 -0
  19. package/src/Changes/index.ts +52 -0
  20. package/src/Checks/CDSCheck.ts +275 -0
  21. package/src/Checks/index.ts +1 -0
  22. package/src/Common/index.ts +1 -0
  23. package/src/Common/jwtPayload.ts +25 -0
  24. package/src/Messages.ts +32 -0
  25. package/src/Operations/GetAssembliesOperation.ts +28 -0
  26. package/src/Operations/GetFeaturesOperation.ts +58 -0
  27. package/src/Operations/index.ts +6 -0
  28. package/src/Validations/CoreValidation.ts +37 -0
  29. package/src/Validations/ParentChildValidation.ts +88 -0
  30. package/src/Validations/Validation.ts +55 -0
  31. package/src/Validations/ValidationSet.ts +106 -0
  32. package/src/Validations/index.ts +4 -0
  33. package/src/Validations/soSequenceTypes.ts +1865 -0
  34. package/src/index.ts +7 -0
  35. package/src/util.ts +109 -0
  36. package/tsconfig.json +19 -0
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './Changes'
2
+ export * from './Operations'
3
+ export * from './Validations'
4
+ export * from './Common'
5
+ export * from './Checks'
6
+ export * from './util'
7
+ export * from './Messages'
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
+ }