@jbrowse/plugin-gtf 2.16.1 → 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.
- package/dist/GtfAdapter/GtfAdapter.d.ts +4 -3
- package/dist/GtfAdapter/GtfAdapter.js +8 -13
- package/dist/GtfAdapter/configSchema.d.ts +0 -3
- package/dist/GtfAdapter/configSchema.js +1 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/util.js +2 -7
- package/esm/GtfAdapter/GtfAdapter.d.ts +4 -3
- package/esm/GtfAdapter/GtfAdapter.js +9 -14
- package/esm/GtfAdapter/configSchema.d.ts +0 -3
- package/esm/GtfAdapter/configSchema.js +1 -8
- package/esm/index.d.ts +1 -1
- package/esm/index.js +2 -2
- package/esm/util.js +2 -7
- package/package.json +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
1
|
import IntervalTree from '@flatten-js/interval-tree';
|
|
4
|
-
import {
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
import type { Feature } from '@jbrowse/core/util';
|
|
5
|
+
import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
5
6
|
type StatusCallback = (arg: string) => void;
|
|
6
7
|
export default class GtfAdapter extends BaseFeatureDataAdapter {
|
|
7
8
|
calculatedIntervalTreeMap: Record<string, IntervalTree>;
|
|
@@ -3,16 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const interval_tree_1 = __importDefault(require("@flatten-js/interval-tree"));
|
|
6
7
|
const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
8
|
+
const util_1 = require("@jbrowse/core/util");
|
|
7
9
|
const io_1 = require("@jbrowse/core/util/io");
|
|
8
10
|
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
9
|
-
const interval_tree_1 = __importDefault(require("@flatten-js/interval-tree"));
|
|
10
|
-
const util_1 = require("@jbrowse/core/util");
|
|
11
|
-
const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
12
11
|
const gtf_nostream_1 = require("gtf-nostream");
|
|
13
|
-
// locals
|
|
14
12
|
const util_2 = require("../util");
|
|
15
|
-
const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
|
|
16
13
|
class GtfAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
17
14
|
constructor() {
|
|
18
15
|
super(...arguments);
|
|
@@ -20,19 +17,17 @@ class GtfAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
20
17
|
}
|
|
21
18
|
async loadDataP(opts) {
|
|
22
19
|
const { statusCallback = () => { } } = opts || {};
|
|
23
|
-
const
|
|
24
|
-
const buffer = (0, util_1.
|
|
25
|
-
? await (0, util_1.updateStatus)('Unzipping', statusCallback, () => (0, bgzf_filehandle_1.unzip)(buf))
|
|
26
|
-
: buf;
|
|
20
|
+
const loc = (0, io_1.openLocation)(this.getConf('gtfLocation'), this.pluginManager);
|
|
21
|
+
const buffer = await (0, util_1.fetchAndMaybeUnzip)(loc, opts);
|
|
27
22
|
const headerLines = [];
|
|
28
23
|
const featureMap = {};
|
|
29
24
|
let blockStart = 0;
|
|
30
25
|
let i = 0;
|
|
26
|
+
const decoder = new TextDecoder('utf8');
|
|
31
27
|
while (blockStart < buffer.length) {
|
|
32
28
|
const n = buffer.indexOf('\n', blockStart);
|
|
33
|
-
// could be a non-newline ended file, so slice to end of file if n===-1
|
|
34
29
|
const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
|
|
35
|
-
const line =
|
|
30
|
+
const line = decoder.decode(b).trim();
|
|
36
31
|
if (line) {
|
|
37
32
|
if (line.startsWith('#')) {
|
|
38
33
|
headerLines.push(line);
|
|
@@ -108,8 +103,8 @@ class GtfAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
108
103
|
catch (e) {
|
|
109
104
|
observer.error(e);
|
|
110
105
|
}
|
|
111
|
-
}, opts.
|
|
106
|
+
}, opts.stopToken);
|
|
112
107
|
}
|
|
113
|
-
freeResources(
|
|
108
|
+
freeResources() { }
|
|
114
109
|
}
|
|
115
110
|
exports.default = GtfAdapter;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
|
-
|
|
5
|
-
* #config GtfAdapter
|
|
6
|
-
* #category adapter
|
|
7
|
-
*/
|
|
8
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
function x() { }
|
|
9
5
|
const GtfAdapter = (0, configuration_1.ConfigurationSchema)('GtfAdapter', {
|
|
10
|
-
/**
|
|
11
|
-
* #slot
|
|
12
|
-
*/
|
|
13
6
|
gtfLocation: {
|
|
14
7
|
type: 'fileLocation',
|
|
15
8
|
defaultValue: { uri: '/path/to/my.gtf', locationType: 'UriLocation' },
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
2
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
3
3
|
export default class GtfPlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
install(pluginManager: PluginManager): void;
|
package/dist/index.js
CHANGED
|
@@ -26,10 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
|
|
30
29
|
const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
|
|
31
|
-
const
|
|
30
|
+
const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
|
|
32
31
|
const tracks_1 = require("@jbrowse/core/util/tracks");
|
|
32
|
+
const GtfAdapter_1 = require("./GtfAdapter");
|
|
33
33
|
class GtfPlugin extends Plugin_1.default {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
package/dist/util.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.featureData = featureData;
|
|
4
4
|
function featureData(data) {
|
|
5
5
|
const f = { ...data };
|
|
6
|
-
f.start -= 1;
|
|
7
|
-
f.strand = { '+': 1, '-': -1, '.': 0, '?': undefined }[data.strand];
|
|
6
|
+
f.start -= 1;
|
|
7
|
+
f.strand = { '+': 1, '-': -1, '.': 0, '?': undefined }[data.strand];
|
|
8
8
|
f.phase = Number(data.frame);
|
|
9
9
|
f.refName = data.seq_name;
|
|
10
10
|
if (data.score === null) {
|
|
@@ -26,15 +26,11 @@ function featureData(data) {
|
|
|
26
26
|
for (const a of Object.keys(data.attributes)) {
|
|
27
27
|
let b = a.toLowerCase();
|
|
28
28
|
if (defaultFields.has(b)) {
|
|
29
|
-
// add "suffix" to tag name if it already exists
|
|
30
|
-
// reproduces behavior of NCList
|
|
31
29
|
b += '2';
|
|
32
30
|
}
|
|
33
31
|
if (data.attributes[a]) {
|
|
34
32
|
let attr = data.attributes[a];
|
|
35
33
|
if (Array.isArray(attr) && attr.length === 1) {
|
|
36
|
-
// gtf uses double quotes for text values in the attributes column,
|
|
37
|
-
// remove them
|
|
38
34
|
attr = attr[0].replaceAll(/^"|"$/g, '');
|
|
39
35
|
}
|
|
40
36
|
f[b] = attr;
|
|
@@ -42,7 +38,6 @@ function featureData(data) {
|
|
|
42
38
|
}
|
|
43
39
|
f.refName = f.seq_name;
|
|
44
40
|
f.type = f.featureType;
|
|
45
|
-
// the SimpleFeature constructor takes care of recursively inflating subfeatures
|
|
46
41
|
if (data.child_features && data.child_features.length > 0) {
|
|
47
42
|
f.subfeatures = data.child_features.flatMap(childLocs => childLocs.map(childLoc => featureData(childLoc)));
|
|
48
43
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
1
|
import IntervalTree from '@flatten-js/interval-tree';
|
|
4
|
-
import {
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
import type { Feature } from '@jbrowse/core/util';
|
|
5
|
+
import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
5
6
|
type StatusCallback = (arg: string) => void;
|
|
6
7
|
export default class GtfAdapter extends BaseFeatureDataAdapter {
|
|
7
8
|
calculatedIntervalTreeMap: Record<string, IntervalTree>;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import IntervalTree from '@flatten-js/interval-tree';
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import { SimpleFeature, fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
2
4
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
5
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
4
|
-
import IntervalTree from '@flatten-js/interval-tree';
|
|
5
|
-
import { SimpleFeature, updateStatus, isGzip, } from '@jbrowse/core/util';
|
|
6
|
-
import { unzip } from '@gmod/bgzf-filehandle';
|
|
7
6
|
import { parseStringSync } from 'gtf-nostream';
|
|
8
|
-
// locals
|
|
9
7
|
import { featureData } from '../util';
|
|
10
|
-
const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
|
|
11
8
|
export default class GtfAdapter extends BaseFeatureDataAdapter {
|
|
12
9
|
constructor() {
|
|
13
10
|
super(...arguments);
|
|
@@ -15,19 +12,17 @@ export default class GtfAdapter extends BaseFeatureDataAdapter {
|
|
|
15
12
|
}
|
|
16
13
|
async loadDataP(opts) {
|
|
17
14
|
const { statusCallback = () => { } } = opts || {};
|
|
18
|
-
const
|
|
19
|
-
const buffer =
|
|
20
|
-
? await updateStatus('Unzipping', statusCallback, () => unzip(buf))
|
|
21
|
-
: buf;
|
|
15
|
+
const loc = openLocation(this.getConf('gtfLocation'), this.pluginManager);
|
|
16
|
+
const buffer = await fetchAndMaybeUnzip(loc, opts);
|
|
22
17
|
const headerLines = [];
|
|
23
18
|
const featureMap = {};
|
|
24
19
|
let blockStart = 0;
|
|
25
20
|
let i = 0;
|
|
21
|
+
const decoder = new TextDecoder('utf8');
|
|
26
22
|
while (blockStart < buffer.length) {
|
|
27
23
|
const n = buffer.indexOf('\n', blockStart);
|
|
28
|
-
// could be a non-newline ended file, so slice to end of file if n===-1
|
|
29
24
|
const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
|
|
30
|
-
const line =
|
|
25
|
+
const line = decoder.decode(b).trim();
|
|
31
26
|
if (line) {
|
|
32
27
|
if (line.startsWith('#')) {
|
|
33
28
|
headerLines.push(line);
|
|
@@ -103,7 +98,7 @@ export default class GtfAdapter extends BaseFeatureDataAdapter {
|
|
|
103
98
|
catch (e) {
|
|
104
99
|
observer.error(e);
|
|
105
100
|
}
|
|
106
|
-
}, opts.
|
|
101
|
+
}, opts.stopToken);
|
|
107
102
|
}
|
|
108
|
-
freeResources(
|
|
103
|
+
freeResources() { }
|
|
109
104
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
3
|
-
* #config GtfAdapter
|
|
4
|
-
* #category adapter
|
|
5
|
-
*/
|
|
6
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
function x() { }
|
|
7
3
|
const GtfAdapter = ConfigurationSchema('GtfAdapter', {
|
|
8
|
-
/**
|
|
9
|
-
* #slot
|
|
10
|
-
*/
|
|
11
4
|
gtfLocation: {
|
|
12
5
|
type: 'fileLocation',
|
|
13
6
|
defaultValue: { uri: '/path/to/my.gtf', locationType: 'UriLocation' },
|
package/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
2
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
3
3
|
export default class GtfPlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
install(pluginManager: PluginManager): void;
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
2
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
3
|
-
import
|
|
2
|
+
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
4
3
|
import { getFileName } from '@jbrowse/core/util/tracks';
|
|
4
|
+
import { configSchema as gtfAdapterConfigSchema } from './GtfAdapter';
|
|
5
5
|
export default class GtfPlugin extends Plugin {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
package/esm/util.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function featureData(data) {
|
|
2
2
|
const f = { ...data };
|
|
3
|
-
f.start -= 1;
|
|
4
|
-
f.strand = { '+': 1, '-': -1, '.': 0, '?': undefined }[data.strand];
|
|
3
|
+
f.start -= 1;
|
|
4
|
+
f.strand = { '+': 1, '-': -1, '.': 0, '?': undefined }[data.strand];
|
|
5
5
|
f.phase = Number(data.frame);
|
|
6
6
|
f.refName = data.seq_name;
|
|
7
7
|
if (data.score === null) {
|
|
@@ -23,15 +23,11 @@ export function featureData(data) {
|
|
|
23
23
|
for (const a of Object.keys(data.attributes)) {
|
|
24
24
|
let b = a.toLowerCase();
|
|
25
25
|
if (defaultFields.has(b)) {
|
|
26
|
-
// add "suffix" to tag name if it already exists
|
|
27
|
-
// reproduces behavior of NCList
|
|
28
26
|
b += '2';
|
|
29
27
|
}
|
|
30
28
|
if (data.attributes[a]) {
|
|
31
29
|
let attr = data.attributes[a];
|
|
32
30
|
if (Array.isArray(attr) && attr.length === 1) {
|
|
33
|
-
// gtf uses double quotes for text values in the attributes column,
|
|
34
|
-
// remove them
|
|
35
31
|
attr = attr[0].replaceAll(/^"|"$/g, '');
|
|
36
32
|
}
|
|
37
33
|
f[b] = attr;
|
|
@@ -39,7 +35,6 @@ export function featureData(data) {
|
|
|
39
35
|
}
|
|
40
36
|
f.refName = f.seq_name;
|
|
41
37
|
f.type = f.featureType;
|
|
42
|
-
// the SimpleFeature constructor takes care of recursively inflating subfeatures
|
|
43
38
|
if (data.child_features && data.child_features.length > 0) {
|
|
44
39
|
f.subfeatures = data.child_features.flatMap(childLocs => childLocs.map(childLoc => featureData(childLoc)));
|
|
45
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-gtf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "JBrowse 2 gtf feature adapter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"distModule": "esm/index.js",
|
|
57
57
|
"srcModule": "src/index.ts",
|
|
58
58
|
"module": "esm/index.js",
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "c344ea60099cb7e460b77f15808946b24a7eee74"
|
|
60
60
|
}
|