@jbrowse/plugin-bed 3.7.0 → 4.0.1

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 (82) hide show
  1. package/esm/BedAdapter/BedAdapter.js +8 -11
  2. package/esm/BedAdapter/configSchema.d.ts +2 -2
  3. package/esm/BedAdapter/index.js +2 -2
  4. package/esm/BedGraphAdapter/BedGraphAdapter.js +5 -8
  5. package/esm/BedGraphAdapter/configSchema.d.ts +2 -2
  6. package/esm/BedGraphAdapter/index.js +2 -2
  7. package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.js +3 -3
  8. package/esm/BedGraphTabixAdapter/configSchema.d.ts +5 -5
  9. package/esm/BedGraphTabixAdapter/configSchema.js +1 -1
  10. package/esm/BedGraphTabixAdapter/index.js +2 -2
  11. package/esm/BedTabixAdapter/BedTabixAdapter.js +10 -6
  12. package/esm/BedTabixAdapter/configSchema.d.ts +5 -5
  13. package/esm/BedTabixAdapter/configSchema.js +1 -1
  14. package/esm/BedTabixAdapter/index.js +2 -2
  15. package/esm/BedpeAdapter/BedpeAdapter.js +9 -13
  16. package/esm/BedpeAdapter/configSchema.d.ts +2 -2
  17. package/esm/BedpeAdapter/index.js +2 -2
  18. package/esm/BedpeAdapter/util.js +1 -1
  19. package/esm/BigBedAdapter/BigBedAdapter.d.ts +1 -1
  20. package/esm/BigBedAdapter/BigBedAdapter.js +8 -9
  21. package/esm/BigBedAdapter/configSchema.d.ts +2 -2
  22. package/esm/BigBedAdapter/index.js +2 -2
  23. package/esm/generateRepeatMaskerFeature.js +2 -2
  24. package/esm/generateUcscTranscript.d.ts +18 -9
  25. package/esm/generateUcscTranscript.js +67 -84
  26. package/esm/index.js +8 -11
  27. package/esm/types.d.ts +2 -11
  28. package/esm/util.d.ts +11 -174
  29. package/esm/util.js +49 -48
  30. package/package.json +26 -33
  31. package/dist/BedAdapter/BedAdapter.d.ts +0 -36
  32. package/dist/BedAdapter/BedAdapter.js +0 -137
  33. package/dist/BedAdapter/configSchema.d.ts +0 -41
  34. package/dist/BedAdapter/configSchema.js +0 -58
  35. package/dist/BedAdapter/index.d.ts +0 -2
  36. package/dist/BedAdapter/index.js +0 -49
  37. package/dist/BedGraphAdapter/BedGraphAdapter.d.ts +0 -23
  38. package/dist/BedGraphAdapter/BedGraphAdapter.js +0 -122
  39. package/dist/BedGraphAdapter/configSchema.d.ts +0 -15
  40. package/dist/BedGraphAdapter/configSchema.js +0 -32
  41. package/dist/BedGraphAdapter/index.d.ts +0 -2
  42. package/dist/BedGraphAdapter/index.js +0 -49
  43. package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +0 -17
  44. package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.js +0 -107
  45. package/dist/BedGraphTabixAdapter/configSchema.d.ts +0 -29
  46. package/dist/BedGraphTabixAdapter/configSchema.js +0 -53
  47. package/dist/BedGraphTabixAdapter/index.d.ts +0 -2
  48. package/dist/BedGraphTabixAdapter/index.js +0 -49
  49. package/dist/BedTabixAdapter/BedTabixAdapter.d.ts +0 -43
  50. package/dist/BedTabixAdapter/BedTabixAdapter.js +0 -104
  51. package/dist/BedTabixAdapter/configSchema.d.ts +0 -39
  52. package/dist/BedTabixAdapter/configSchema.js +0 -63
  53. package/dist/BedTabixAdapter/index.d.ts +0 -2
  54. package/dist/BedTabixAdapter/index.js +0 -49
  55. package/dist/BedpeAdapter/BedpeAdapter.d.ts +0 -22
  56. package/dist/BedpeAdapter/BedpeAdapter.js +0 -111
  57. package/dist/BedpeAdapter/configSchema.d.ts +0 -16
  58. package/dist/BedpeAdapter/configSchema.js +0 -33
  59. package/dist/BedpeAdapter/index.d.ts +0 -2
  60. package/dist/BedpeAdapter/index.js +0 -49
  61. package/dist/BedpeAdapter/util.d.ts +0 -2
  62. package/dist/BedpeAdapter/util.js +0 -55
  63. package/dist/BigBedAdapter/BigBedAdapter.d.ts +0 -46
  64. package/dist/BigBedAdapter/BigBedAdapter.js +0 -230
  65. package/dist/BigBedAdapter/configSchema.d.ts +0 -20
  66. package/dist/BigBedAdapter/configSchema.js +0 -37
  67. package/dist/BigBedAdapter/index.d.ts +0 -2
  68. package/dist/BigBedAdapter/index.js +0 -49
  69. package/dist/GuessAdapter/index.d.ts +0 -2
  70. package/dist/GuessAdapter/index.js +0 -68
  71. package/dist/generateBedMethylFeature.d.ts +0 -31
  72. package/dist/generateBedMethylFeature.js +0 -32
  73. package/dist/generateRepeatMaskerFeature.d.ts +0 -51
  74. package/dist/generateRepeatMaskerFeature.js +0 -42
  75. package/dist/generateUcscTranscript.d.ts +0 -20
  76. package/dist/generateUcscTranscript.js +0 -123
  77. package/dist/index.d.ts +0 -6
  78. package/dist/index.js +0 -29
  79. package/dist/types.d.ts +0 -18
  80. package/dist/types.js +0 -2
  81. package/dist/util.d.ts +0 -213
  82. package/dist/util.js +0 -157
