@jbrowse/plugin-bed 2.17.0 → 2.18.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 (81) 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/BedGraphAdapter/BedGraphAdapter.d.ts +24 -0
  7. package/dist/BedGraphAdapter/BedGraphAdapter.js +130 -0
  8. package/dist/BedGraphAdapter/configSchema.d.ts +15 -0
  9. package/dist/BedGraphAdapter/configSchema.js +19 -0
  10. package/dist/BedGraphAdapter/index.d.ts +2 -0
  11. package/dist/BedGraphAdapter/index.js +39 -0
  12. package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +18 -0
  13. package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.js +105 -0
  14. package/dist/BedGraphTabixAdapter/configSchema.d.ts +29 -0
  15. package/dist/BedGraphTabixAdapter/configSchema.js +34 -0
  16. package/dist/BedGraphTabixAdapter/index.d.ts +2 -0
  17. package/dist/BedGraphTabixAdapter/index.js +39 -0
  18. package/dist/BedTabixAdapter/BedTabixAdapter.d.ts +6 -5
  19. package/dist/BedTabixAdapter/BedTabixAdapter.js +12 -5
  20. package/dist/BedTabixAdapter/configSchema.d.ts +0 -18
  21. package/dist/BedTabixAdapter/configSchema.js +1 -22
  22. package/dist/BedTabixAdapter/index.d.ts +1 -1
  23. package/dist/BedpeAdapter/BedpeAdapter.d.ts +4 -2
  24. package/dist/BedpeAdapter/BedpeAdapter.js +4 -5
  25. package/dist/BedpeAdapter/configSchema.d.ts +0 -7
  26. package/dist/BedpeAdapter/configSchema.js +1 -12
  27. package/dist/BedpeAdapter/index.d.ts +1 -1
  28. package/dist/BigBedAdapter/BigBedAdapter.d.ts +5 -4
  29. package/dist/BigBedAdapter/BigBedAdapter.js +13 -8
  30. package/dist/BigBedAdapter/configSchema.d.ts +0 -9
  31. package/dist/BigBedAdapter/configSchema.js +1 -13
  32. package/dist/BigBedAdapter/index.d.ts +1 -1
  33. package/dist/generateBedMethylFeature.d.ts +3 -3
  34. package/dist/generateBedMethylFeature.js +3 -5
  35. package/dist/generateUcscTranscript.d.ts +1 -1
  36. package/dist/generateUcscTranscript.js +0 -6
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +8 -4
  39. package/dist/util.d.ts +171 -6
  40. package/dist/util.js +65 -61
  41. package/esm/BedAdapter/BedAdapter.d.ts +15 -5
  42. package/esm/BedAdapter/BedAdapter.js +8 -11
  43. package/esm/BedAdapter/configSchema.d.ts +0 -21
  44. package/esm/BedAdapter/configSchema.js +1 -25
  45. package/esm/BedAdapter/index.d.ts +1 -1
  46. package/esm/BedGraphAdapter/BedGraphAdapter.d.ts +24 -0
  47. package/esm/BedGraphAdapter/BedGraphAdapter.js +124 -0
  48. package/esm/BedGraphAdapter/configSchema.d.ts +15 -0
  49. package/esm/BedGraphAdapter/configSchema.js +17 -0
  50. package/esm/BedGraphAdapter/index.d.ts +2 -0
  51. package/esm/BedGraphAdapter/index.js +10 -0
  52. package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +18 -0
  53. package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.js +102 -0
  54. package/esm/BedGraphTabixAdapter/configSchema.d.ts +29 -0
  55. package/esm/BedGraphTabixAdapter/configSchema.js +32 -0
  56. package/esm/BedGraphTabixAdapter/index.d.ts +2 -0
  57. package/esm/BedGraphTabixAdapter/index.js +10 -0
  58. package/esm/BedTabixAdapter/BedTabixAdapter.d.ts +6 -5
  59. package/esm/BedTabixAdapter/BedTabixAdapter.js +13 -6
  60. package/esm/BedTabixAdapter/configSchema.d.ts +0 -18
  61. package/esm/BedTabixAdapter/configSchema.js +1 -22
  62. package/esm/BedTabixAdapter/index.d.ts +1 -1
  63. package/esm/BedpeAdapter/BedpeAdapter.d.ts +4 -2
  64. package/esm/BedpeAdapter/BedpeAdapter.js +5 -6
  65. package/esm/BedpeAdapter/configSchema.d.ts +0 -7
  66. package/esm/BedpeAdapter/configSchema.js +1 -12
  67. package/esm/BedpeAdapter/index.d.ts +1 -1
  68. package/esm/BigBedAdapter/BigBedAdapter.d.ts +5 -4
  69. package/esm/BigBedAdapter/BigBedAdapter.js +14 -9
  70. package/esm/BigBedAdapter/configSchema.d.ts +0 -9
  71. package/esm/BigBedAdapter/configSchema.js +1 -13
  72. package/esm/BigBedAdapter/index.d.ts +1 -1
  73. package/esm/generateBedMethylFeature.d.ts +3 -3
  74. package/esm/generateBedMethylFeature.js +3 -5
  75. package/esm/generateUcscTranscript.d.ts +1 -1
  76. package/esm/generateUcscTranscript.js +0 -6
  77. package/esm/index.d.ts +1 -1
  78. package/esm/index.js +8 -4
  79. package/esm/util.d.ts +171 -6
  80. package/esm/util.js +65 -61
  81. package/package.json +2 -2
