@apollo-annotation/common 0.3.9 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo-annotation/common",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/GMOD/Apollo3.git",
@@ -11,13 +11,13 @@
11
11
  "build": "tsc"
12
12
  },
13
13
  "dependencies": {
14
- "@apollo-annotation/schemas": "^0.3.9",
14
+ "@apollo-annotation/schemas": "^0.3.11",
15
15
  "@jbrowse/core": "^3.6.5",
16
16
  "bson-objectid": "^2.0.4",
17
17
  "tslib": "^2.3.1"
18
18
  },
19
19
  "devDependencies": {
20
- "@apollo-annotation/mst": "^0.3.9",
20
+ "@apollo-annotation/mst": "^0.3.11",
21
21
  "@gmod/gff": "^2.0.0",
22
22
  "@nestjs/common": "^10.1.0",
23
23
  "@nestjs/core": "^10.1.0",
@@ -1,4 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
2
+ import { type AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
3
+ import { type Feature } from '@apollo-annotation/schemas'
4
+
2
5
  import {
3
6
  Change,
4
7
  type ChangeOptions,
@@ -26,4 +29,33 @@ export abstract class AssemblySpecificChange extends Change {
26
29
  super(json, options)
27
30
  this.assembly = json.assembly
28
31
  }
32
+
33
+ getIndexedIds(
34
+ feature: AnnotationFeatureSnapshot | Feature,
35
+ idsToIndex: string[] | undefined,
36
+ ): string[] {
37
+ const indexedIds: string[] = []
38
+ for (const additionalId of idsToIndex ?? []) {
39
+ const { attributes } = feature
40
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
41
+ const idValue: string[] =
42
+ attributes instanceof Map
43
+ ? attributes.get(additionalId)
44
+ : attributes?.[additionalId]
45
+ if (idValue) {
46
+ indexedIds.push(idValue[0])
47
+ }
48
+ }
49
+ if (feature.children) {
50
+ const childrenIterable =
51
+ feature.children instanceof Map
52
+ ? feature.children.values()
53
+ : Object.values(feature.children)
54
+ for (const child of childrenIterable) {
55
+ const childIndexedIds = this.getIndexedIds(child, idsToIndex)
56
+ indexedIds.push(...childIndexedIds)
57
+ }
58
+ }
59
+ return indexedIds
60
+ }
29
61
  }