@@ -1,13 +1,29 @@
1
1
  export function isUcscTranscript({ thickStart, blockCount, strand, }) {
2
2
  return thickStart && blockCount && strand !== 0;
3
3
  }
4
+ function calculatePhasesFromCds(cdsRegions, strand) {
5
+ const sorted = [...cdsRegions].sort((a, b) => strand > 0 ? a.start - b.start : b.start - a.start);
6
+ const phaseMap = new Map();
7
+ let cumulativeWidth = 0;
8
+ for (const cds of sorted) {
9
+ const phase = (3 - (cumulativeWidth % 3)) % 3;
10
+ phaseMap.set(cds.start, phase);
11
+ cumulativeWidth += cds.end - cds.start;
12
+ }
13
+ return phaseMap;
14
+ }
15
+ function frameToPhase(frame) {
16
+ return (3 - frame) % 3;
17
+ }
4
18
  export function generateUcscTranscript(data) {
5
- const { strand = 0, chrom: _1, chromStart: _2, chromEnd: _3, chromStarts, blockStarts, blockSizes, uniqueId, ...rest } = data;
6
- const { subfeatures: oldSubfeatures, thickStart, thickEnd, blockCount, refName, ...rest2 } = rest;
7
- const subfeatures = [];
19
+ const { strand = 0, uniqueId, start, end, ...rest } = data;
20
+ const { subfeatures: oldSubfeatures, thickStart, thickEnd, refName, chrom: _1, chromStart: _2, chromEnd: _3, chromStarts: _4, blockStarts: _5, blockSizes: _6, blockCount: _7, ...rest2 } = rest;
21
+ const exonFrames = (rest2.exonFrames ?? rest2._exonFrames);
8
22
  const feats = oldSubfeatures
9
23
  .filter(child => child.type === 'block')
10
24
  .sort((a, b) => a.start - b.start);
25
+ const fiveUTR = strand > 0 ? 'five_prime_UTR' : 'three_prime_UTR';
26
+ const threeUTR = strand > 0 ? 'three_prime_UTR' : 'five_prime_UTR';
11
27
  const { cdsEndStat, cdsStartStat } = rest2;
12
28
  if (cdsStartStat === 'none' && cdsEndStat === 'none') {
13
29
  return {
@@ -16,97 +32,62 @@ export function generateUcscTranscript(data) {
16
32
  strand,
17
33
  type: 'transcript',
18
34
  refName,
19
- subfeatures: feats.map(e => ({
20
- ...e,
21
- type: 'exon',
22
- })),
35
+ start,
36
+ end,
37
+ subfeatures: feats.map(e => ({ ...e, type: 'exon' })),
23
38
  };
24
39
  }
25
- else {
40
+ let calculatedPhases;
41
+ if (!exonFrames) {
42
+ const cdsRegions = [];
26
43
  for (const block of feats) {
27
- const start = block.start;
28
- const end = block.end;
29
- if (thickStart >= end) {
30
- subfeatures.push({
31
- type: `${strand > 0 ? 'five' : 'three'}_prime_UTR`,
32
- start,
33
- end,
34
- refName,
35
- });
36
- }
37
- else if (thickStart > start && thickStart < end && thickEnd >= end) {
38
- subfeatures.push({
39
- type: `${strand > 0 ? 'five' : 'three'}_prime_UTR`,
40
- start,
41
- end: thickStart,
42
- refName,
43
- }, {
44
- type: 'CDS',
45
- phase: 0,
46
- start: thickStart,
47
- end,
48
- refName,
44
+ const { start, end } = block;
45
+ if (thickStart < end && thickEnd > start) {
46
+ cdsRegions.push({
47
+ start: Math.max(start, thickStart),
48
+ end: Math.min(end, thickEnd),
49
49
  });
50
50
  }
51
- else if (thickStart <= start && thickEnd >= end) {
52
- subfeatures.push({
53
- type: 'CDS',
54
- phase: 0,
55
- start,
56
- end,
57
- refName,
58
- });
51
+ }
52
+ calculatedPhases = calculatePhasesFromCds(cdsRegions, strand);
53
+ }
54
+ const subfeatures = [];
55
+ for (const [i, feat] of feats.entries()) {
56
+ const block = feat;
57
+ const { start, end } = block;
58
+ if (thickStart >= end) {
59
+ subfeatures.push({ type: fiveUTR, start, end, refName });
60
+ }
61
+ else if (thickEnd <= start) {
62
+ subfeatures.push({ type: threeUTR, start, end, refName });
63
+ }
64
+ else {
65
+ if (start < thickStart) {
66
+ subfeatures.push({ type: fiveUTR, start, end: thickStart, refName });
59
67
  }
60
- else if (thickStart > start && thickStart < end && thickEnd < end) {
61
- subfeatures.push({
62
- type: `${strand > 0 ? 'five' : 'three'}_prime_UTR`,
63
- start,
64
- end: thickStart,
65
- refName,
66
- }, {
67
- type: 'CDS',
68
- phase: 0,
69
- start: thickStart,
70
- end: thickEnd,
71
- refName,
72
- }, {
73
- type: `${strand > 0 ? 'three' : 'five'}_prime_UTR`,
74
- start: thickEnd,
75
- end,
76
- refName,
77
- });
68
+ const cdsStart = Math.max(start, thickStart);
69
+ const cdsEnd = Math.min(end, thickEnd);
70
+ let phase = 0;
71
+ if (exonFrames) {
72
+ const frame = exonFrames[i];
73
+ if (frame !== undefined && frame >= 0) {
74
+ phase = frameToPhase(frame);
75
+ }
78
76
  }
79
- else if (thickStart <= start && thickEnd > start && thickEnd < end) {
80
- subfeatures.push({
81
- type: 'CDS',
82
- phase: 0,
83
- start,
84
- end: thickEnd,
85
- refName,
86
- }, {
87
- type: `${strand > 0 ? 'three' : 'five'}_prime_UTR`,
88
- start: thickEnd,
89
- end,
90
- refName,
91
- });
77
+ else if (calculatedPhases) {
78
+ phase = calculatedPhases.get(cdsStart) ?? 0;
92
79
  }
93
- else if (thickEnd <= start) {
94
- subfeatures.push({
95
- type: `${strand > 0 ? 'three' : 'five'}_prime_UTR`,
96
- start,
97
- end,
98
- refName,
99
- });
80
+ subfeatures.push({
81
+ type: 'CDS',
82
+ phase,
83
+ start: cdsStart,
84
+ end: cdsEnd,
85
+ refName,
86
+ });
87
+ if (end > thickEnd) {
88
+ subfeatures.push({ type: threeUTR, start: thickEnd, end, refName });
100
89
  }
101
90
  }
102
- return {
103
- ...rest2,
104
- uniqueId,
105
- strand,
106
- type: 'mRNA',
107
- refName,
108
- subfeatures,
109
- };
110
91
  }
111
92
  return {
112
93
  ...rest2,
@@ -114,6 +95,8 @@ export function generateUcscTranscript(data) {
114
95
  strand,
115
96
  type: 'mRNA',
116
97
  refName,
98
+ start,
99
+ end,
117
100
  subfeatures,
118
101
  };
119
102
  }
package/esm/index.js CHANGED
@@ -1,16 +1,13 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import BedAdapterF from './BedAdapter';
3
- import BedGraphAdapterF from './BedGraphAdapter';
4
- import BedGraphTabixAdapterF from './BedGraphTabixAdapter';
5
- import BedTabixAdapterF from './BedTabixAdapter';
6
- import BedpeAdapterF from './BedpeAdapter';
7
- import BigBedAdapterF from './BigBedAdapter';
8
- import GuessAdapterF from './GuessAdapter';
2
+ import BedAdapterF from "./BedAdapter/index.js";
3
+ import BedGraphAdapterF from "./BedGraphAdapter/index.js";
4
+ import BedGraphTabixAdapterF from "./BedGraphTabixAdapter/index.js";
5
+ import BedTabixAdapterF from "./BedTabixAdapter/index.js";
6
+ import BedpeAdapterF from "./BedpeAdapter/index.js";
7
+ import BigBedAdapterF from "./BigBedAdapter/index.js";
8
+ import GuessAdapterF from "./GuessAdapter/index.js";
9
9
  export default class BedPlugin extends Plugin {
10
- constructor() {
11
- super(...arguments);
12
- this.name = 'BedPlugin';
13
- }
10
+ name = 'BedPlugin';
14
11
  install(pluginManager) {
15
12
  BigBedAdapterF(pluginManager);
16
13
  BedAdapterF(pluginManager);
package/esm/types.d.ts CHANGED
@@ -3,16 +3,7 @@ export interface MinimalFeature {
3
3
  start: number;
4
4
  end: number;
5
5
  refName: string;
6
+ uniqueId?: string;
7
+ phase?: number;
6
8
  [key: string]: unknown;
7
9
  }
8
- export interface TranscriptFeat extends MinimalFeature {
9
- uniqueId: string;
10
- thickStart: number;
11
- thickEnd: number;
12
- blockCount: number;
13
- blockSizes: number[];
14
- chromStarts: number[];
15
- refName: string;
16
- strand?: number;
17
- subfeatures: MinimalFeature[];
18
- }
package/esm/util.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { MinimalFeature } from './types';
1
2
  import type BED from '@gmod/bed';
2
3
  export declare function makeBlocks({ start, uniqueId, refName, chromStarts, blockCount, blockSizes, blockStarts, }: {
3
4
  blockCount: number;
@@ -23,95 +24,18 @@ export declare function featureData({ line, colRef, colStart, colEnd, scoreColum
23
24
  parser: BED;
24
25
  uniqueId: string;
25
26
  names?: 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
- } | {
27
+ }): FeatureData;
28
+ interface FeatureData {
88
29
  uniqueId: string;
89
- strand: number;
90
- type: string;
91
30
  refName: string;
92
- subfeatures: {
93
- type: string;
94
- start: number;
95
- end: number;
96
- refName: string;
97
- }[];
98
- start: number;
99
- end: number;
100
- } | {
101
- uniqueId: string;
102
- score: number | undefined;
103
31
  start: number;
104
32
  end: number;
105
- strand: any;
106
- refName: string;
107
- subfeatures: {
108
- uniqueId: string;
109
- start: number;
110
- end: number;
111
- refName: string;
112
- type: string;
113
- }[] | undefined;
114
- };
33
+ strand?: number | string;
34
+ score?: number;
35
+ type?: string;
36
+ subfeatures?: MinimalFeature[];
37
+ [key: string]: unknown;
38
+ }
115
39
  export declare function featureData2({ splitLine, refName, start, end, parser, uniqueId, scoreColumn, names, }: {
116
40
  splitLine: string[];
117
41
  refName: string;
@@ -121,93 +45,6 @@ export declare function featureData2({ splitLine, refName, start, end, parser, u
121
45
  uniqueId: string;
122
46
  scoreColumn: string;
123
47
  names?: string[];
124
- }): {
125
- uniqueId: string;
126
- refName: string;
127
- start: number;
128
- end: number;
129
- code: string | undefined;
130
- score: number;
131
- strand: string | undefined;
132
- color: string | undefined;
133
- source: string | undefined;
134
- n_valid_cov: string | undefined;
135
- fraction_modified: string | undefined;
136
- n_mod: string | undefined;
137
- n_canonical: string | undefined;
138
- n_other_mod: string | undefined;
139
- n_delete: string | undefined;
140
- n_fail: string | undefined;
141
- n_diff: string | undefined;
142
- n_nocall: string | undefined;
143
- } | {
144
- uniqueId: string;
145
- refName: string;
146
- start: number;
147
- end: number;
148
- bitsw_score: string | undefined;
149
- percent_div: string | undefined;
150
- percent_del: string | undefined;
151
- percent_ins: string | undefined;
152
- query_chr: string | undefined;
153
- query_begin: string | undefined;
154
- query_end: string | undefined;
155
- query_remaining: string | undefined;
156
- orientation: string | undefined;
157
- matching_repeat_name: string | undefined;
158
- matching_repeat_class: string | undefined;
159
- matching_repeat_begin: string | undefined;
160
- matching_repeat_end: string | undefined;
161
- matching_repeat_remaining: string | undefined;
162
- repeat_id: string | undefined;
163
- description?: undefined;
164
- } | {
165
- uniqueId: string;
166
- refName: string;
167
- start: number;
168
- end: number;
169
- description: undefined;
170
- bitsw_score?: undefined;
171
- percent_div?: undefined;
172
- percent_del?: undefined;
173
- percent_ins?: undefined;
174
- query_chr?: undefined;
175
- query_begin?: undefined;
176
- query_end?: undefined;
177
- query_remaining?: undefined;
178
- orientation?: undefined;
179
- matching_repeat_name?: undefined;
180
- matching_repeat_class?: undefined;
181
- matching_repeat_begin?: undefined;
182
- matching_repeat_end?: undefined;
183
- matching_repeat_remaining?: undefined;
184
- repeat_id?: undefined;
185
- } | {
186
- uniqueId: string;
187
- strand: number;
188
- type: string;
189
- refName: string;
190
- subfeatures: {
191
- type: string;
192
- start: number;
193
- end: number;
194
- refName: string;
195
- }[];
196
- start: number;
197
- end: number;
198
- } | {
199
- uniqueId: string;
200
- score: number | undefined;
201
- start: number;
202
- end: number;
203
- strand: any;
204
- refName: string;
205
- subfeatures: {
206
- uniqueId: string;
207
- start: number;
208
- end: number;
209
- refName: string;
210
- type: string;
211
- }[] | undefined;
212
- };
48
+ }): FeatureData;
213
49
  export declare function arrayify(f?: string | number[]): number[] | undefined;
50
+ export {};
package/esm/util.js CHANGED
@@ -1,16 +1,18 @@
1
- import { generateBedMethylFeature, isBedMethylFeature, } from './generateBedMethylFeature';
2
- import { generateRepeatMaskerFeature, isRepeatMaskerDescriptionField, } from './generateRepeatMaskerFeature';
3
- import { generateUcscTranscript, isUcscTranscript, } from './generateUcscTranscript';
1
+ import { generateBedMethylFeature, isBedMethylFeature, } from "./generateBedMethylFeature.js";
2
+ import { generateRepeatMaskerFeature, isRepeatMaskerDescriptionField, } from "./generateRepeatMaskerFeature.js";
3
+ import { generateUcscTranscript, isUcscTranscript, } from "./generateUcscTranscript.js";
4
4
  function defaultParser(fields, splitLine) {
5
+ const obj = {};
5
6
  let hasBlockCount = false;
6
- const r = [];
7
- for (let i = 0; i < splitLine.length; i++) {
8
- if (fields[i] === 'blockCount') {
9
- hasBlockCount = true;
7
+ for (const [i, element] of splitLine.entries()) {
8
+ const field = fields[i];
9
+ if (field) {
10
+ obj[field] = element;
11
+ if (field === 'blockCount') {
12
+ hasBlockCount = true;
13
+ }
10
14
  }
11
- r.push([fields[i], splitLine[i]]);
12
15
  }
13
- const obj = Object.fromEntries(r);
14
16
  if (hasBlockCount) {
15
17
  const { blockStarts, blockCount, chromStarts, thickEnd, thickStart, blockSizes, ...rest } = obj;
16
18
  return {
@@ -23,22 +25,19 @@ function defaultParser(fields, splitLine) {
23
25
  blockCount: blockCount ? +blockCount : undefined,
24
26
  };
25
27
  }
26
- else {
27
- return obj;
28
- }
28
+ return obj;
29
29
  }
30
30
  export function makeBlocks({ start, uniqueId, refName, chromStarts, blockCount, blockSizes, blockStarts, }) {
31
31
  const subfeatures = [];
32
- const starts = chromStarts || blockStarts || [];
32
+ const starts = chromStarts ?? blockStarts ?? [];
33
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];
34
+ const bmin = (starts[b] ?? 0) + start;
35
+ const bsize = blockSizes?.[b];
36
36
  if (bsize && bsize > 0) {
37
- const bmax = bmin + bsize;
38
37
  subfeatures.push({
39
38
  uniqueId: `${uniqueId}-${b}`,
40
39
  start: bmin,
41
- end: bmax,
40
+ end: bmin + bsize,
42
41
  refName,
43
42
  type: 'block',
44
43
  });
@@ -62,13 +61,22 @@ export function featureData({ line, colRef, colStart, colEnd, scoreColumn, parse
62
61
  names,
63
62
  });
64
63
  }
64
+ function parseStrand(strand) {
65
+ if (strand === '-' || strand === -1) {
66
+ return -1;
67
+ }
68
+ if (strand === '+' || strand === 1) {
69
+ return 1;
70
+ }
71
+ return 0;
72
+ }
65
73
  export function featureData2({ splitLine, refName, start, end, parser, uniqueId, scoreColumn, names, }) {
66
74
  const data = names
67
75
  ? defaultParser(names, splitLine)
68
76
  : parser.parseLine(splitLine, { uniqueId });
69
77
  const { strand: strand2, score: score2, chrom: _1, chromStart: _2, chromEnd: _3, ...rest } = data;
70
78
  const score = scoreColumn ? +data[scoreColumn] : score2 ? +score2 : undefined;
71
- const strand = typeof strand2 === 'string' ? (strand2 === '-' ? -1 : 1) : strand2;
79
+ const strand = parseStrand(strand2);
72
80
  const subfeatures = rest.blockCount
73
81
  ? makeBlocks({
74
82
  start,
@@ -89,13 +97,12 @@ export function featureData2({ splitLine, refName, start, end, parser, uniqueId,
89
97
  end,
90
98
  });
91
99
  }
92
- else if (isRepeatMaskerDescriptionField(rest.description)) {
93
- const { chromStarts, blockSizes, blockStarts, type, blockCount, thickStart, thickEnd, description, ...rest2 } = rest;
100
+ if (isRepeatMaskerDescriptionField(rest.description)) {
101
+ const { chromStarts: _4, blockSizes: _5, blockStarts: _6, blockCount: _7, thickStart: _8, thickEnd: _9, description, ...rest2 } = rest;
94
102
  return generateRepeatMaskerFeature({
95
103
  ...rest2,
96
- uniqueId,
97
104
  description,
98
- type,
105
+ uniqueId,
99
106
  score,
100
107
  start,
101
108
  end,
@@ -104,22 +111,14 @@ export function featureData2({ splitLine, refName, start, end, parser, uniqueId,
104
111
  subfeatures,
105
112
  });
106
113
  }
107
- else if (subfeatures &&
114
+ if (subfeatures &&
108
115
  isUcscTranscript({
109
116
  strand,
110
117
  blockCount: rest.blockCount,
111
118
  thickStart: rest.thickStart,
112
119
  })) {
113
- const { chromStarts, blockSizes, type, blockCount, thickStart, thickEnd, description, } = rest;
114
120
  return generateUcscTranscript({
115
121
  ...rest,
116
- description,
117
- chromStarts,
118
- thickStart,
119
- thickEnd,
120
- blockSizes,
121
- blockCount,
122
- type,
123
122
  score,
124
123
  start,
125
124
  end,
@@ -127,25 +126,27 @@ export function featureData2({ splitLine, refName, start, end, parser, uniqueId,
127
126
  refName,
128
127
  uniqueId,
129
128
  subfeatures,
129
+ thickStart: rest.thickStart,
130
+ thickEnd: rest.thickEnd,
130
131
  });
131
132
  }
132
- else {
133
- return {
134
- ...rest,
135
- uniqueId,
136
- score,
137
- start,
138
- end,
139
- strand,
140
- refName,
141
- subfeatures,
142
- };
143
- }
133
+ return {
134
+ ...rest,
135
+ uniqueId,
136
+ score,
137
+ start,
138
+ end,
139
+ strand,
140
+ refName,
141
+ subfeatures,
142
+ };
144
143
  }
145
144
  export function arrayify(f) {
146
- return f !== undefined
147
- ? typeof f === 'string'
148
- ? f.split(',').map(f => +f)
149
- : f
150
- : undefined;
145
+ if (f === undefined) {
146
+ return undefined;
147
+ }
148
+ if (typeof f === 'string') {
149
+ return f.split(',').map(s => +s);
150
+ }
151
+ return f;
151
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-bed",
3
- "version": "3.7.0",
3
+ "version": "4.0.1",
4
4
  "description": "JBrowse 2 bed adapters, tracks, etc.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -15,43 +15,36 @@
15
15
  "directory": "plugins/bed"
16
16
  },
17
17
  "author": "JBrowse Team",
18
- "distMain": "dist/index.js",
19
- "srcMain": "src/index.ts",
20
- "main": "dist/index.js",
18
+ "main": "esm/index.js",
21
19
  "files": [
22
- "dist",
23
20
  "esm"
24
21
  ],
25
- "scripts": {
26
- "build": "npm-run-all build:*",
27
- "test": "cd ../..; jest --passWithNoTests plugins/bed",
28
- "prepublishOnly": "yarn test",
29
- "prepack": "yarn build && yarn useDist",
30
- "postpack": "yarn useSrc",
31
- "useDist": "node ../../scripts/useDist.js",
32
- "useSrc": "node ../../scripts/useSrc.js",
33
- "prebuild": "npm run clean",
34
- "build:esm": "tsc --build tsconfig.build.esm.json",
35
- "build:commonjs": "tsc --build tsconfig.build.commonjs.json",
36
- "clean": "rimraf dist esm *.tsbuildinfo"
37
- },
38
22
  "dependencies": {
39
- "@flatten-js/interval-tree": "^2.0.0",
40
- "@gmod/bbi": "^7.0.0",
41
- "@gmod/bed": "^2.1.2",
42
- "@gmod/bgzf-filehandle": "^4.0.0",
43
- "@gmod/tabix": "^3.0.1",
44
- "@jbrowse/core": "^3.7.0",
45
- "mobx": "^6.0.0",
46
- "mobx-react": "^9.0.0",
47
- "mobx-state-tree": "^5.0.0",
48
- "rxjs": "^7.0.0"
23
+ "@flatten-js/interval-tree": "^2.0.3",
24
+ "@gmod/bbi": "^8.1.1",
25
+ "@gmod/bed": "^2.1.7",
26
+ "@gmod/tabix": "^3.2.2",
27
+ "@jbrowse/mobx-state-tree": "^5.5.0",
28
+ "mobx": "^6.15.0",
29
+ "rxjs": "^7.8.2",
30
+ "@jbrowse/core": "^4.0.1"
49
31
  },
50
32
  "publishConfig": {
51
33
  "access": "public"
52
34
  },
53
- "distModule": "esm/index.js",
54
- "srcModule": "src/index.ts",
55
- "module": "esm/index.js",
56
- "gitHead": "85bdd0d58286b7adbfd408146b15847676317635"
57
- }
35
+ "sideEffects": false,
36
+ "scripts": {
37
+ "build": "pnpm run /^build:/",
38
+ "test": "cd ../..; jest --passWithNoTests plugins/bed",
39
+ "prebuild": "pnpm clean",
40
+ "build:esm": "tsc -p tsconfig.build.esm.json",
41
+ "clean": "rimraf esm *.tsbuildinfo"
42
+ },
43
+ "types": "esm/index.d.ts",
44
+ "exports": {
45
+ ".": {
46
+ "types": "./esm/index.d.ts",
47
+ "import": "./esm/index.js"
48
+ }
49
+ }
50
+ }