@jbrowse/plugin-bed 2.17.0 → 3.0.0

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 (95) hide show
  1. package/dist/BedAdapter/BedAdapter.d.ts +15 -5
  2. package/dist/BedAdapter/BedAdapter.js +7 -10
  3. package/dist/BedAdapter/configSchema.d.ts +0 -21
  4. package/dist/BedAdapter/configSchema.js +1 -25
  5. package/dist/BedAdapter/index.d.ts +1 -1
  6. package/dist/BedAdapter/index.js +17 -7
  7. package/dist/BedGraphAdapter/BedGraphAdapter.d.ts +24 -0
  8. package/dist/BedGraphAdapter/BedGraphAdapter.js +130 -0
  9. package/dist/BedGraphAdapter/configSchema.d.ts +15 -0
  10. package/dist/BedGraphAdapter/configSchema.js +19 -0
  11. package/dist/BedGraphAdapter/index.d.ts +2 -0
  12. package/dist/BedGraphAdapter/index.js +49 -0
  13. package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +18 -0
  14. package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.js +108 -0
  15. package/dist/BedGraphTabixAdapter/configSchema.d.ts +29 -0
  16. package/dist/BedGraphTabixAdapter/configSchema.js +34 -0
  17. package/dist/BedGraphTabixAdapter/index.d.ts +2 -0
  18. package/dist/BedGraphTabixAdapter/index.js +49 -0
  19. package/dist/BedTabixAdapter/BedTabixAdapter.d.ts +6 -5
  20. package/dist/BedTabixAdapter/BedTabixAdapter.js +12 -5
  21. package/dist/BedTabixAdapter/configSchema.d.ts +0 -18
  22. package/dist/BedTabixAdapter/configSchema.js +1 -22
  23. package/dist/BedTabixAdapter/index.d.ts +1 -1
  24. package/dist/BedTabixAdapter/index.js +17 -7
  25. package/dist/BedpeAdapter/BedpeAdapter.d.ts +3 -3
  26. package/dist/BedpeAdapter/BedpeAdapter.js +7 -64
  27. package/dist/BedpeAdapter/configSchema.d.ts +0 -7
  28. package/dist/BedpeAdapter/configSchema.js +1 -12
  29. package/dist/BedpeAdapter/index.d.ts +1 -1
  30. package/dist/BedpeAdapter/index.js +17 -7
  31. package/dist/BedpeAdapter/util.d.ts +2 -0
  32. package/dist/BedpeAdapter/util.js +55 -0
  33. package/dist/BigBedAdapter/BigBedAdapter.d.ts +5 -4
  34. package/dist/BigBedAdapter/BigBedAdapter.js +13 -8
  35. package/dist/BigBedAdapter/configSchema.d.ts +0 -9
  36. package/dist/BigBedAdapter/configSchema.js +2 -14
  37. package/dist/BigBedAdapter/index.d.ts +1 -1
  38. package/dist/BigBedAdapter/index.js +17 -7
  39. package/dist/GuessAdapter/index.d.ts +2 -0
  40. package/dist/GuessAdapter/index.js +68 -0
  41. package/dist/generateBedMethylFeature.d.ts +3 -3
  42. package/dist/generateBedMethylFeature.js +6 -6
  43. package/dist/generateRepeatMaskerFeature.js +2 -1
  44. package/dist/generateUcscTranscript.d.ts +1 -1
  45. package/dist/generateUcscTranscript.js +4 -6
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.js +9 -72
  48. package/dist/util.d.ts +171 -6
  49. package/dist/util.js +65 -61
  50. package/esm/BedAdapter/BedAdapter.d.ts +15 -5
  51. package/esm/BedAdapter/BedAdapter.js +8 -11
  52. package/esm/BedAdapter/configSchema.d.ts +0 -21
  53. package/esm/BedAdapter/configSchema.js +1 -25
  54. package/esm/BedAdapter/index.d.ts +1 -1
  55. package/esm/BedGraphAdapter/BedGraphAdapter.d.ts +24 -0
  56. package/esm/BedGraphAdapter/BedGraphAdapter.js +124 -0
  57. package/esm/BedGraphAdapter/configSchema.d.ts +15 -0
  58. package/esm/BedGraphAdapter/configSchema.js +17 -0
  59. package/esm/BedGraphAdapter/index.d.ts +2 -0
  60. package/esm/BedGraphAdapter/index.js +10 -0
  61. package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +18 -0
  62. package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.js +105 -0
  63. package/esm/BedGraphTabixAdapter/configSchema.d.ts +29 -0
  64. package/esm/BedGraphTabixAdapter/configSchema.js +32 -0
  65. package/esm/BedGraphTabixAdapter/index.d.ts +2 -0
  66. package/esm/BedGraphTabixAdapter/index.js +10 -0
  67. package/esm/BedTabixAdapter/BedTabixAdapter.d.ts +6 -5
  68. package/esm/BedTabixAdapter/BedTabixAdapter.js +13 -6
  69. package/esm/BedTabixAdapter/configSchema.d.ts +0 -18
  70. package/esm/BedTabixAdapter/configSchema.js +1 -22
  71. package/esm/BedTabixAdapter/index.d.ts +1 -1
  72. package/esm/BedpeAdapter/BedpeAdapter.d.ts +3 -3
  73. package/esm/BedpeAdapter/BedpeAdapter.js +6 -62
  74. package/esm/BedpeAdapter/configSchema.d.ts +0 -7
  75. package/esm/BedpeAdapter/configSchema.js +1 -12
  76. package/esm/BedpeAdapter/index.d.ts +1 -1
  77. package/esm/BedpeAdapter/util.d.ts +2 -0
  78. package/esm/BedpeAdapter/util.js +52 -0
  79. package/esm/BigBedAdapter/BigBedAdapter.d.ts +5 -4
  80. package/esm/BigBedAdapter/BigBedAdapter.js +14 -9
  81. package/esm/BigBedAdapter/configSchema.d.ts +0 -9
  82. package/esm/BigBedAdapter/configSchema.js +2 -14
  83. package/esm/BigBedAdapter/index.d.ts +1 -1
  84. package/esm/GuessAdapter/index.d.ts +2 -0
  85. package/esm/GuessAdapter/index.js +65 -0
  86. package/esm/generateBedMethylFeature.d.ts +3 -3
  87. package/esm/generateBedMethylFeature.js +6 -6
  88. package/esm/generateRepeatMaskerFeature.js +2 -1
  89. package/esm/generateUcscTranscript.d.ts +1 -1
  90. package/esm/generateUcscTranscript.js +4 -6
  91. package/esm/index.d.ts +1 -1
  92. package/esm/index.js +9 -72
  93. package/esm/util.d.ts +171 -6
  94. package/esm/util.js +65 -61
  95. package/package.json +5 -5