@@ -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
  }
@@ -1,7 +1,4 @@
1
1
  declare const BigBedAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- /**
3
- * #slot
4
- */
5
2
  bigBedLocation: {
6
3
  type: string;
7
4
  defaultValue: {
@@ -9,17 +6,11 @@ declare const BigBedAdapter: import("@jbrowse/core/configuration/configurationSc
9
6
  locationType: string;
10
7
  };
11
8
  };
12
- /**
13
- * #slot
14
- */
15
9
  scoreColumn: {
16
10
  type: string;
17
11
  description: string;
18
12
  defaultValue: string;
19
13
  };
20
- /**
21
- * #slot
22
- */
23
14
  aggregateField: {
24
15
  type: string;
25
16
  description: string;
@@ -1,27 +1,15 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- /**
3
- * #config BigBedAdapter
4
- */
5
- function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ function x() { }
6
3
  const BigBedAdapter = ConfigurationSchema('BigBedAdapter', {
7
- /**
8
- * #slot
9
- */
10
4
  bigBedLocation: {
11
5
  type: 'fileLocation',
12
6
  defaultValue: { uri: '/path/to/my.bb', locationType: 'UriLocation' },
13
7
  },
14
- /**
15
- * #slot
16
- */
17
8
  scoreColumn: {
18
9
  type: 'string',
19
10
  description: 'The column to use as a "score" attribute',
20
11
  defaultValue: '',
21
12
  },
22
- /**
23
- * #slot
24
- */
25
13
  aggregateField: {
26
14
  type: 'string',
27
15
  description: 'An attribute to aggregate features with',
@@ -1,2 +1,2 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
2
  export default function BigBedAdapterF(pluginManager: PluginManager): void;
@@ -3,8 +3,8 @@ export declare function isBedMethylFeature({ splitLine, start, end, }: {
3
3
  start: number;
4
4
  end: number;
5
5
  }): boolean;
6
- export declare function generateBedMethylFeature({ line, uniqueId, refName, start, end, }: {
7
- line: string;
6
+ export declare function generateBedMethylFeature({ splitLine, uniqueId, refName, start, end, }: {
7
+ splitLine: string[];
8
8
  uniqueId: string;
9
9
  refName: string;
10
10
  start: number;
@@ -15,7 +15,7 @@ export declare function generateBedMethylFeature({ line, uniqueId, refName, star
15
15
  start: number;
16
16
  end: number;
17
17
  code: string | undefined;
18
- score: string | undefined;
18
+ score: number;
19
19
  strand: string | undefined;
20
20
  color: string | undefined;
21
21
  source: string | undefined;
@@ -1,17 +1,15 @@
1
1
  export function isBedMethylFeature({ splitLine, start, end, }) {
2
2
  return +(splitLine[6] || 0) === start && +(splitLine[7] || 0) === end;
3
3
  }
4
- export function generateBedMethylFeature({ line, uniqueId, refName, start, end, }) {
5
- // see
6
- // https://github.com/nanoporetech/modkit?tab=readme-ov-file#description-of-bedmethyl-output
7
- const [, , , code, , strand, , , color, n_valid_cov, fraction_modified, n_mod, n_canonical, n_other_mod, n_delete, n_fail, n_diff, n_nocall,] = line.split('\t');
4
+ export function generateBedMethylFeature({ splitLine, uniqueId, refName, start, end, }) {
5
+ const [, , , code, , strand, , , color, n_valid_cov, fraction_modified, n_mod, n_canonical, n_other_mod, n_delete, n_fail, n_diff, n_nocall,] = splitLine;
8
6
  return {
9
7
  uniqueId,
10
8
  refName,
11
9
  start,
12
10
  end,
13
11
  code,
14
- score: fraction_modified,
12
+ score: +fraction_modified || 0,
15
13
  strand,
16
14
  color,
17
15
  source: code,
@@ -1,4 +1,4 @@
1
- import { MinimalFeature, TranscriptFeat } from './types';
1
+ import type { MinimalFeature, TranscriptFeat } from './types';
2
2
  export declare function isUcscTranscript({ thickStart, blockCount, strand, }: {
3
3
  thickStart?: number;
4
4
  blockCount?: number;
@@ -12,7 +12,6 @@ export function generateUcscTranscript(data) {
12
12
  const start = block.start;
13
13
  const end = block.end;
14
14
  if (thickStart >= end) {
15
- // left-side UTR
16
15
  subfeatures.push({
17
16
  type: `${strand > 0 ? 'five' : 'three'}_prime_UTR`,
18
17
  start,
@@ -21,7 +20,6 @@ export function generateUcscTranscript(data) {
21
20
  });
22
21
  }
23
22
  else if (thickStart > start && thickStart < end && thickEnd >= end) {
24
- // UTR | CDS
25
23
  subfeatures.push({
26
24
  type: `${strand > 0 ? 'five' : 'three'}_prime_UTR`,
27
25
  start,
@@ -35,7 +33,6 @@ export function generateUcscTranscript(data) {
35
33
  });
36
34
  }
37
35
  else if (thickStart <= start && thickEnd >= end) {
38
- // CDS
39
36
  subfeatures.push({
40
37
  type: 'CDS',
41
38
  start,
@@ -44,7 +41,6 @@ export function generateUcscTranscript(data) {
44
41
  });
45
42
  }
46
43
  else if (thickStart > start && thickStart < end && thickEnd < end) {
47
- // UTR | CDS | UTR
48
44
  subfeatures.push({
49
45
  type: `${strand > 0 ? 'five' : 'three'}_prime_UTR`,
50
46
  start,
@@ -63,7 +59,6 @@ export function generateUcscTranscript(data) {
63
59
  });
64
60
  }
65
61
  else if (thickStart <= start && thickEnd > start && thickEnd < end) {
66
- // CDS | UTR
67
62
  subfeatures.push({
68
63
  type: 'CDS',
69
64
  start,
@@ -77,7 +72,6 @@ export function generateUcscTranscript(data) {
77
72
  });
78
73
  }
79
74
  else if (thickEnd <= start) {
80
- // right-side UTR
81
75
  subfeatures.push({
82
76
  type: `${strand > 0 ? 'three' : 'five'}_prime_UTR`,
83
77
  start,
package/esm/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import PluginManager from '@jbrowse/core/PluginManager';
2
+ import type PluginManager from '@jbrowse/core/PluginManager';
3
3
  export default class BedPlugin extends Plugin {
4
4
  name: string;
5
5
  install(pluginManager: PluginManager): void;
package/esm/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import BigBedAdapterF from './BigBedAdapter';
3
- import BedpeAdapterF from './BedpeAdapter';
4
- import BedTabixAdapterF from './BedTabixAdapter';
5
- import BedAdapterF from './BedAdapter';
6
2
  import { getFileName, makeIndex, makeIndexType, } from '@jbrowse/core/util/tracks';
3
+ import BedAdapterF from './BedAdapter';
4
+ import BedGraphAdapterF from './BedGraphAdapter';
5
+ import BedGraphTabixAdapterF from './BedGraphTabixAdapter';
6
+ import BedTabixAdapterF from './BedTabixAdapter';
7
+ import BedpeAdapterF from './BedpeAdapter';
8
+ import BigBedAdapterF from './BigBedAdapter';
7
9
  export default class BedPlugin extends Plugin {
8
10
  constructor() {
9
11
  super(...arguments);
@@ -14,6 +16,8 @@ export default class BedPlugin extends Plugin {
14
16
  BedAdapterF(pluginManager);
15
17
  BedpeAdapterF(pluginManager);
16
18
  BedTabixAdapterF(pluginManager);
19
+ BedGraphAdapterF(pluginManager);
20
+ BedGraphTabixAdapterF(pluginManager);
17
21
  pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
18
22
  return (file, index, adapterHint) => {
19
23
  const regexGuess = /\.(bb|bigbed)$/i;
package/esm/util.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import BED from '@gmod/bed';
2
- import { SimpleFeatureSerialized } from '@jbrowse/core/util';
1
+ import type BED from '@gmod/bed';
3
2
  export declare function makeBlocks({ start, uniqueId, refName, chromStarts, blockCount, blockSizes, blockStarts, }: {
4
3
  blockCount: number;
5
4
  start: number;
@@ -24,9 +23,92 @@ export declare function featureData({ line, colRef, colStart, colEnd, scoreColum
24
23
  parser: BED;
25
24
  uniqueId: string;
26
25
  names?: string[];
27
- }): SimpleFeatureSerialized;
28
- export declare function featureData2({ line, refName, start, end, parser, uniqueId, scoreColumn, names, }: {
29
- line: string;
26
+ }): {
27
+ uniqueId: string;
28
+ refName: string;
29
+ start: number;
30
+ end: number;
31
+ code: string | undefined;
32
+ score: number;
33
+ strand: string | undefined;
34
+ color: string | undefined;
35
+ source: string | undefined;
36
+ n_valid_cov: string | undefined;
37
+ fraction_modified: string | undefined;
38
+ n_mod: string | undefined;
39
+ n_canonical: string | undefined;
40
+ n_other_mod: string | undefined;
41
+ n_delete: string | undefined;
42
+ n_fail: string | undefined;
43
+ n_diff: string | undefined;
44
+ n_nocall: string | undefined;
45
+ } | {
46
+ uniqueId: string;
47
+ refName: string;
48
+ start: number;
49
+ end: number;
50
+ bitsw_score: string | undefined;
51
+ percent_div: string | undefined;
52
+ percent_del: string | undefined;
53
+ percent_ins: string | undefined;
54
+ query_chr: string | undefined;
55
+ query_begin: string | undefined;
56
+ query_end: string | undefined;
57
+ query_remaining: string | undefined;
58
+ orientation: string | undefined;
59
+ matching_repeat_name: string | undefined;
60
+ matching_repeat_class: string | undefined;
61
+ matching_repeat_begin: string | undefined;
62
+ matching_repeat_end: string | undefined;
63
+ matching_repeat_remaining: string | undefined;
64
+ repeat_id: string | undefined;
65
+ description?: undefined;
66
+ } | {
67
+ uniqueId: string;
68
+ refName: string;
69
+ start: number;
70
+ end: number;
71
+ description: undefined;
72
+ bitsw_score?: undefined;
73
+ percent_div?: undefined;
74
+ percent_del?: undefined;
75
+ percent_ins?: undefined;
76
+ query_chr?: undefined;
77
+ query_begin?: undefined;
78
+ query_end?: undefined;
79
+ query_remaining?: undefined;
80
+ orientation?: undefined;
81
+ matching_repeat_name?: undefined;
82
+ matching_repeat_class?: undefined;
83
+ matching_repeat_begin?: undefined;
84
+ matching_repeat_end?: undefined;
85
+ matching_repeat_remaining?: undefined;
86
+ repeat_id?: undefined;
87
+ } | {
88
+ uniqueId: string;
89
+ strand: number;
90
+ type: string;
91
+ refName: string;
92
+ subfeatures: import("./types").MinimalFeature[];
93
+ start: number;
94
+ end: number;
95
+ } | {
96
+ uniqueId: string;
97
+ score: number | undefined;
98
+ start: number;
99
+ end: number;
100
+ strand: any;
101
+ refName: string;
102
+ subfeatures: {
103
+ uniqueId: string;
104
+ start: number;
105
+ end: number;
106
+ refName: string;
107
+ type: string;
108
+ }[] | undefined;
109
+ };
110
+ export declare function featureData2({ splitLine, refName, start, end, parser, uniqueId, scoreColumn, names, }: {
111
+ splitLine: string[];
30
112
  refName: string;
31
113
  start: number;
32
114
  end: number;
@@ -34,5 +116,88 @@ export declare function featureData2({ line, refName, start, end, parser, unique
34
116
  uniqueId: string;
35
117
  scoreColumn: string;
36
118
  names?: string[];
37
- }): SimpleFeatureSerialized;
119
+ }): {
120
+ uniqueId: string;
121
+ refName: string;
122
+ start: number;
123
+ end: number;
124
+ code: string | undefined;
125
+ score: number;
126
+ strand: string | undefined;
127
+ color: string | undefined;
128
+ source: string | undefined;
129
+ n_valid_cov: string | undefined;
130
+ fraction_modified: string | undefined;
131
+ n_mod: string | undefined;
132
+ n_canonical: string | undefined;
133
+ n_other_mod: string | undefined;
134
+ n_delete: string | undefined;
135
+ n_fail: string | undefined;
136
+ n_diff: string | undefined;
137
+ n_nocall: string | undefined;
138
+ } | {
139
+ uniqueId: string;
140
+ refName: string;
141
+ start: number;
142
+ end: number;
143
+ bitsw_score: string | undefined;
144
+ percent_div: string | undefined;
145
+ percent_del: string | undefined;
146
+ percent_ins: string | undefined;
147
+ query_chr: string | undefined;
148
+ query_begin: string | undefined;
149
+ query_end: string | undefined;
150
+ query_remaining: string | undefined;
151
+ orientation: string | undefined;
152
+ matching_repeat_name: string | undefined;
153
+ matching_repeat_class: string | undefined;
154
+ matching_repeat_begin: string | undefined;
155
+ matching_repeat_end: string | undefined;
156
+ matching_repeat_remaining: string | undefined;
157
+ repeat_id: string | undefined;
158
+ description?: undefined;
159
+ } | {
160
+ uniqueId: string;
161
+ refName: string;
162
+ start: number;
163
+ end: number;
164
+ description: undefined;
165
+ bitsw_score?: undefined;
166
+ percent_div?: undefined;
167
+ percent_del?: undefined;
168
+ percent_ins?: undefined;
169
+ query_chr?: undefined;
170
+ query_begin?: undefined;
171
+ query_end?: undefined;
172
+ query_remaining?: undefined;
173
+ orientation?: undefined;
174
+ matching_repeat_name?: undefined;
175
+ matching_repeat_class?: undefined;
176
+ matching_repeat_begin?: undefined;
177
+ matching_repeat_end?: undefined;
178
+ matching_repeat_remaining?: undefined;
179
+ repeat_id?: undefined;
180
+ } | {
181
+ uniqueId: string;
182
+ strand: number;
183
+ type: string;
184
+ refName: string;
185
+ subfeatures: import("./types").MinimalFeature[];
186
+ start: number;
187
+ end: number;
188
+ } | {
189
+ uniqueId: string;
190
+ score: number | undefined;
191
+ start: number;
192
+ end: number;
193
+ strand: any;
194
+ refName: string;
195
+ subfeatures: {
196
+ uniqueId: string;
197
+ start: number;
198
+ end: number;
199
+ refName: string;
200
+ type: string;
201
+ }[] | undefined;
202
+ };
38
203
  export declare function arrayify(f?: string | number[]): number[] | undefined;
package/esm/util.js CHANGED
@@ -1,59 +1,58 @@
1
1
  import { generateBedMethylFeature, isBedMethylFeature, } from './generateBedMethylFeature';
2
- import { generateUcscTranscript, isUcscTranscript, } from './generateUcscTranscript';
3
2
  import { generateRepeatMaskerFeature, isRepeatMaskerDescriptionField, } from './generateRepeatMaskerFeature';
4
- function stringToStrand(f) {
5
- if (f === '-1') {
6
- return -1;
3
+ import { generateUcscTranscript, isUcscTranscript, } from './generateUcscTranscript';
4
+ function defaultParser(fields, splitLine) {
5
+ let hasBlockCount = false;
6
+ const r = [];
7
+ for (let i = 0; i < splitLine.length; i++) {
8
+ if (fields[i] === 'blockCount') {
9
+ hasBlockCount = true;
10
+ }
11
+ r.push([fields[i], splitLine[i]]);
7
12
  }
8
- else if (f === '+') {
9
- return 1;
13
+ const obj = Object.fromEntries(r);
14
+ if (hasBlockCount) {
15
+ const { blockStarts, blockCount, chromStarts, thickEnd, thickStart, blockSizes, ...rest } = obj;
16
+ return {
17
+ ...rest,
18
+ blockStarts: arrayify(blockStarts),
19
+ chromStarts: arrayify(chromStarts),
20
+ blockSizes: arrayify(blockSizes),
21
+ thickStart: thickStart ? +thickStart : undefined,
22
+ thickEnd: thickEnd ? +thickEnd : undefined,
23
+ blockCount: blockCount ? +blockCount : undefined,
24
+ };
10
25
  }
11
26
  else {
12
- return 0;
27
+ return obj;
13
28
  }
14
29
  }
15
- function defaultParser(fields, line) {
16
- const obj = Object.fromEntries(line.split('\t').map((f, i) => [fields[i], f]));
17
- const { blockStarts, blockCount, chromStarts, thickEnd, thickStart, blockSizes, ...rest } = obj;
18
- return {
19
- ...rest,
20
- blockStarts: arrayify(blockStarts),
21
- chromStarts: arrayify(chromStarts),
22
- blockSizes: arrayify(blockSizes),
23
- thickStart: thickStart ? +thickStart : undefined,
24
- thickEnd: thickEnd ? +thickEnd : undefined,
25
- blockCount: blockCount ? +blockCount : undefined,
26
- };
27
- }
28
30
  export function makeBlocks({ start, uniqueId, refName, chromStarts, blockCount, blockSizes, blockStarts, }) {
29
- if (blockCount) {
30
- const subfeatures = [];
31
- const starts = chromStarts || blockStarts || [];
32
- for (let b = 0; b < blockCount; b++) {
33
- const bmin = (starts[b] || 0) + start;
34
- const bsize = blockSizes === null || blockSizes === void 0 ? void 0 : blockSizes[b];
35
- if (bsize && bsize > 0) {
36
- const bmax = bmin + bsize;
37
- subfeatures.push({
38
- uniqueId: `${uniqueId}-${b}`,
39
- start: bmin,
40
- end: bmax,
41
- refName,
42
- type: 'block',
43
- });
44
- }
31
+ const subfeatures = [];
32
+ const starts = chromStarts || blockStarts || [];
33
+ for (let b = 0; b < blockCount; b++) {
34
+ const bmin = (starts[b] || 0) + start;
35
+ const bsize = blockSizes === null || blockSizes === void 0 ? void 0 : blockSizes[b];
36
+ if (bsize && bsize > 0) {
37
+ const bmax = bmin + bsize;
38
+ subfeatures.push({
39
+ uniqueId: `${uniqueId}-${b}`,
40
+ start: bmin,
41
+ end: bmax,
42
+ refName,
43
+ type: 'block',
44
+ });
45
45
  }
46
- return subfeatures;
47
46
  }
48
- return [];
47
+ return subfeatures;
49
48
  }
50
49
  export function featureData({ line, colRef, colStart, colEnd, scoreColumn, parser, uniqueId, names, }) {
51
50
  const splitLine = line.split('\t');
52
51
  const refName = splitLine[colRef];
53
- const start = +splitLine[colStart];
54
- const end = +splitLine[colEnd] + (colStart === colEnd ? 1 : 0);
52
+ const start = Number.parseInt(splitLine[colStart], 10);
53
+ const end = Number.parseInt(splitLine[colEnd], 10) + (colStart === colEnd ? 1 : 0);
55
54
  return featureData2({
56
- line,
55
+ splitLine,
57
56
  refName,
58
57
  start,
59
58
  end,
@@ -63,34 +62,35 @@ export function featureData({ line, colRef, colStart, colEnd, scoreColumn, parse
63
62
  names,
64
63
  });
65
64
  }
66
- export function featureData2({ line, refName, start, end, parser, uniqueId, scoreColumn, names, }) {
67
- const splitLine = line.split('\t');
65
+ export function featureData2({ splitLine, refName, start, end, parser, uniqueId, scoreColumn, names, }) {
68
66
  const data = names
69
- ? defaultParser(names, line)
70
- : parser.parseLine(line, { uniqueId });
67
+ ? defaultParser(names, splitLine)
68
+ : parser.parseLine(splitLine, { uniqueId });
71
69
  const { strand: strand2, score: score2, chrom: _1, chromStart: _2, chromEnd: _3, ...rest } = data;
72
- const { chromStarts, blockSizes, blockStarts, type, blockCount, thickStart, thickEnd, description, ...rest2 } = rest;
73
70
  const score = scoreColumn ? +data[scoreColumn] : score2 ? +score2 : undefined;
74
- const strand = typeof strand2 === 'string' ? stringToStrand(strand2) : strand2;
75
- const subfeatures = makeBlocks({
76
- start,
77
- uniqueId,
78
- refName,
79
- chromStarts,
80
- blockCount,
81
- blockSizes,
82
- blockStarts,
83
- });
71
+ const strand = typeof strand2 === 'string' ? (strand2 === '-' ? -1 : 1) : strand2;
72
+ const subfeatures = rest.blockCount
73
+ ? makeBlocks({
74
+ start,
75
+ uniqueId,
76
+ refName,
77
+ chromStarts: rest.chromStarts,
78
+ blockCount: rest.blockCount,
79
+ blockSizes: rest.blockSizes,
80
+ blockStarts: rest.blockStarts,
81
+ })
82
+ : undefined;
84
83
  if (isBedMethylFeature({ splitLine, start, end })) {
85
84
  return generateBedMethylFeature({
86
- line,
85
+ splitLine,
87
86
  uniqueId,
88
87
  refName,
89
88
  start,
90
89
  end,
91
90
  });
92
91
  }
93
- else if (isRepeatMaskerDescriptionField(description)) {
92
+ else if (isRepeatMaskerDescriptionField(rest.description)) {
93
+ const { chromStarts, blockSizes, blockStarts, type, blockCount, thickStart, thickEnd, description, ...rest2 } = rest;
94
94
  return generateRepeatMaskerFeature({
95
95
  ...rest2,
96
96
  uniqueId,
@@ -104,7 +104,13 @@ export function featureData2({ line, refName, start, end, parser, uniqueId, scor
104
104
  subfeatures,
105
105
  });
106
106
  }
107
- else if (isUcscTranscript({ strand, blockCount, thickStart })) {
107
+ else if (subfeatures &&
108
+ isUcscTranscript({
109
+ strand,
110
+ blockCount: rest.blockCount,
111
+ thickStart: rest.thickStart,
112
+ })) {
113
+ const { chromStarts, blockSizes, type, blockCount, thickStart, thickEnd, description, } = rest;
108
114
  return generateUcscTranscript({
109
115
  ...rest,
110
116
  description,
@@ -127,8 +133,6 @@ export function featureData2({ line, refName, start, end, parser, uniqueId, scor
127
133
  return {
128
134
  ...rest,
129
135
  uniqueId,
130
- description,
131
- type,
132
136
  score,
133
137
  start,
134
138
  end,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-bed",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "JBrowse 2 bed adapters, tracks, etc.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -55,5 +55,5 @@
55
55
  "distModule": "esm/index.js",
56
56
  "srcModule": "src/index.ts",
57
57
  "module": "esm/index.js",
58
- "gitHead": "eed30b5e671f8f7823652d7cecc51aa89226de46"
58
+ "gitHead": "c344ea60099cb7e460b77f15808946b24a7eee74"
59
59
  }