@jbrowse/plugin-config 2.5.0 → 2.6.2

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 (175) hide show
  1. package/dist/ConfigurationEditorWidget/components/BooleanEditor.d.ts +2 -1
  2. package/dist/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
  3. package/dist/ConfigurationEditorWidget/components/CallbackEditor.d.ts +2 -1
  4. package/dist/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
  5. package/dist/ConfigurationEditorWidget/components/ColorEditor.d.ts +3 -2
  6. package/dist/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
  7. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -1
  8. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
  9. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +2 -1
  10. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -1
  11. package/dist/ConfigurationEditorWidget/components/JsonEditor.d.ts +2 -1
  12. package/dist/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
  13. package/dist/ConfigurationEditorWidget/components/NumberEditor.d.ts +2 -1
  14. package/dist/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
  15. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.d.ts +2 -1
  16. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
  17. package/dist/ConfigurationEditorWidget/components/SlotEditor.d.ts +2 -1
  18. package/dist/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
  19. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +2 -1
  20. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
  21. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +2 -1
  22. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
  23. package/dist/ConfigurationEditorWidget/components/TypeSelector.d.ts +1 -1
  24. package/dist/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
  25. package/dist/ConfigurationEditorWidget/index.d.ts +2 -1
  26. package/dist/ConfigurationEditorWidget/index.js +0 -1
  27. package/dist/ConfigurationEditorWidget/model.js +0 -1
  28. package/dist/FromConfigAdapter/FromConfigAdapter.js +0 -1
  29. package/dist/FromConfigAdapter/configSchema.js +0 -1
  30. package/dist/FromConfigAdapter/index.js +0 -1
  31. package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
  32. package/dist/FromConfigRegionsAdapter/configSchema.js +0 -1
  33. package/dist/FromConfigRegionsAdapter/index.js +0 -1
  34. package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
  35. package/dist/FromConfigSequenceAdapter/configSchema.js +0 -1
  36. package/dist/FromConfigSequenceAdapter/index.js +0 -1
  37. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
  38. package/dist/RefNameAliasAdapter/configSchema.js +0 -1
  39. package/dist/RefNameAliasAdapter/index.js +0 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +0 -1
  42. package/esm/ConfigurationEditorWidget/components/BooleanEditor.d.ts +2 -1
  43. package/esm/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
  44. package/esm/ConfigurationEditorWidget/components/CallbackEditor.d.ts +2 -1
  45. package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
  46. package/esm/ConfigurationEditorWidget/components/ColorEditor.d.ts +3 -2
  47. package/esm/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
  48. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -1
  49. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
  50. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +2 -1
  51. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -1
  52. package/esm/ConfigurationEditorWidget/components/JsonEditor.d.ts +2 -1
  53. package/esm/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
  54. package/esm/ConfigurationEditorWidget/components/NumberEditor.d.ts +2 -1
  55. package/esm/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
  56. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.d.ts +2 -1
  57. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
  58. package/esm/ConfigurationEditorWidget/components/SlotEditor.d.ts +2 -1
  59. package/esm/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
  60. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +2 -1
  61. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
  62. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +2 -1
  63. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
  64. package/esm/ConfigurationEditorWidget/components/TypeSelector.d.ts +1 -1
  65. package/esm/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
  66. package/esm/ConfigurationEditorWidget/index.d.ts +2 -1
  67. package/esm/ConfigurationEditorWidget/index.js +0 -1
  68. package/esm/ConfigurationEditorWidget/model.js +0 -1
  69. package/esm/FromConfigAdapter/FromConfigAdapter.js +0 -1
  70. package/esm/FromConfigAdapter/configSchema.js +0 -1
  71. package/esm/FromConfigAdapter/index.js +0 -1
  72. package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
  73. package/esm/FromConfigRegionsAdapter/configSchema.js +0 -1
  74. package/esm/FromConfigRegionsAdapter/index.js +0 -1
  75. package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
  76. package/esm/FromConfigSequenceAdapter/configSchema.js +0 -1
  77. package/esm/FromConfigSequenceAdapter/index.js +0 -1
  78. package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
  79. package/esm/RefNameAliasAdapter/configSchema.js +0 -1
  80. package/esm/RefNameAliasAdapter/index.js +0 -1
  81. package/esm/index.d.ts +1 -1
  82. package/esm/index.js +0 -1
  83. package/package.json +3 -4
  84. package/dist/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
  85. package/dist/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
  86. package/dist/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
  87. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
  88. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
  89. package/dist/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
  90. package/dist/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
  91. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
  92. package/dist/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
  93. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
  94. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
  95. package/dist/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
  96. package/dist/ConfigurationEditorWidget/index.js.map +0 -1
  97. package/dist/ConfigurationEditorWidget/model.js.map +0 -1
  98. package/dist/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
  99. package/dist/FromConfigAdapter/configSchema.js.map +0 -1
  100. package/dist/FromConfigAdapter/index.js.map +0 -1
  101. package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
  102. package/dist/FromConfigRegionsAdapter/configSchema.js.map +0 -1
  103. package/dist/FromConfigRegionsAdapter/index.js.map +0 -1
  104. package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
  105. package/dist/FromConfigSequenceAdapter/configSchema.js.map +0 -1
  106. package/dist/FromConfigSequenceAdapter/index.js.map +0 -1
  107. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
  108. package/dist/RefNameAliasAdapter/configSchema.js.map +0 -1
  109. package/dist/RefNameAliasAdapter/index.js.map +0 -1
  110. package/dist/index.js.map +0 -1
  111. package/esm/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
  112. package/esm/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
  113. package/esm/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
  114. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
  115. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
  116. package/esm/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
  117. package/esm/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
  118. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
  119. package/esm/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
  120. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
  121. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
  122. package/esm/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
  123. package/esm/ConfigurationEditorWidget/index.js.map +0 -1
  124. package/esm/ConfigurationEditorWidget/model.js.map +0 -1
  125. package/esm/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
  126. package/esm/FromConfigAdapter/configSchema.js.map +0 -1
  127. package/esm/FromConfigAdapter/index.js.map +0 -1
  128. package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
  129. package/esm/FromConfigRegionsAdapter/configSchema.js.map +0 -1
  130. package/esm/FromConfigRegionsAdapter/index.js.map +0 -1
  131. package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
  132. package/esm/FromConfigSequenceAdapter/configSchema.js.map +0 -1
  133. package/esm/FromConfigSequenceAdapter/index.js.map +0 -1
  134. package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
  135. package/esm/RefNameAliasAdapter/configSchema.js.map +0 -1
  136. package/esm/RefNameAliasAdapter/index.js.map +0 -1
  137. package/esm/index.js.map +0 -1
  138. package/src/ConfigurationEditorWidget/components/BooleanEditor.tsx +0 -35
  139. package/src/ConfigurationEditorWidget/components/CallbackEditor.tsx +0 -126
  140. package/src/ConfigurationEditorWidget/components/ColorEditor.test.tsx +0 -14
  141. package/src/ConfigurationEditorWidget/components/ColorEditor.tsx +0 -59
  142. package/src/ConfigurationEditorWidget/components/ConfigurationEditor.test.tsx +0 -95
  143. package/src/ConfigurationEditorWidget/components/ConfigurationEditor.tsx +0 -167
  144. package/src/ConfigurationEditorWidget/components/ConfigurationTextField.tsx +0 -22
  145. package/src/ConfigurationEditorWidget/components/JsonEditor.tsx +0 -84
  146. package/src/ConfigurationEditorWidget/components/NumberEditor.tsx +0 -34
  147. package/src/ConfigurationEditorWidget/components/NumberMapEditor.tsx +0 -94
  148. package/src/ConfigurationEditorWidget/components/SlotEditor.tsx +0 -236
  149. package/src/ConfigurationEditorWidget/components/StringArrayEditor.tsx +0 -112
  150. package/src/ConfigurationEditorWidget/components/StringArrayMapEditor.tsx +0 -104
  151. package/src/ConfigurationEditorWidget/components/TypeSelector.tsx +0 -43
  152. package/src/ConfigurationEditorWidget/components/__snapshots__/ConfigurationEditor.test.tsx.snap +0 -2079
  153. package/src/ConfigurationEditorWidget/index.tsx +0 -25
  154. package/src/ConfigurationEditorWidget/model.ts +0 -21
  155. package/src/FromConfigAdapter/FromConfigAdapter.test.ts +0 -56
  156. package/src/FromConfigAdapter/FromConfigAdapter.ts +0 -90
  157. package/src/FromConfigAdapter/configSchema.ts +0 -22
  158. package/src/FromConfigAdapter/index.ts +0 -18
  159. package/src/FromConfigAdapter/test_data/volvox.2bit +0 -0
  160. package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.test.ts +0 -58
  161. package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.ts +0 -81
  162. package/src/FromConfigRegionsAdapter/configSchema.ts +0 -24
  163. package/src/FromConfigRegionsAdapter/index.ts +0 -18
  164. package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.test.ts +0 -64
  165. package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.ts +0 -86
  166. package/src/FromConfigSequenceAdapter/configSchema.ts +0 -21
  167. package/src/FromConfigSequenceAdapter/index.ts +0 -19
  168. package/src/RefNameAliasAdapter/RefNameAliasAdapter.test.ts +0 -18
  169. package/src/RefNameAliasAdapter/RefNameAliasAdapter.ts +0 -30
  170. package/src/RefNameAliasAdapter/configSchema.ts +0 -36
  171. package/src/RefNameAliasAdapter/index.ts +0 -19
  172. package/src/RefNameAliasAdapter/test_data/simple_alias.txt +0 -2
  173. package/src/__snapshots__/index.test.ts.snap +0 -10
  174. package/src/index.test.ts +0 -38
  175. package/src/index.ts +0 -42