@@ -0,0 +1,105 @@
1
+ import { TabixIndexedFile } from '@gmod/tabix';
2
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import { SimpleFeature } from '@jbrowse/core/util';
4
+ import { openLocation } from '@jbrowse/core/util/io';
5
+ import { ObservableCreate } from '@jbrowse/core/util/rxjs';
6
+ export default class BedGraphAdapter extends BaseFeatureDataAdapter {
7
+ async configurePre() {
8
+ const pm = this.pluginManager;
9
+ const bedGraphGzLocation = this.getConf('bedGraphGzLocation');
10
+ const location = this.getConf(['index', 'location']);
11
+ const indexType = this.getConf(['index', 'indexType']);
12
+ const filehandle = openLocation(bedGraphGzLocation, pm);
13
+ const isCSI = indexType === 'CSI';
14
+ const bedGraph = new TabixIndexedFile({
15
+ filehandle,
16
+ csiFilehandle: isCSI ? openLocation(location, pm) : undefined,
17
+ tbiFilehandle: !isCSI ? openLocation(location, pm) : undefined,
18
+ chunkCacheSize: 50 * 2 ** 20,
19
+ });
20
+ const columnNames = this.getConf('columnNames');
21
+ const header = await bedGraph.getHeader();
22
+ return {
23
+ columnNames,
24
+ bedGraph,
25
+ header,
26
+ };
27
+ }
28
+ async configure() {
29
+ if (!this.configured) {
30
+ this.configured = this.configurePre().catch((e) => {
31
+ this.configured = undefined;
32
+ throw e;
33
+ });
34
+ }
35
+ return this.configured;
36
+ }
37
+ async getNames() {
38
+ const { bedGraph, columnNames } = await this.configure();
39
+ if (columnNames.length) {
40
+ return columnNames;
41
+ }
42
+ const header = await bedGraph.getHeader();
43
+ const defs = header.split(/\n|\r\n|\r/).filter(f => !!f);
44
+ const defline = defs.at(-1);
45
+ return (defline === null || defline === void 0 ? void 0 : defline.includes('\t'))
46
+ ? defline
47
+ .slice(1)
48
+ .split('\t')
49
+ .map(f => f.trim())
50
+ : undefined;
51
+ }
52
+ async getRefNames(opts = {}) {
53
+ const { bedGraph } = await this.configure();
54
+ return bedGraph.getReferenceSequenceNames(opts);
55
+ }
56
+ async getHeader() {
57
+ const { bedGraph } = await this.configure();
58
+ return bedGraph.getHeader();
59
+ }
60
+ getFeatures(query, opts = {}) {
61
+ return ObservableCreate(async (observer) => {
62
+ var _a;
63
+ const { bedGraph } = await this.configure();
64
+ const meta = await bedGraph.getMetadata();
65
+ const { columnNumbers } = meta;
66
+ const colRef = columnNumbers.ref - 1;
67
+ const colStart = columnNumbers.start - 1;
68
+ const colEnd = columnNumbers.end - 1;
69
+ const same = colStart === colEnd;
70
+ const names = ((_a = (await this.getNames())) === null || _a === void 0 ? void 0 : _a.slice(same ? 2 : 3)) || [];
71
+ await bedGraph.getLines(query.refName, query.start + (same ? -1 : 0), query.end, {
72
+ lineCallback: (line, fileOffset) => {
73
+ const cols = line.split('\t');
74
+ const refName = cols[colRef];
75
+ const start = +cols[colStart];
76
+ const end = +(same ? start + 1 : cols[colEnd]);
77
+ const rest = cols.slice(colEnd + 1);
78
+ if (Number.isNaN(start) || Number.isNaN(end)) {
79
+ throw new Error(`start/end NaN on line "${line}", with colStart:${colStart} and colEnd:${colEnd}. run "tabix -p bed" to ensure bed preset`);
80
+ }
81
+ for (let j = 0; j < rest.length; j++) {
82
+ const uniqueId = `${this.id}-${fileOffset}-${j}`;
83
+ const score = Math.abs(+rest[j]);
84
+ const source = names[j] || `col${j}`;
85
+ if (score) {
86
+ observer.next(new SimpleFeature({
87
+ id: uniqueId,
88
+ data: {
89
+ refName,
90
+ start,
91
+ end,
92
+ score,
93
+ source,
94
+ },
95
+ }));
96
+ }
97
+ }
98
+ },
99
+ ...opts,
100
+ });
101
+ observer.complete();
102
+ });
103
+ }
104
+ freeResources() { }
105
+ }
@@ -0,0 +1,29 @@
1
+ declare const BedGraphTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
+ bedGraphGzLocation: {
3
+ type: string;
4
+ defaultValue: {
5
+ uri: string;
6
+ locationType: string;
7
+ };
8
+ };
9
+ index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
10
+ indexType: {
11
+ model: import("mobx-state-tree").ISimpleType<string>;
12
+ type: string;
13
+ defaultValue: string;
14
+ };
15
+ location: {
16
+ type: string;
17
+ defaultValue: {
18
+ uri: string;
19
+ locationType: string;
20
+ };
21
+ };
22
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
23
+ columnNames: {
24
+ type: string;
25
+ description: string;
26
+ defaultValue: never[];
27
+ };
28
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
29
+ export default BedGraphTabixAdapter;
@@ -0,0 +1,32 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ import { types } from 'mobx-state-tree';
3
+ function x() { }
4
+ const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
5
+ bedGraphGzLocation: {
6
+ type: 'fileLocation',
7
+ defaultValue: {
8
+ uri: '/path/to/my.bedgraph',
9
+ locationType: 'UriLocation',
10
+ },
11
+ },
12
+ index: ConfigurationSchema('VcfIndex', {
13
+ indexType: {
14
+ model: types.enumeration('IndexType', ['TBI', 'CSI']),
15
+ type: 'stringEnum',
16
+ defaultValue: 'TBI',
17
+ },
18
+ location: {
19
+ type: 'fileLocation',
20
+ defaultValue: {
21
+ uri: '/path/to/my.vcf.gz.tbi',
22
+ locationType: 'UriLocation',
23
+ },
24
+ },
25
+ }),
26
+ columnNames: {
27
+ type: 'stringArray',
28
+ description: 'List of column names',
29
+ defaultValue: [],
30
+ },
31
+ }, { explicitlyTyped: true });
32
+ export default BedGraphTabixAdapter;
@@ -0,0 +1,2 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export default function BedGraphTabixAdapterF(pluginManager: PluginManager): void;
@@ -0,0 +1,10 @@
1
+ import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
+ import configSchema from './configSchema';
3
+ export default function BedGraphTabixAdapterF(pluginManager) {
4
+ pluginManager.addAdapterType(() => new AdapterType({
5
+ name: 'BedGraphTabixAdapter',
6
+ displayName: 'BedGraphTabix adapter',
7
+ configSchema,
8
+ getAdapterClass: () => import('./BedGraphTabixAdapter').then(r => r.default),
9
+ }));
10
+ }
@@ -1,9 +1,10 @@
1
- import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
- import { Region, Feature } from '@jbrowse/core/util';
3
1
  import { TabixIndexedFile } from '@gmod/tabix';
