@jbrowse/plugin-gtf 3.6.3 → 3.6.5

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.
@@ -7,6 +7,7 @@ const interval_tree_1 = __importDefault(require("@flatten-js/interval-tree"));
7
7
  const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
8
8
  const util_1 = require("@jbrowse/core/util");
9
9
  const io_1 = require("@jbrowse/core/util/io");
10
+ const parseLineByLine_1 = require("@jbrowse/core/util/parseLineByLine");
10
11
  const rxjs_1 = require("@jbrowse/core/util/rxjs");
11
12
  const gtf_nostream_1 = require("gtf-nostream");
12
13
  const util_2 = require("../util");
@@ -16,39 +17,27 @@ class GtfAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
16
17
  this.calculatedIntervalTreeMap = {};
17
18
  }
18
19
  async loadDataP(opts) {
19
- const { statusCallback = () => { } } = opts || {};
20
20
  const loc = (0, io_1.openLocation)(this.getConf('gtfLocation'), this.pluginManager);
21
21
  const buffer = await (0, util_1.fetchAndMaybeUnzip)(loc, opts);
22
22
  const headerLines = [];
23
23
  const featureMap = {};
24
- let blockStart = 0;
25
- let i = 0;
26
- const decoder = new TextDecoder('utf8');
27
- while (blockStart < buffer.length) {
28
- const n = buffer.indexOf(10, blockStart);
29
- const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
30
- const line = decoder.decode(b).trim();
31
- if (line) {
32
- if (line.startsWith('#')) {
33
- headerLines.push(line);
34
- }
35
- else if (line.startsWith('>')) {
36
- break;
37
- }
38
- else {
39
- const ret = line.indexOf('\t');
40
- const refName = line.slice(0, ret);
41
- if (!featureMap[refName]) {
42
- featureMap[refName] = '';
43
- }
44
- featureMap[refName] += `${line}\n`;
45
- }
24
+ (0, parseLineByLine_1.parseLineByLine)(buffer, line => {
25
+ if (line.startsWith('#')) {
26
+ headerLines.push(line);
46
27
  }
47
- if (i++ % 10000 === 0) {
48
- statusCallback(`Loading ${(0, util_1.getProgressDisplayStr)(blockStart, buffer.length)}`);
28
+ else if (line.startsWith('>')) {
29
+ return false;
49
30
  }
50
- blockStart = n + 1;
51
- }
31
+ else {
32
+ const ret = line.indexOf('\t');
33
+ const refName = line.slice(0, ret);
34
+ if (!featureMap[refName]) {
35
+ featureMap[refName] = '';
36
+ }
37
+ featureMap[refName] += `${line}\n`;
38
+ }
39
+ return true;
40
+ }, opts === null || opts === void 0 ? void 0 : opts.statusCallback);
52
41
  const intervalTreeMap = Object.fromEntries(Object.entries(featureMap).map(([refName, lines]) => [
53
42
  refName,
54
43
  (sc) => {
@@ -1,7 +1,8 @@
1
1
  import IntervalTree from '@flatten-js/interval-tree';
2
2
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
- import { SimpleFeature, doesIntersect2, fetchAndMaybeUnzip, getProgressDisplayStr, max, min, } from '@jbrowse/core/util';
3
+ import { SimpleFeature, doesIntersect2, fetchAndMaybeUnzip, max, min, } from '@jbrowse/core/util';
4
4
  import { openLocation } from '@jbrowse/core/util/io';
5
+ import { parseLineByLine } from '@jbrowse/core/util/parseLineByLine';
5
6
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
6
7
  import { parseStringSync } from 'gtf-nostream';
7
8
  import { featureData } from '../util';
@@ -11,39 +12,27 @@ export default class GtfAdapter extends BaseFeatureDataAdapter {
11
12
  this.calculatedIntervalTreeMap = {};
12
13
  }
13
14
  async loadDataP(opts) {
14
- const { statusCallback = () => { } } = opts || {};
15
15
  const loc = openLocation(this.getConf('gtfLocation'), this.pluginManager);
16
16
  const buffer = await fetchAndMaybeUnzip(loc, opts);
17
17
  const headerLines = [];
18
18
  const featureMap = {};
19
- let blockStart = 0;
20
- let i = 0;
21
- const decoder = new TextDecoder('utf8');
22
- while (blockStart < buffer.length) {
23
- const n = buffer.indexOf(10, blockStart);
24
- const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
25
- const line = decoder.decode(b).trim();
26
- if (line) {
27
- if (line.startsWith('#')) {
28
- headerLines.push(line);
29
- }
30
- else if (line.startsWith('>')) {
31
- break;
32
- }
33
- else {
34
- const ret = line.indexOf('\t');
35
- const refName = line.slice(0, ret);
36
- if (!featureMap[refName]) {
37
- featureMap[refName] = '';
38
- }
39
- featureMap[refName] += `${line}\n`;
40
- }
19
+ parseLineByLine(buffer, line => {
20
+ if (line.startsWith('#')) {
21
+ headerLines.push(line);
41
22
  }
42
- if (i++ % 10000 === 0) {
43
- statusCallback(`Loading ${getProgressDisplayStr(blockStart, buffer.length)}`);
23
+ else if (line.startsWith('>')) {
24
+ return false;
44
25
  }
45
- blockStart = n + 1;
46
- }
26
+ else {
27
+ const ret = line.indexOf('\t');
28
+ const refName = line.slice(0, ret);
29
+ if (!featureMap[refName]) {
30
+ featureMap[refName] = '';
31
+ }
32
+ featureMap[refName] += `${line}\n`;
33
+ }
34
+ return true;
35
+ }, opts === null || opts === void 0 ? void 0 : opts.statusCallback);
47
36
  const intervalTreeMap = Object.fromEntries(Object.entries(featureMap).map(([refName, lines]) => [
48
37
  refName,
49
38
  (sc) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-gtf",
3
- "version": "3.6.3",
3
+ "version": "3.6.5",
4
4
  "description": "JBrowse 2 gtf feature adapter",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -38,8 +38,8 @@
38
38
  "dependencies": {
39
39
  "@flatten-js/interval-tree": "^1.0.15",
40
40
  "@gmod/bgzf-filehandle": "^4.0.0",
41
- "@jbrowse/core": "^3.6.3",
42
- "@jbrowse/plugin-linear-genome-view": "^3.6.3",
41
+ "@jbrowse/core": "^3.6.5",
42
+ "@jbrowse/plugin-linear-genome-view": "^3.6.5",
43
43
  "@mui/material": "^7.0.0",
44
44
  "gtf-nostream": "^1.0.0",
45
45
  "mobx": "^6.0.0",
@@ -56,5 +56,5 @@
56
56
  "distModule": "esm/index.js",
57
57
  "srcModule": "src/index.ts",
58
58
  "module": "esm/index.js",
59
- "gitHead": "cf3dd1c895b4f3f7367093d57a0b607f54b8d7db"
59
+ "gitHead": "354d0a87b757b4d84f824b47507662f6f3a1693f"
60
60
  }