@@ -1,25 +0,0 @@
1
- import React from 'react'
2
- import { observer } from 'mobx-react'
3
- import { isStateTreeNode, getType } from 'mobx-state-tree'
4
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
5
-
6
- export { default as stateModelFactory } from './model'
7
- export const configSchema = ConfigurationSchema('ConfigurationEditorWidget', {})
8
- export const HeadingComponent = observer(
9
- ({ model }: { model?: { target: { type: string } } }) => {
10
- if (model?.target) {
11
- if (model.target.type) {
12
- return <>{`${model.target.type} settings`}</>
13
- }
14
- if (isStateTreeNode(model.target)) {
15
- const type = getType(model.target)
16
- if (type?.name) {
17
- return (
18
- <>{`${type.name.replace('ConfigurationSchema', '')} settings`}</>
19
- )
20
- }
21
- }
22
- }
23
- return <>Settings</>
24
- },
25
- )
@@ -1,21 +0,0 @@
1
- import { types } from 'mobx-state-tree'
2
- import { ElementId } from '@jbrowse/core/util/types/mst'
3
- import PluginManager from '@jbrowse/core/PluginManager'
4
-
5
- export default (pluginManager: PluginManager) =>
6
- types
7
- .model('ConfigurationEditorWidget', {
8
- id: ElementId,
9
- type: types.literal('ConfigurationEditorWidget'),
10
- // If you add different types of targets, don't forget to account for that
11
- // in the key of ./components/ConfigurationEditor.js
12
- target: types.safeReference(
13
- pluginManager.pluggableConfigSchemaType('track'),
14
- ),
15
- })
16
- .actions(self => ({
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- setTarget(newTarget: any) {
19
- self.target = newTarget
20
- },
21
- }))
@@ -1,56 +0,0 @@
1
- import { toArray } from 'rxjs/operators'
2
- import { firstValueFrom } from 'rxjs'
3
- import Adapter from './FromConfigAdapter'
4
- import configSchema from './configSchema'
5
-
6
- test('adapter can fetch features', async () => {
7
- const features = [
8
- { uniqueId: 'one', refName: 'ctgA', start: 20, end: 40 },
9
- { uniqueId: 'two', refName: 'ctgB', start: 50, end: 60 },
10
- ]
11
- const adapter = new Adapter(configSchema.create({ features }))
12
- const result = adapter.getFeatures({
13
- refName: 'ctgA',
14
- start: 0,
15
- end: 20000,
16
- })
17
-
18
- const featuresArray = await firstValueFrom(result.pipe(toArray()))
19
- expect(featuresArray.length).toBe(1)
20
- expect(featuresArray[0].toJSON()).toEqual(features[0])
21
- })
22
-
23
- test('adapter can fetch features with subfeatures', async () => {
24
- const features = [
25
- {
26
- refName: 'ctgA',
27
- uniqueId: 'feat1',
28
- start: 200,
29
- end: 750,
30
- name: 'Feature1',
31
- subfeatures: [
32
- {
33
- uniqueId: 'feat2',
34
- start: 225,
35
- end: 300,
36
- name: 'Feature2',
37
- },
38
- {
39
- uniqueId: 'feat3',
40
- start: 400,
41
- end: 600,
42
- name: 'Feature3',
43
- },
44
- ],
45
- },
46
- ]
47
- const adapter = new Adapter(configSchema.create({ features }))
48
- const result = adapter.getFeatures({
49
- refName: 'ctgA',
50
- start: 0,
51
- end: 20000,
52
- })
53
-
54
- const featuresArray = await firstValueFrom(result.pipe(toArray()))
55
- expect(featuresArray.length).toBe(1)
56
- })
@@ -1,90 +0,0 @@
1
- import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
2
- import SimpleFeature, {
3
- Feature,
4
- SimpleFeatureSerialized,
5
- } from '@jbrowse/core/util/simpleFeature'
6
- import { ObservableCreate } from '@jbrowse/core/util/rxjs'
7
- import { NoAssemblyRegion } from '@jbrowse/core/util/types'
8
- import {
9
- AnyConfigurationModel,
10
- readConfObject,
11
- } from '@jbrowse/core/configuration'
12
- import PluginManager from '@jbrowse/core/PluginManager'
13
- import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
14
-
15
- /**
16
- * Adapter that just returns the features defined in its `features` configuration
17
- * key, like:
18
- * `"features": [ { "refName": "ctgA", "start":1, "end":20 }, ... ]`
19
- */
20
-
21
- export default class FromConfigAdapter extends BaseFeatureDataAdapter {
22
- protected features: Map<string, Feature[]>
23
-
24
- constructor(
25
- conf: AnyConfigurationModel,
26
- getSubAdapter?: getSubAdapterType,
27
- pluginManager?: PluginManager,
28
- ) {
29
- super(conf, getSubAdapter, pluginManager)
30
- const feats = readConfObject(conf, 'features') as SimpleFeatureSerialized[]
31
- this.features = FromConfigAdapter.makeFeatures(feats || [])
32
- }
33
-
34
- static makeFeatures(fdata: SimpleFeatureSerialized[]) {
35
- const features = new Map<string, Feature[]>()
36
- for (let i = 0; i < fdata.length; i += 1) {
37
- if (fdata[i]) {
38
- const f = this.makeFeature(fdata[i])
39
- const refName = f.get('refName') as string
40
- let bucket = features.get(refName)
41
- if (!bucket) {
42
- bucket = []
43
- features.set(refName, bucket)
44
- }
45
-
46
- bucket.push(f)
47
- }
48
- }
49
-
50
- // sort the features on each reference sequence by start coordinate
51
- for (const refFeatures of features.values()) {
52
- refFeatures.sort((a, b) => a.get('start') - b.get('start'))
53
- }
54
-
55
- return features
56
- }
57
-
58
- static makeFeature(data: SimpleFeatureSerialized) {
59
- return new SimpleFeature(data)
60
- }
61
-
62
- async getRefNames() {
63
- return [...this.features.keys()]
64
- }
65
-
66
- async getRefNameAliases() {
67
- return [...this.features.values()].map(featureArray => ({
68
- refName: featureArray[0].get('refName'),
69
- aliases: featureArray[0].get('aliases'),
70
- }))
71
- }
72
-
73
- getFeatures(region: NoAssemblyRegion) {
74
- const { refName, start, end } = region
75
-
76
- return ObservableCreate<Feature>(async observer => {
77
- const features = this.features.get(refName) || []
78
- for (let i = 0; i < features.length; i++) {
79
- const f = features[i]
80
-
81
- if (f.get('end') > start && f.get('start') < end) {
82
- observer.next(f)
83
- }
84
- }
85
- observer.complete()
86
- })
87
- }
88
-
89
- freeResources(/* { region } */): void {}
90
- }
@@ -1,22 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
-
3
- /**
4
- * #config FromConfigAdapter
5
- */
6
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
7
-
8
- const configSchema = ConfigurationSchema(
9
- 'FromConfigAdapter',
10
- {
11
- /**
12
- * #slot
13
- */
14
- features: {
15
- type: 'frozen',
16
- defaultValue: [],
17
- },
18
- },
19
- { explicitlyTyped: true, implicitIdentifier: 'adapterId' },
20
- )
21
-
22
- export default configSchema
@@ -1,18 +0,0 @@
1
- import { AdapterType } from '@jbrowse/core/pluggableElementTypes'
2
- import PluginManager from '@jbrowse/core/PluginManager'
3
- import configSchema from './configSchema'
4
-
5
- export default (pluginManager: PluginManager) => {
6
- pluginManager.addAdapterType(
7
- () =>
8
- new AdapterType({
9
- name: 'FromConfigAdapter',
10
- configSchema,
11
- getAdapterClass: () =>
12
- import('./FromConfigAdapter').then(r => r.default),
13
- adapterMetadata: {
14
- hiddenFromGUI: true,
15
- },
16
- }),
17
- )
18
- }
@@ -1,58 +0,0 @@
1
- import Adapter from './FromConfigRegionsAdapter'
2
- import regionsConfigSchema from './configSchema'
3
-
4
- test('adapter can fetch regions 1', async () => {
5
- const features = [
6
- { uniqueId: 'one', refName: 'ctgA', start: 250, end: 400 },
7
- { uniqueId: 'two', refName: 'ctgA', start: 150, end: 300 },
8
- { uniqueId: 'three', refName: 'ctgB', start: 50, end: 60 },
9
- ]
10
- const adapter = new Adapter(regionsConfigSchema.create({ features }))
11
- const result = await adapter.getRegions()
12
- expect(result).toEqual([
13
- { refName: 'ctgA', start: 150, end: 400 },
14
- { refName: 'ctgB', start: 50, end: 60 },
15
- ])
16
- })
17
-
18
- test('adapter can fetch regions 2', async () => {
19
- const features = [
20
- { uniqueId: 'three', refName: 'ctgB', start: 50, end: 60 },
21
- { uniqueId: 'two', refName: 'ctgA', start: 150, end: 300 },
22
- { uniqueId: 'one', refName: 'ctgA', start: 250, end: 400 },
23
- ]
24
- const adapter = new Adapter(regionsConfigSchema.create({ features }))
25
- const result = await adapter.getRegions()
26
- expect(result).toEqual([
27
- { refName: 'ctgA', start: 150, end: 400 },
28
- { refName: 'ctgB', start: 50, end: 60 },
29
- ])
30
- })
31
-
32
- test('adapter can fetch regions 3', async () => {
33
- const features = [
34
- { uniqueId: 'two', refName: 'ctgA', start: 150, end: 300 },
35
- { uniqueId: 'one', refName: 'ctgA', start: 250, end: 400 },
36
- { uniqueId: 'three', refName: 'ctgB', start: 50, end: 60 },
37
- ]
38
- const adapter = new Adapter(regionsConfigSchema.create({ features }))
39
- const result = await adapter.getRegions()
40
- expect(result).toEqual([
41
- { refName: 'ctgA', start: 150, end: 400 },
42
- { refName: 'ctgB', start: 50, end: 60 },
43
- ])
44
- })
45
-
46
- test('adapter can fetch regions 4', async () => {
47
- const features = [
48
- { uniqueId: 'two', refName: 'ctgA', start: 150, end: 300 },
49
- { uniqueId: 'onePrime', refName: 'ctgA', start: 300, end: 400 },
50
- { uniqueId: 'three', refName: 'ctgB', start: 50, end: 60 },
51
- ]
52
- const adapter = new Adapter(regionsConfigSchema.create({ features }))
53
- const result = await adapter.getRegions()
54
- expect(result).toEqual([
55
- { refName: 'ctgA', start: 150, end: 400 },
56
- { refName: 'ctgB', start: 50, end: 60 },
57
- ])
58
- })
@@ -1,81 +0,0 @@
1
- import {
2
- BaseAdapter,
3
- RegionsAdapter,
4
- } from '@jbrowse/core/data_adapters/BaseAdapter'
5
- import {
6
- Feature,
7
- SimpleFeatureSerialized,
8
- } from '@jbrowse/core/util/simpleFeature'
9
- import {
10
- AnyConfigurationModel,
11
- readConfObject,
12
- } from '@jbrowse/core/configuration'
13
- import PluginManager from '@jbrowse/core/PluginManager'
14
- import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
15
-
16
- import FromConfigAdapter from '../FromConfigAdapter/FromConfigAdapter'
17
-
18
- /**
19
- * Adapter that just returns the features defined in its `features` configuration
20
- * key, like:
21
- * `"features": [ { "refName": "ctgA", "start":1, "end":20 }, ... ]`
22
- */
23
- export default class FromConfigRegionsAdapter
24
- extends BaseAdapter
25
- implements RegionsAdapter
26
- {
27
- private features: Map<string, Feature[]>
28
-
29
- constructor(
30
- config: AnyConfigurationModel,
31
- getSubAdapter?: getSubAdapterType,
32
- pluginManager?: PluginManager,
33
- ) {
34
- super(config, getSubAdapter, pluginManager)
35
- const features = readConfObject(
36
- config,
37
- 'features',
38
- ) as SimpleFeatureSerialized[]
39
- this.features = FromConfigAdapter.makeFeatures(features || [])
40
- }
41
-
42
- /**
43
- * Get refName, start, and end for all features after collapsing any overlaps
44
- */
45
- async getRegions() {
46
- const regions = []
47
-
48
- // recall: features are stored in this object sorted by start coordinate
49
- for (const [refName, features] of this.features) {
50
- let currentRegion
51
- for (const feature of features) {
52
- if (
53
- currentRegion &&
54
- currentRegion.end >= feature.get('start') &&
55
- currentRegion.start <= feature.get('end')
56
- ) {
57
- currentRegion.end = feature.get('end')
58
- } else {
59
- if (currentRegion) {
60
- regions.push(currentRegion)
61
- }
62
- currentRegion = {
63
- refName,
64
- start: feature.get('start'),
65
- end: feature.get('end'),
66
- }
67
- }
68
- }
69
- if (currentRegion) {
70
- regions.push(currentRegion)
71
- }
72
- }
73
-
74
- // sort the regions by refName
75
- regions.sort((a, b) => a.refName.localeCompare(b.refName))
76
-
77
- return regions
78
- }
79
-
80
- freeResources(/* { region } */): void {}
81
- }
@@ -1,24 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
- /**
3
- * #config FromConfigRegionsAdapter
4
- * used for specifying refNames+sizes of an assembly
5
- */
6
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
7
-
8
- const regionsConfigSchema = ConfigurationSchema(
9
- 'FromConfigRegionsAdapter',
10
- {
11
- /**
12
- * #slot
13
- */
14
- features: {
15
- type: 'frozen',
16
- defaultValue: [],
17
- },
18
- },
19
- {
20
- explicitlyTyped: true,
21
- implicitIdentifier: 'adapterId',
22
- },
23
- )
24
- export default regionsConfigSchema
@@ -1,18 +0,0 @@
1
- import { AdapterType } from '@jbrowse/core/pluggableElementTypes'
2
- import PluginManager from '@jbrowse/core/PluginManager'
3
- import configSchema from './configSchema'
4
-
5
- export default (pluginManager: PluginManager) => {
6
- pluginManager.addAdapterType(
7
- () =>
8
- new AdapterType({
9
- name: 'FromConfigRegionsAdapter',
10
- configSchema,
11
- getAdapterClass: () =>
12
- import('./FromConfigRegionsAdapter').then(r => r.default),
13
- adapterMetadata: {
14
- hiddenFromGUI: true,
15
- },
16
- }),
17
- )
18
- }
@@ -1,64 +0,0 @@
1
- import { toArray } from 'rxjs/operators'
2
- import { firstValueFrom } from 'rxjs'
3
- import Adapter from './FromConfigSequenceAdapter'
4
- import sequenceConfigSchema from './configSchema'
5
-
6
- test('adapter can fetch sequences when there is just one feature representing whole refseq', async () => {
7
- const features = [
8
- {
9
- uniqueId: 'one',
10
- refName: 'ctgA',
11
- start: 0,
12
- end: 150,
13
- seq: 'ccaaaccgtcaattaaccggtatcttctcggaaacggcggttctctcctagatagcgatctgtggtctcaccatgcaatttaaacaggtgagtaaagattgctacaaatacgagactagctgtcaccagatgctgttcatctgttggctc',
14
- },
15
- ]
16
- const adapter = new Adapter(sequenceConfigSchema.create({ features }))
17
- const result = adapter.getFeatures({
18
- refName: 'ctgA',
19
- start: 0,
20
- end: 50,
21
- })
22
- const featuresArray = await firstValueFrom(result.pipe(toArray()))
23
- expect(featuresArray.length).toBe(1)
24
- expect(featuresArray[0].get('seq')).toBe(features[0].seq.slice(0, 50))
25
-
26
- const result2 = adapter.getFeatures({
27
- refName: 'ctgA',
28
- start: 100,
29
- end: 150,
30
- })
31
- const featuresArray2 = await firstValueFrom(result2.pipe(toArray()))
32
- expect(featuresArray2.length).toBe(1)
33
- expect(featuresArray2[0].get('seq')).toBe(features[0].seq.slice(100, 150))
34
- })
35
-
36
- test("adapter can fetch sequences when the config's sequence doesn't start at 0", async () => {
37
- const features = [
38
- {
39
- uniqueId: 'one',
40
- refName: 'ctgA',
41
- start: 5000,
42
- end: 5150,
43
- seq: 'ccaaaccgtcaattaaccggtatcttctcggaaacggcggttctctcctagatagcgatctgtggtctcaccatgcaatttaaacaggtgagtaaagattgctacaaatacgagactagctgtcaccagatgctgttcatctgttggctc',
44
- },
45
- ]
46
- const adapter = new Adapter(sequenceConfigSchema.create({ features }))
47
- const result = adapter.getFeatures({
48
- refName: 'ctgA',
49
- start: 4950,
50
- end: 5050,
51
- })
52
- const featuresArray = await firstValueFrom(result.pipe(toArray()))
53
- expect(featuresArray.length).toBe(1)
54
- expect(featuresArray[0].get('seq')).toBe(features[0].seq.slice(0, 50))
55
-
56
- const result2 = adapter.getFeatures({
57
- refName: 'ctgA',
58
- start: 5050,
59
- end: 5150,
60
- })
61
- const featuresArray2 = await firstValueFrom(result2.pipe(toArray()))
62
- expect(featuresArray2.length).toBe(1)
63
- expect(featuresArray2[0].get('seq')).toBe(features[0].seq.slice(50, 150))
64
- })
@@ -1,86 +0,0 @@
1
- import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
2
- import { ObservableCreate } from '@jbrowse/core/util/rxjs'
3
- import { NoAssemblyRegion } from '@jbrowse/core/util/types'
4
- import { toArray } from 'rxjs/operators'
5
- import { RegionsAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
6
-
7
- // locals
8
- import FromConfigAdapter from '../FromConfigAdapter/FromConfigAdapter'
9
- import { firstValueFrom } from 'rxjs'
10
-
11
- export default class FromConfigSequenceAdapter
12
- extends FromConfigAdapter
13
- implements RegionsAdapter
14
- {
15
- /**
16
- * Fetch features for a certain region
17
- * @param region - Region
18
- * @returns Observable of Feature objects in the region
19
- */
20
- getFeatures(region: NoAssemblyRegion) {
21
- return ObservableCreate<Feature>(async observer => {
22
- const feats = await firstValueFrom(
23
- super.getFeatures(region).pipe(toArray()),
24
- )
25
- const feat = feats[0]
26
- observer.next(
27
- new SimpleFeature({
28
- ...feat.toJSON(),
29
- uniqueId: `${feat.id()}:${region.start}-${region.end}`,
30
- end: region.end,
31
- start: region.start,
32
- seq: feat
33
- .get('seq')
34
- .slice(
35
- Math.max(region.start - feat.get('start'), 0),
36
- Math.max(region.end - feat.get('start'), 0),
37
- ),
38
- }),
39
- )
40
-
41
- observer.complete()
42
- })
43
- }
44
-
45
- /**
46
- * Get refName, start, and end for all features after collapsing any overlaps
47
- */
48
- async getRegions() {
49
- const regions = []
50
-
51
- // recall: features are stored in this object sorted by start coordinate
52
- for (const [refName, features] of this.features) {
53
- let currentRegion
54
- for (const feature of features) {
55
- if (
56
- currentRegion &&
57
- currentRegion.end >= feature.get('start') &&
58
- currentRegion.start <= feature.get('end')
59
- ) {
60
- currentRegion.end = feature.get('end')
61
- } else {
62
- if (currentRegion) {
63
- regions.push(currentRegion)
64
- }
65
- currentRegion = {
66
- refName,
67
- start: feature.get('start'),
68
- end: feature.get('end'),
69
- }
70
- }
71
- }
72
- if (currentRegion) {
73
- regions.push(currentRegion)
74
- }
75
- }
76
-
77
- return regions
78
- }
79
-
80
- /**
81
- * called to provide a hint that data tied to a certain region
82
- * will not be needed for the foreseeable future and can be purged
83
- * from caches, etc
84
- */
85
- freeResources(/* { region } */): void {}
86
- }
@@ -1,21 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
- /**
3
- * #config FromConfigSequenceAdapter
4
- */
5
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
6
-
7
- const sequenceConfigSchema = ConfigurationSchema(
8
- 'FromConfigSequenceAdapter',
9
- {
10
- /**
11
- * #slot
12
- */
13
- features: {
14
- type: 'frozen',
15
- defaultValue: [],
16
- },
17
- },
18
- { explicitlyTyped: true, implicitIdentifier: 'adapterId' },
19
- )
20
-
21
- export default sequenceConfigSchema
@@ -1,19 +0,0 @@
1
- import { AdapterType } from '@jbrowse/core/pluggableElementTypes'
2
- import PluginManager from '@jbrowse/core/PluginManager'
3
-
4
- import configSchema from './configSchema'
5
-
6
- export default (pluginManager: PluginManager) => {
7
- pluginManager.addAdapterType(
8
- () =>
9
- new AdapterType({
10
- name: 'FromConfigSequenceAdapter',
11
- configSchema,
12
- getAdapterClass: () =>
13
- import('./FromConfigSequenceAdapter').then(r => r.default),
14
- adapterMetadata: {
15
- hiddenFromGUI: true,
16
- },
17
- }),
18
- )
19
- }
@@ -1,18 +0,0 @@
1
- import Adapter from './RefNameAliasAdapter'
2
- import configSchema from './configSchema'
3
-
4
- test('adapter can fetch a simple alias file', async () => {
5
- const adapter = new Adapter(
6
- configSchema.create({
7
- location: {
8
- localPath: require.resolve('./test_data/simple_alias.txt'),
9
- locationType: 'LocalPathLocation',
10
- },
11
- }),
12
- )
13
- const result = await adapter.getRefNameAliases()
14
- expect(result[0].refName).toBe('chr1')
15
- expect(result[0].aliases).toEqual(['1', 'NC_000001.10'])
16
- expect(result[1].refName).toBe('chr2')
17
- expect(result[1].aliases).toEqual(['2', 'NC_000002.11'])
18
- })
@@ -1,30 +0,0 @@
1
- import {
2
- BaseRefNameAliasAdapter,
3
- BaseAdapter,
4
- } from '@jbrowse/core/data_adapters/BaseAdapter'
5
- import { openLocation } from '@jbrowse/core/util/io'
6
-
7
- export default class RefNameAliasAdapter
8
- extends BaseAdapter
9
- implements BaseRefNameAliasAdapter
10
- {
11
- async getRefNameAliases() {
12
- const loc = this.getConf('location')
13
- if (loc.uri === '' || loc.uri === '/path/to/my/aliases.txt') {
14
- return []
15
- }
16
- const results = await openLocation(loc, this.pluginManager).readFile('utf8')
17
- const refColumn = this.getConf('refNameColumn')
18
- return results
19
- .trim()
20
- .split(/\n|\r\n|\r/)
21
- .filter(f => !!f && !f.startsWith('#'))
22
- .map(row => {
23
- const aliases = row.split('\t')
24
- const [refName] = aliases.splice(refColumn, 1)
25
- return { refName, aliases: aliases.filter(f => !!f.trim()) }
26
- })
27
- }
28
-
29
- async freeResources() {}
30
- }