4
- import PluginManager from '@jbrowse/core/PluginManager';
5
- import { AnyConfigurationModel } from '@jbrowse/core/configuration';
6
- import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
2
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import type PluginManager from '@jbrowse/core/PluginManager';
4
+ import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
5
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
6
+ import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
7
+ import type { Feature, Region } from '@jbrowse/core/util';
7
8
  export default class BedTabixAdapter extends BaseFeatureDataAdapter {
8
9
  private parser;
9
10
  protected bed: TabixIndexedFile;
@@ -1,10 +1,10 @@
1
1
  import BED from '@gmod/bed';
2
- import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter';
2
+ import { TabixIndexedFile } from '@gmod/tabix';
3
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
+ import { SimpleFeature } from '@jbrowse/core/util';
3
5
  import { openLocation } from '@jbrowse/core/util/io';
4
6
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
5
- import { SimpleFeature, } from '@jbrowse/core/util';
6
- import { TabixIndexedFile } from '@gmod/tabix';
7
- // locals
7
+ import { checkStopToken } from '@jbrowse/core/util/stopToken';
8
8
  import { featureData } from '../util';
9
9
  class BedTabixAdapter extends BaseFeatureDataAdapter {
10
10
  constructor(config, getSubAdapter, pluginManager) {
@@ -45,6 +45,7 @@ class BedTabixAdapter extends BaseFeatureDataAdapter {
45
45
  : undefined;
46
46
  }
47
47
  getFeatures(query, opts = {}) {
48
+ const { stopToken } = opts;
48
49
  return ObservableCreate(async (observer) => {
49
50
  const meta = await this.bed.getMetadata();
50
51
  const { columnNumbers } = meta;
@@ -52,8 +53,14 @@ class BedTabixAdapter extends BaseFeatureDataAdapter {
52
53
  const colStart = columnNumbers.start - 1;
53
54
  const colEnd = columnNumbers.end - 1;
54
55
  const names = await this.getNames();
56
+ let start = performance.now();
57
+ checkStopToken(stopToken);
55
58
  await this.bed.getLines(query.refName, query.start, query.end, {
56
59
  lineCallback: (line, fileOffset) => {
60
+ if (performance.now() - start > 200) {
61
+ checkStopToken(stopToken);
62
+ start = performance.now();
63
+ }
57
64
  observer.next(new SimpleFeature(featureData({
58
65
  line,
59
66
  colRef,
@@ -65,10 +72,10 @@ class BedTabixAdapter extends BaseFeatureDataAdapter {
65
72
  names,
66
73
  })));
67
74
  },
68
- signal: opts.signal,
75
+ stopToken: opts.stopToken,
69
76
  });
70
77
  observer.complete();
71
- }, opts.signal);
78
+ }, opts.stopToken);
72
79
  }
73
80
  freeResources() { }
74
81
  }
@@ -1,7 +1,4 @@
1
1
  declare const BedTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- /**
3
- * #slot
4
- */
5
2
  bedGzLocation: {
6
3
  type: string;
7
4
  defaultValue: {
@@ -10,17 +7,11 @@ declare const BedTabixAdapter: import("@jbrowse/core/configuration/configuration
10
7
  };
11
8
  };
12
9
  index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
13
- /**
14
- * #slot index.indexType
15
- */
16
10
  indexType: {
17
11
  model: import("mobx-state-tree").ISimpleType<string>;
18
12
  type: string;
19
13
  defaultValue: string;
20
14
  };
21
- /**
22
- * #slot index.location
23
- */
24
15
  location: {
25
16
  type: string;
26
17
  defaultValue: {
@@ -29,25 +20,16 @@ declare const BedTabixAdapter: import("@jbrowse/core/configuration/configuration
29
20
  };
30
21
  };
31
22
  }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
32
- /**
33
- * #slot
34
- */
35
23
  columnNames: {
36
24
  type: string;
37
25
  description: string;
38
26
  defaultValue: never[];
39
27
  };
40
- /**
41
- * #slot
42
- */
43
28
  scoreColumn: {
44
29
  type: string;
45
30
  description: string;
46
31
  defaultValue: string;
47
32
  };
48
- /**
49
- * #slot
50
- */
51
33
  autoSql: {
52
34
  type: string;
53
35
  description: string;
@@ -1,29 +1,17 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
2
  import { types } from 'mobx-state-tree';
3
- /**
4
- * #config BedTabixAdapter
5
- */
6
- function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ function x() { }
7
4
  const BedTabixAdapter = ConfigurationSchema('BedTabixAdapter', {
8
- /**
9
- * #slot
10
- */
11
5
  bedGzLocation: {
12
6
  type: 'fileLocation',
13
7
  defaultValue: { uri: '/path/to/my.bed.gz', locationType: 'UriLocation' },
14
8
  },
15
9
  index: ConfigurationSchema('TabixIndex', {
16
- /**
17
- * #slot index.indexType
18
- */
19
10
  indexType: {
20
11
  model: types.enumeration('IndexType', ['TBI', 'CSI']),
21
12
  type: 'stringEnum',
22
13
  defaultValue: 'TBI',
23
14
  },
24
- /**
25
- * #slot index.location
26
- */
27
15
  location: {
28
16
  type: 'fileLocation',
29
17
  defaultValue: {
@@ -32,25 +20,16 @@ const BedTabixAdapter = ConfigurationSchema('BedTabixAdapter', {
32
20
  },
33
21
  },
34
22
  }),
35
- /**
36
- * #slot
37
- */
38
23
  columnNames: {
39
24
  type: 'stringArray',
40
25
  description: 'List of column names',
41
26
  defaultValue: [],
42
27
  },
43
- /**
44
- * #slot
45
- */
46
28
  scoreColumn: {
47
29
  type: 'string',
48
30
  description: 'The column to use as a "score" attribute',
49
31
  defaultValue: '',
50
32
  },
51
- /**
52
- * #slot
53
- */
54
33
  autoSql: {
55
34
  type: 'string',
56
35
  description: 'The autoSql definition for the data fields in the file',
@@ -1,2 +1,2 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
2
  export default function BedTabixAdapterF(pluginManager: PluginManager): void;
@@ -1,7 +1,7 @@
1
- import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
- import { Region, Feature, SimpleFeature } from '@jbrowse/core/util';
3
1
  import IntervalTree from '@flatten-js/interval-tree';
4
- export declare function featureData(line: string, uniqueId: string, flip: boolean, names?: string[]): SimpleFeature;
2
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
4
+ import type { Feature, Region } from '@jbrowse/core/util';
5
5
  export default class BedpeAdapter extends BaseFeatureDataAdapter {
6
6
  protected bedpeFeatures?: Promise<{
7
7
  header: string;
@@ -1,72 +1,16 @@
1
- import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter';
1
+ import IntervalTree from '@flatten-js/interval-tree';
2
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import { fetchAndMaybeUnzipText } from '@jbrowse/core/util';
2
4
  import { openLocation } from '@jbrowse/core/util/io';
3
5
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
4
- import { SimpleFeature, fetchAndMaybeUnzip, } from '@jbrowse/core/util';
5
- import IntervalTree from '@flatten-js/interval-tree';
6
- const svTypes = new Set(['DUP', 'TRA', 'INV', 'CNV', 'DEL']);
7
- export function featureData(line, uniqueId, flip, names) {
8
- const l = line.split('\t');
9
- const ref1 = l[flip ? 3 : 0];
10
- const start1 = +l[flip ? 4 : 1];
11
- const end1 = +l[flip ? 5 : 2];
12
- const ref2 = l[!flip ? 3 : 0];
13
- const start2 = +l[!flip ? 4 : 1];
14
- const end2 = +l[!flip ? 5 : 2];
15
- const name = l[6];
16
- const score = +l[7];
17
- const strand1 = parseStrand(l[8]);
18
- const strand2 = parseStrand(l[9]);
19
- const extra = l.slice(10);
20
- const rest = names
21
- ? Object.fromEntries(names.slice(10).map((n, idx) => [n, extra[idx]]))
22
- : extra;
23
- const ALT = svTypes.has(extra[0]) ? `<${extra[0]}>` : undefined;
24
- return new SimpleFeature({
25
- ...rest,
26
- start: start1,
27
- end: end1,
28
- type: 'paired_feature',
29
- refName: ref1,
30
- strand: strand1,
31
- name,
32
- score,
33
- uniqueId,
34
- mate: {
35
- refName: ref2,
36
- start: start2,
37
- end: end2,
38
- strand: strand2,
39
- },
40
- ...(ALT ? { ALT: [ALT] } : {}), // ALT is an array in VCF
41
- });
42
- }
43
- function parseStrand(strand) {
44
- if (strand === '+') {
45
- return 1;
46
- }
47
- if (strand === '-') {
48
- return -1;
49
- }
50
- if (strand === '.') {
51
- return 0;
52
- }
53
- return undefined;
54
- }
6
+ import { featureData } from './util';
55
7
  class BedpeAdapter extends BaseFeatureDataAdapter {
56
8
  constructor() {
57
9
  super(...arguments);
58
10
  this.intervalTrees = {};
59
11
  }
60
12
  async loadDataP(opts) {
61
- const pm = this.pluginManager;
62
- const bedLoc = this.getConf('bedpeLocation');
63
- const loc = openLocation(bedLoc, pm);
64
- const buffer = await fetchAndMaybeUnzip(loc, opts);
65
- // 512MB max chrome string length is 512MB
66
- if (buffer.length > 536870888) {
67
- throw new Error('Data exceeds maximum string length (512MB)');
68
- }
69
- const data = new TextDecoder('utf8', { fatal: true }).decode(buffer);
13
+ const data = await fetchAndMaybeUnzipText(openLocation(this.getConf('bedpeLocation'), this.pluginManager), opts);
70
14
  const lines = data.split(/\n|\r\n|\r/).filter(f => !!f);
71
15
  const headerLines = [];
72
16
  let i = 0;
@@ -158,7 +102,7 @@ class BedpeAdapter extends BaseFeatureDataAdapter {
158
102
  observer.next(f);
159
103
  });
160
104
  observer.complete();
161
- }, opts.signal);
105
+ }, opts.stopToken);
162
106
  }
163
107
  freeResources() { }
164
108
  }
@@ -1,8 +1,4 @@
1
1
  declare const BedpeAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- /**
3
- * #slot
4
- * can be plaintext or gzipped, not indexed so loaded into memory on startup
5
- */
6
2
  bedpeLocation: {
7
3
  type: string;
8
4
  defaultValue: {
@@ -10,9 +6,6 @@ declare const BedpeAdapter: import("@jbrowse/core/configuration/configurationSch
10
6
  locationType: string;
11
7
  };
12
8
  };
13
- /**
14
- * #slot
15
- */
16
9
  columnNames: {
17
10
  type: string;
18
11
  description: string;
@@ -1,14 +1,6 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- /**
3
- * #config BedpeAdapter
4
- * intended for SVs in a single assembly
5
- */
6
- function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ function x() { }
7
3
  const BedpeAdapter = ConfigurationSchema('BedpeAdapter', {
8
- /**
9
- * #slot
10
- * can be plaintext or gzipped, not indexed so loaded into memory on startup
11
- */
12
4
  bedpeLocation: {
13
5
  type: 'fileLocation',
14
6
  defaultValue: {
@@ -16,9 +8,6 @@ const BedpeAdapter = ConfigurationSchema('BedpeAdapter', {
16
8
  locationType: 'UriLocation',
17
9
  },
18
10
  },
19
- /**
20
- * #slot
21
- */
22
11
  columnNames: {
23
12
  type: 'stringArray',
24
13
  description: 'List of column names',
@@ -1,2 +1,2 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
2
  export default function BedpeAdapterF(pluginManager: PluginManager): void;
@@ -0,0 +1,2 @@
1
+ import { SimpleFeature } from '@jbrowse/core/util';
2
+ export declare function featureData(line: string, uniqueId: string, flip: boolean, names?: string[]): SimpleFeature;
@@ -0,0 +1,52 @@
1
+ import { SimpleFeature } from '@jbrowse/core/util';
2
+ const svTypes = new Set(['DUP', 'TRA', 'INV', 'CNV', 'DEL']);
3
+ export function featureData(line, uniqueId, flip, names) {
4
+ const l = line.split('\t');
5
+ const ref1 = l[flip ? 3 : 0];
6
+ const start1 = +l[flip ? 4 : 1];
7
+ const end1 = +l[flip ? 5 : 2];
8
+ const ref2 = l[!flip ? 3 : 0];
9
+ const start2 = +l[!flip ? 4 : 1];
10
+ const end2 = +l[!flip ? 5 : 2];
11
+ const name = l[6];
12
+ const score = +l[7];
13
+ const strand1 = parseStrand(l[8]);
14
+ const strand2 = parseStrand(l[9]);
15
+ const extra = l.slice(10);
16
+ const rest = names
17
+ ? Object.fromEntries(names.slice(10).map((n, idx) => [n, extra[idx]]))
18
+ : {};
19
+ const ALT = svTypes.has(extra[0]) ? `<${extra[0]}>` : undefined;
20
+ return new SimpleFeature({
21
+ ...rest,
22
+ start: start1,
23
+ end: end1,
24
+ type: 'paired_feature',
25
+ refName: ref1,
26
+ strand: strand1,
27
+ name,
28
+ score,
29
+ uniqueId,
30
+ mate: {
31
+ refName: ref2,
32
+ start: start2,
33
+ end: end2,
34
+ strand: strand2,
35
+ },
36
+ ...(ALT ? { ALT: [ALT] } : {}),
37
+ });
38
+ }
39
+ function parseStrand(strand) {
40
+ if (strand === '+') {
41
+ return 1;
42
+ }
43
+ else if (strand === '-') {
44
+ return -1;
45
+ }
46
+ else if (strand === '.') {
47
+ return 0;
48
+ }
49
+ else {
50
+ return undefined;
51
+ }
52
+ }
@@ -1,9 +1,10 @@
1
1
  import { BigBed } from '@gmod/bbi';
2
2
  import BED from '@gmod/bed';
3
- import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
4
- import { Region } from '@jbrowse/core/util/types';
5
- import { Feature } from '@jbrowse/core/util';
6
- import { Observer } from 'rxjs';
3
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
5
+ import type { Feature } from '@jbrowse/core/util';
6
+ import type { Region } from '@jbrowse/core/util/types';
7
+ import type { Observer } from 'rxjs';
7
8
  export default class BigBedAdapter extends BaseFeatureDataAdapter {
8
9
  private cachedP?;
9
10
  configurePre(opts?: BaseOptions): Promise<{
@@ -1,11 +1,10 @@
1
1
  import { BigBed } from '@gmod/bbi';
2
2
  import BED from '@gmod/bed';
3
- import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
+ import { SimpleFeature, doesIntersect2, max, min } from '@jbrowse/core/util';
4
5
  import { openLocation } from '@jbrowse/core/util/io';
5
6
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
6
- import { doesIntersect2, max, min, SimpleFeature, } from '@jbrowse/core/util';
7
7
  import { firstValueFrom, toArray } from 'rxjs';
8
- // locals
9
8
  import { featureData2 } from '../util';
10
9
  export default class BigBedAdapter extends BaseFeatureDataAdapter {
11
10
  async configurePre(opts) {
@@ -62,12 +61,13 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
62
61
  };
63
62
  }
64
63
  async getFeaturesHelper({ query, opts, observer, allowRedispatch, originalQuery = query, }) {
65
- const { signal } = opts;
64
+ var _a;
65
+ const { stopToken } = opts;
66
66
  const scoreColumn = this.getConf('scoreColumn');
67
67
  const aggregateField = this.getConf('aggregateField');
68
68
  const { parser, bigbed } = await this.configure(opts);
69
69
  const feats = await bigbed.getFeatures(query.refName, query.start, query.end, {
70
- signal,
70
+ stopToken,
71
71
  basesPerSpan: query.end - query.start,
72
72
  });
73
73
  if (allowRedispatch && feats.length) {
@@ -101,8 +101,13 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
101
101
  throw new Error('found uniqueId undefined');
102
102
  }
103
103
  for (const feat of feats) {
104
- const line = `${query.refName}\t${feat.start}\t${feat.end}\t${feat.rest}`;
105
- const data = parser.parseLine(line, { uniqueId: feat.uniqueId });
104
+ const splitLine = [
105
+ query.refName,
106
+ `${feat.start}`,
107
+ `${feat.end}`,
108
+ ...(((_a = feat.rest) === null || _a === void 0 ? void 0 : _a.split('\t')) || []),
109
+ ];
110
+ const data = parser.parseLine(splitLine, { uniqueId: feat.uniqueId });
106
111
  const aggr = data[aggregateField];
107
112
  if (!parentAggregation[aggr]) {
108
113
  parentAggregation[aggr] = [];
@@ -111,7 +116,7 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
111
116
  const f = featureData2({
112
117
  ...rest,
113
118
  scoreColumn,
114
- line,
119
+ splitLine,
115
120
  parser,
116
121
  uniqueId,
117
122
  start: feat.start,
@@ -164,7 +169,7 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
164
169
  catch (e) {
165
170
  observer.error(e);
166
171
  }
167
- }, opts.signal);
172
+ }, opts.stopToken);
168
173
  }
169
174
  freeResources() { }
170
175
  }