@jbrowse/plugin-gtf 1.7.11 → 2.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.
package/esm/util.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ export declare type Strand = '+' | '-' | '.' | '?';
2
+ export interface FeatureLoc {
3
+ [key: string]: unknown;
4
+ start: number;
5
+ end: number;
6
+ strand: Strand;
7
+ seq_name: string;
8
+ child_features: FeatureLoc[][];
9
+ data: unknown;
10
+ derived_features: unknown;
11
+ attributes: {
12
+ [key: string]: unknown[];
13
+ };
14
+ }
15
+ export declare function featureData(data: FeatureLoc): Record<string, unknown>;
package/esm/util.js ADDED
@@ -0,0 +1,62 @@
1
+ export function featureData(data) {
2
+ const f = { ...data };
3
+ f.start -= 1; // convert to interbase
4
+ f.strand = { '+': 1, '-': -1, '.': 0, '?': undefined }[data.strand]; // convert strand
5
+ f.phase = Number(data.frame);
6
+ f.refName = data.seq_name;
7
+ if (data.score === null) {
8
+ delete f.score;
9
+ }
10
+ if (data.frame === null) {
11
+ delete f.score;
12
+ }
13
+ const defaultFields = [
14
+ 'start',
15
+ 'end',
16
+ 'seq_name',
17
+ 'score',
18
+ 'featureType',
19
+ 'source',
20
+ 'frame',
21
+ 'strand',
22
+ ];
23
+ Object.keys(data.attributes).forEach(a => {
24
+ let b = a.toLowerCase();
25
+ if (defaultFields.includes(b)) {
26
+ // add "suffix" to tag name if it already exists
27
+ // reproduces behavior of NCList
28
+ b += '2';
29
+ }
30
+ if (data.attributes[a] !== null) {
31
+ let attr = data.attributes[a];
32
+ if (Array.isArray(attr) && attr.length === 1) {
33
+ // gtf uses double quotes for text values in the attributes column, remove them
34
+ const formattedAttr = attr[0].replace(/^"|"$/g, '');
35
+ attr = formattedAttr;
36
+ }
37
+ f[b] = attr;
38
+ }
39
+ });
40
+ f.refName = f.seq_name;
41
+ f.type = f.featureType;
42
+ // the SimpleFeature constructor takes care of recursively inflating subfeatures
43
+ if (data.child_features && data.child_features.length) {
44
+ f.subfeatures = data.child_features
45
+ .map(childLocs => childLocs.map(childLoc => featureData(childLoc)))
46
+ .flat();
47
+ }
48
+ delete f.child_features;
49
+ delete f.data;
50
+ delete f.derived_features;
51
+ // eslint-disable-next-line no-underscore-dangle
52
+ delete f._linehash;
53
+ delete f.attributes;
54
+ delete f.seq_name;
55
+ delete f.featureType;
56
+ delete f.frame;
57
+ if (f.transcript_id) {
58
+ f.name = f.transcript_id;
59
+ }
60
+ return f;
61
+ }
62
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,WAAW,CAAC,IAAgB;IAC1C,MAAM,CAAC,GAA4B,EAAE,GAAG,IAAI,EAAE,CAC7C;IAAC,CAAC,CAAC,KAAgB,IAAI,CAAC,CAAA,CAAC,uBAAuB;IACjD,CAAC,CAAC,MAAM,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAC,iBAAiB;IACrF,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAA;IACzB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE;QACvB,OAAO,CAAC,CAAC,KAAK,CAAA;KACf;IACD,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE;QACvB,OAAO,CAAC,CAAC,KAAK,CAAA;KACf;IACD,MAAM,aAAa,GAAG;QACpB,OAAO;QACP,KAAK;QACL,UAAU;QACV,OAAO;QACP,aAAa;QACb,QAAQ;QACR,OAAO;QACP,QAAQ;KACT,CAAA;IACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,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AAA;IAClB,OAAO,CAAC,CAAC,UAAU,CAAA;IACnB,OAAO,CAAC,CAAC,QAAQ,CAAA;IACjB,OAAO,CAAC,CAAC,WAAW,CAAA;IACpB,OAAO,CAAC,CAAC,KAAK,CAAA;IAEd,IAAI,CAAC,CAAC,aAAa,EAAE;QACnB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,aAAa,CAAA;KACzB;IACD,OAAO,CAAC,CAAA;AACV,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-gtf",
3
- "version": "1.7.11",
3
+ "version": "2.0.0",
4
4
  "description": "JBrowse 2 gtf feature adapter",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -20,17 +20,21 @@
20
20
  "main": "dist/index.js",
21
21
  "files": [
22
22
  "dist",
23
- "src"
23
+ "src",
24
+ "esm"
24
25
  ],
25
26
  "scripts": {
26
- "build": "babel src --root-mode upward --out-dir dist --extensions .ts,.js,.tsx,.jsx",
27
+ "build": "npm-run-all build:*",
27
28
  "test": "cd ../..; jest plugins/gtf --passWithNoTests",
28
29
  "prepublishOnly": "yarn test",
29
30
  "prepack": "yarn build; yarn useDist",
30
31
  "postpack": "yarn useSrc",
31
32
  "useDist": "node ../../scripts/useDist.js",
32
33
  "useSrc": "node ../../scripts/useSrc.js",
33
- "postbuild": "tsc --build tsconfig.build.json"
34
+ "prebuild": "npm run clean",
35
+ "build:esm": "tsc --build tsconfig.build.esm.json",
36
+ "build:es5": "tsc --build tsconfig.build.es5.json",
37
+ "clean": "rimraf dist esm *.tsbuildinfo"
34
38
  },
35
39
  "dependencies": {
36
40
  "@babel/runtime": "^7.17.9",
@@ -41,9 +45,10 @@
41
45
  "peerDependencies": {
42
46
  "@jbrowse/core": "^1.0.0",
43
47
  "@jbrowse/plugin-linear-genome-view": "^1.0.0",
44
- "@material-ui/core": "^4.12.2",
45
- "mobx-react": "^6.0.0",
46
- "mobx-state-tree": "3.14.1",
48
+ "@mui/material": "^5.0.0",
49
+ "mobx": "^6.0.0",
50
+ "mobx-react": "^7.0.0",
51
+ "mobx-state-tree": "^5.0.0",
47
52
  "prop-types": "^15.0.0",
48
53
  "react": ">=16.8.0",
49
54
  "rxjs": "^6.0.0"
@@ -51,5 +56,8 @@
51
56
  "publishConfig": {
52
57
  "access": "public"
53
58
  },
54
- "gitHead": "5c21beb48a21f08b0091d293f09ac99174c48f77"
59
+ "distModule": "esm/index.js",
60
+ "srcModule": "src/index.ts",
61
+ "module": "esm/index.js",
62
+ "gitHead": "ecc7f5d47351a5ea04bc00f3a6eb6dfb607342e6"
55
63
  }
@@ -1,127 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
6
-
7
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
-
9
- var _operators = require("rxjs/operators");
10
-
11
- var _configSchema = _interopRequireDefault(require("./configSchema"));
12
-
13
- var _GtfAdapter = _interopRequireDefault(require("./GtfAdapter"));
14
-
15
- var _webEncoding = require("web-encoding");
16
-
17
- window.TextDecoder = _webEncoding.TextDecoder;
18
- describe('adapter can fetch features from volvox.sorted.gtf', function () {
19
- var adapter;
20
- beforeEach(function () {
21
- adapter = new _GtfAdapter.default(_configSchema.default.create({
22
- gtfLocation: {
23
- localPath: require.resolve('../test_data/volvox.sorted.gtf')
24
- }
25
- }));
26
- });
27
- it('test getfeatures on gtf plain text adapter', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
28
- var features, featuresArray, featuresJsonArray;
29
- return _regenerator.default.wrap(function _callee$(_context) {
30
- while (1) {
31
- switch (_context.prev = _context.next) {
32
- case 0:
33
- features = adapter.getFeatures({
34
- refName: 'ctgA',
35
- start: 0,
36
- end: 100000
37
- });
38
- _context.t0 = expect;
39
- _context.next = 4;
40
- return adapter.hasDataForRefName('ctgA');
41
-
42
- case 4:
43
- _context.t1 = _context.sent;
44
- (0, _context.t0)(_context.t1).toBe(true);
45
- _context.t2 = expect;
46
- _context.next = 9;
47
- return adapter.hasDataForRefName('ctgB');
48
-
49
- case 9:
50
- _context.t3 = _context.sent;
51
- (0, _context.t2)(_context.t3).toBe(false);
52
- _context.next = 13;
53
- return features.pipe((0, _operators.toArray)()).toPromise();
54
-
55
- case 13:
56
- featuresArray = _context.sent;
57
- // There are only 4 features in ctgB
58
- expect(featuresArray.length).toBe(6);
59
- featuresJsonArray = featuresArray.map(function (f) {
60
- return f.toJSON();
61
- });
62
- expect(featuresJsonArray).toMatchSnapshot();
63
-
64
- case 17:
65
- case "end":
66
- return _context.stop();
67
- }
68
- }
69
- }, _callee);
70
- })));
71
- });
72
- test('can instantiate new GtfAdapter and check for demo data', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
73
- var demoAdapter, features, featuresArray, featuresJsonArray;
74
- return _regenerator.default.wrap(function _callee2$(_context2) {
75
- while (1) {
76
- switch (_context2.prev = _context2.next) {
77
- case 0:
78
- demoAdapter = new _GtfAdapter.default(_configSchema.default.create({
79
- gtfLocation: {
80
- localPath: require.resolve('../test_data/demo.gtf')
81
- }
82
- }));
83
- _context2.t0 = expect;
84
- _context2.next = 4;
85
- return demoAdapter.hasDataForRefName('GeneScaffold_1');
86
-
87
- case 4:
88
- _context2.t1 = _context2.sent;
89
- (0, _context2.t0)(_context2.t1).toBe(true);
90
- _context2.t2 = expect;
91
- _context2.next = 9;
92
- return demoAdapter.hasDataForRefName('GeneScaffold_10');
93
-
94
- case 9:
95
- _context2.t3 = _context2.sent;
96
- (0, _context2.t2)(_context2.t3).toBe(true);
97
- _context2.t4 = expect;
98
- _context2.next = 14;
99
- return demoAdapter.hasDataForRefName('GeneScaffold_11');
100
-
101
- case 14:
102
- _context2.t5 = _context2.sent;
103
- (0, _context2.t4)(_context2.t5).toBe(false);
104
- features = demoAdapter.getFeatures({
105
- refName: 'GeneScaffold_1',
106
- start: 0,
107
- end: 1100000
108
- });
109
- _context2.next = 19;
110
- return features.pipe((0, _operators.toArray)()).toPromise();
111
-
112
- case 19:
113
- featuresArray = _context2.sent;
114
- featuresJsonArray = featuresArray.map(function (f) {
115
- return f.toJSON();
116
- }); // ENSVPAT00000000407
117
-
118
- expect(featuresArray.length).toEqual(1);
119
- expect(featuresJsonArray).toMatchSnapshot();
120
-
121
- case 23:
122
- case "end":
123
- return _context2.stop();
124
- }
125
- }
126
- }, _callee2);
127
- })));
package/dist/declare.d.js DELETED
@@ -1 +0,0 @@
1
- "use strict";