gff-nostream 1.3.7 → 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/dist/api.d.ts +23 -2
- package/dist/api.js +58 -3
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -0
- package/dist/parse.d.ts +3 -16
- package/dist/parse.js +78 -120
- package/dist/parse.js.map +1 -1
- package/dist/util.d.ts +1 -0
- package/dist/util.js +92 -59
- package/dist/util.js.map +1 -1
- package/esm/api.d.ts +23 -2
- package/esm/api.js +55 -2
- package/esm/api.js.map +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js +2 -2
- package/esm/index.js.map +1 -1
- package/esm/parse.d.ts +3 -16
- package/esm/parse.js +101 -138
- package/esm/parse.js.map +1 -1
- package/esm/util.d.ts +1 -0
- package/esm/util.js +82 -58
- package/esm/util.js.map +1 -1
- package/package.json +31 -20
- package/src/api.ts +77 -12
- package/src/index.ts +6 -5
- package/src/parse.ts +76 -141
- package/src/util.ts +91 -62
package/esm/parse.js
CHANGED
|
@@ -1,57 +1,38 @@
|
|
|
1
|
-
import * as GFF3 from
|
|
1
|
+
import * as GFF3 from "./util.js";
|
|
2
2
|
const containerAttributes = {
|
|
3
3
|
Parent: 'child_features',
|
|
4
4
|
Derives_from: 'derived_features',
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
addLine(line) {
|
|
12
|
-
const defMatch = /^>\s*(\S+)\s*(.*)/.exec(line);
|
|
13
|
-
if (defMatch) {
|
|
14
|
-
this._flush();
|
|
15
|
-
this.currentSequence = { id: defMatch[1], sequence: '' };
|
|
16
|
-
if (defMatch[2]) {
|
|
17
|
-
this.currentSequence.description = defMatch[2].trim();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
else if (this.currentSequence && /\S/.test(line)) {
|
|
21
|
-
this.currentSequence.sequence += line.replaceAll(/\s/g, '');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
_flush() {
|
|
25
|
-
if (this.currentSequence) {
|
|
26
|
-
this.seqCallback(this.currentSequence);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
finish() {
|
|
30
|
-
this._flush();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
6
|
+
const featureLineRegex = /^\s*[^#\s>]/;
|
|
7
|
+
const commentOrDirectiveRegex = /^\s*(#+)(.*)/;
|
|
8
|
+
const blankLineRegex = /^\s*$/;
|
|
9
|
+
const fastaStartRegex = /^\s*>/;
|
|
10
|
+
const lineEndingRegex = /\r?\n?$/g;
|
|
33
11
|
export default class Parser {
|
|
12
|
+
featureCallback;
|
|
13
|
+
endCallback;
|
|
14
|
+
commentCallback;
|
|
15
|
+
errorCallback;
|
|
16
|
+
disableDerivesFromReferences;
|
|
17
|
+
directiveCallback;
|
|
18
|
+
bufferSize;
|
|
19
|
+
eof = false;
|
|
20
|
+
lineNumber = 0;
|
|
21
|
+
// features that we have to keep on hand for now because they
|
|
22
|
+
// might be referenced by something else
|
|
23
|
+
_underConstructionTopLevel = [];
|
|
24
|
+
// index of the above by ID
|
|
25
|
+
_underConstructionById = {};
|
|
26
|
+
_completedReferences = {};
|
|
27
|
+
// features that reference something we have not seen yet
|
|
28
|
+
// structured as:
|
|
29
|
+
// { 'some_id' : {
|
|
30
|
+
// 'Parent' : [ orphans that have a Parent attr referencing it ],
|
|
31
|
+
// 'Derives_from' : [ orphans that have a Derives_from attr referencing it ],
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
34
|
+
_underConstructionOrphans = {};
|
|
34
35
|
constructor(args) {
|
|
35
|
-
this.fastaParser = undefined;
|
|
36
|
-
// if this is true, the parser ignores the
|
|
37
|
-
// rest of the lines in the file. currently
|
|
38
|
-
// set when the file switches over to FASTA
|
|
39
|
-
this.eof = false;
|
|
40
|
-
this.lineNumber = 0;
|
|
41
|
-
// features that we have to keep on hand for now because they
|
|
42
|
-
// might be referenced by something else
|
|
43
|
-
this._underConstructionTopLevel = [];
|
|
44
|
-
// index of the above by ID
|
|
45
|
-
this._underConstructionById = {};
|
|
46
|
-
this._completedReferences = {};
|
|
47
|
-
// features that reference something we have not seen yet
|
|
48
|
-
// structured as:
|
|
49
|
-
// { 'some_id' : {
|
|
50
|
-
// 'Parent' : [ orphans that have a Parent attr referencing it ],
|
|
51
|
-
// 'Derives_from' : [ orphans that have a Derives_from attr referencing it ],
|
|
52
|
-
// }
|
|
53
|
-
// }
|
|
54
|
-
this._underConstructionOrphans = {};
|
|
55
36
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
56
37
|
const nullFunc = () => { };
|
|
57
38
|
this.featureCallback = args.featureCallback || nullFunc;
|
|
@@ -59,29 +40,22 @@ export default class Parser {
|
|
|
59
40
|
this.commentCallback = args.commentCallback || nullFunc;
|
|
60
41
|
this.errorCallback = args.errorCallback || nullFunc;
|
|
61
42
|
this.directiveCallback = args.directiveCallback || nullFunc;
|
|
62
|
-
this.sequenceCallback = args.sequenceCallback || nullFunc;
|
|
63
43
|
this.disableDerivesFromReferences =
|
|
64
44
|
args.disableDerivesFromReferences || false;
|
|
65
45
|
// number of lines to buffer
|
|
66
46
|
this.bufferSize = args.bufferSize === undefined ? Infinity : args.bufferSize;
|
|
67
47
|
}
|
|
68
48
|
addLine(line) {
|
|
69
|
-
// if we have transitioned to a fasta section, just delegate to that parser
|
|
70
|
-
if (this.fastaParser) {
|
|
71
|
-
this.fastaParser.addLine(line);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
49
|
if (this.eof) {
|
|
75
|
-
// otherwise, if we are done, ignore this line
|
|
76
50
|
return;
|
|
77
51
|
}
|
|
78
52
|
this.lineNumber += 1;
|
|
79
|
-
if (
|
|
53
|
+
if (featureLineRegex.test(line)) {
|
|
80
54
|
// feature line, most common case
|
|
81
55
|
this._bufferLine(line);
|
|
82
56
|
return;
|
|
83
57
|
}
|
|
84
|
-
const match =
|
|
58
|
+
const match = commentOrDirectiveRegex.exec(line);
|
|
85
59
|
if (match) {
|
|
86
60
|
// directive or comment
|
|
87
61
|
const [, hashsigns] = match;
|
|
@@ -96,7 +70,6 @@ export default class Parser {
|
|
|
96
70
|
if (directive.directive === 'FASTA') {
|
|
97
71
|
this._emitAllUnderConstructionFeatures();
|
|
98
72
|
this.eof = true;
|
|
99
|
-
this.fastaParser = new FASTAParser(this.sequenceCallback);
|
|
100
73
|
}
|
|
101
74
|
else {
|
|
102
75
|
this._emitItem(directive);
|
|
@@ -104,31 +77,32 @@ export default class Parser {
|
|
|
104
77
|
}
|
|
105
78
|
}
|
|
106
79
|
else {
|
|
107
|
-
|
|
108
|
-
this._emitItem({ comment: contents });
|
|
80
|
+
this._emitItem({ comment: contents.trimStart() });
|
|
109
81
|
}
|
|
110
82
|
}
|
|
111
|
-
else if (
|
|
83
|
+
else if (blankLineRegex.test(line)) {
|
|
112
84
|
// blank line, do nothing
|
|
113
85
|
}
|
|
114
|
-
else if (
|
|
115
|
-
// implicit beginning of a FASTA section
|
|
86
|
+
else if (fastaStartRegex.test(line)) {
|
|
87
|
+
// implicit beginning of a FASTA section, stop parsing
|
|
116
88
|
this._emitAllUnderConstructionFeatures();
|
|
117
89
|
this.eof = true;
|
|
118
|
-
this.fastaParser = new FASTAParser(this.sequenceCallback);
|
|
119
|
-
this.fastaParser.addLine(line);
|
|
120
90
|
}
|
|
121
91
|
else {
|
|
122
92
|
// it's a parse error
|
|
123
|
-
const errLine = line.replaceAll(
|
|
93
|
+
const errLine = line.replaceAll(lineEndingRegex, '');
|
|
124
94
|
throw new Error(`GFF3 parse error. Cannot parse '${errLine}'.`);
|
|
125
95
|
}
|
|
126
96
|
}
|
|
97
|
+
addParsedFeatureLine(featureLine) {
|
|
98
|
+
if (this.eof) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.lineNumber += 1;
|
|
102
|
+
this._bufferParsedLine(featureLine);
|
|
103
|
+
}
|
|
127
104
|
finish() {
|
|
128
105
|
this._emitAllUnderConstructionFeatures();
|
|
129
|
-
if (this.fastaParser) {
|
|
130
|
-
this.fastaParser.finish();
|
|
131
|
-
}
|
|
132
106
|
this.endCallback();
|
|
133
107
|
}
|
|
134
108
|
_emitItem(i) {
|
|
@@ -144,19 +118,24 @@ export default class Parser {
|
|
|
144
118
|
}
|
|
145
119
|
_enforceBufferSizeLimit(additionalItemCount = 0) {
|
|
146
120
|
const _unbufferItem = (item) => {
|
|
147
|
-
|
|
148
|
-
if (item && Array.isArray(item) && ((_b = (_a = item[0].attributes) === null || _a === void 0 ? void 0 : _a.ID) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
121
|
+
if (item && Array.isArray(item) && item[0].attributes?.ID?.[0]) {
|
|
149
122
|
const ids = item[0].attributes.ID;
|
|
150
123
|
ids.forEach(id => {
|
|
151
124
|
delete this._underConstructionById[id];
|
|
152
125
|
delete this._completedReferences[id];
|
|
153
126
|
});
|
|
154
127
|
item.forEach(i => {
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
155
129
|
if (i.child_features) {
|
|
156
|
-
i.child_features.forEach(c =>
|
|
130
|
+
i.child_features.forEach(c => {
|
|
131
|
+
_unbufferItem(c);
|
|
132
|
+
});
|
|
157
133
|
}
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
158
135
|
if (i.derived_features) {
|
|
159
|
-
i.derived_features.forEach(d =>
|
|
136
|
+
i.derived_features.forEach(d => {
|
|
137
|
+
_unbufferItem(d);
|
|
138
|
+
});
|
|
160
139
|
}
|
|
161
140
|
});
|
|
162
141
|
}
|
|
@@ -181,29 +160,24 @@ export default class Parser {
|
|
|
181
160
|
this._completedReferences = {};
|
|
182
161
|
// if we have any orphans hanging around still, this is a
|
|
183
162
|
// problem. die with a parse error
|
|
184
|
-
|
|
185
|
-
|
|
163
|
+
const orphanKeys = Object.keys(this._underConstructionOrphans);
|
|
164
|
+
if (orphanKeys.length) {
|
|
165
|
+
throw new Error(`some features reference other features that do not exist in the file (or in the same '###' scope). ${orphanKeys.join(',')}`);
|
|
186
166
|
}
|
|
187
167
|
}
|
|
188
|
-
// do the right thing with a newly-parsed feature line
|
|
189
168
|
_bufferLine(line) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// NOTE: a feature is an arrayref of one or more feature lines.
|
|
199
|
-
const ids = ((_a = featureLine.attributes) === null || _a === void 0 ? void 0 : _a.ID) || [];
|
|
200
|
-
const parents = ((_b = featureLine.attributes) === null || _b === void 0 ? void 0 : _b.Parent) || [];
|
|
169
|
+
this._bufferParsedLine(GFF3.parseFeature(line));
|
|
170
|
+
}
|
|
171
|
+
_bufferParsedLine(rawFeatureLine) {
|
|
172
|
+
const featureLine = rawFeatureLine;
|
|
173
|
+
featureLine.child_features = [];
|
|
174
|
+
featureLine.derived_features = [];
|
|
175
|
+
const ids = featureLine.attributes?.ID || [];
|
|
176
|
+
const parents = featureLine.attributes?.Parent || [];
|
|
201
177
|
const derives = this.disableDerivesFromReferences
|
|
202
178
|
? []
|
|
203
|
-
:
|
|
179
|
+
: featureLine.attributes?.Derives_from || [];
|
|
204
180
|
if (!ids.length && !parents.length && !derives.length) {
|
|
205
|
-
// if it has no IDs and does not refer to anything, we can just
|
|
206
|
-
// output it
|
|
207
181
|
this._emitItem([featureLine]);
|
|
208
182
|
return;
|
|
209
183
|
}
|
|
@@ -211,7 +185,6 @@ export default class Parser {
|
|
|
211
185
|
ids.forEach(id => {
|
|
212
186
|
const existing = this._underConstructionById[id];
|
|
213
187
|
if (existing) {
|
|
214
|
-
// another location of the same feature
|
|
215
188
|
if (existing[existing.length - 1].type !== featureLine.type) {
|
|
216
189
|
this._parseError(`multi-line feature "${id}" has inconsistent types: "${featureLine.type}", "${existing[existing.length - 1].type}"`);
|
|
217
190
|
}
|
|
@@ -219,37 +192,28 @@ export default class Parser {
|
|
|
219
192
|
feature = existing;
|
|
220
193
|
}
|
|
221
194
|
else {
|
|
222
|
-
// haven't seen it yet, so buffer it so we can attach
|
|
223
|
-
// child features to it
|
|
224
195
|
feature = [featureLine];
|
|
225
196
|
this._enforceBufferSizeLimit(1);
|
|
226
197
|
if (!parents.length && !derives.length) {
|
|
227
198
|
this._underConstructionTopLevel.push(feature);
|
|
228
199
|
}
|
|
229
200
|
this._underConstructionById[id] = feature;
|
|
230
|
-
// see if we have anything buffered that refers to it
|
|
231
201
|
this._resolveReferencesTo(feature, id);
|
|
232
202
|
}
|
|
233
203
|
});
|
|
234
|
-
|
|
235
|
-
|
|
204
|
+
this._resolveReferencesFrom(
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
206
|
+
feature || [featureLine], { Parent: parents, Derives_from: derives }, ids);
|
|
236
207
|
}
|
|
237
208
|
_resolveReferencesTo(feature, id) {
|
|
238
209
|
const references = this._underConstructionOrphans[id];
|
|
239
|
-
// references is of the form
|
|
240
|
-
// {
|
|
241
|
-
// 'Parent' : [ orphans that have a Parent attr referencing this feature ],
|
|
242
|
-
// 'Derives_from' : [ orphans that have a Derives_from attr referencing this feature ],
|
|
243
|
-
// }
|
|
244
210
|
if (!references) {
|
|
245
211
|
return;
|
|
246
212
|
}
|
|
247
|
-
|
|
213
|
+
for (const loc of feature) {
|
|
248
214
|
loc.child_features.push(...references.Parent);
|
|
249
|
-
});
|
|
250
|
-
feature.forEach(loc => {
|
|
251
215
|
loc.derived_features.push(...references.Derives_from);
|
|
252
|
-
}
|
|
216
|
+
}
|
|
253
217
|
delete this._underConstructionOrphans[id];
|
|
254
218
|
}
|
|
255
219
|
_parseError(message) {
|
|
@@ -257,61 +221,60 @@ export default class Parser {
|
|
|
257
221
|
this.errorCallback(`${this.lineNumber}: ${message}`);
|
|
258
222
|
}
|
|
259
223
|
_resolveReferencesFrom(feature, references, ids) {
|
|
260
|
-
|
|
261
|
-
function postSet(obj, slot1, slot2) {
|
|
262
|
-
let subObj = obj[slot1];
|
|
263
|
-
if (!subObj) {
|
|
264
|
-
subObj = {};
|
|
265
|
-
obj[slot1] = subObj;
|
|
266
|
-
}
|
|
267
|
-
const returnVal = subObj[slot2] || false;
|
|
268
|
-
subObj[slot2] = true;
|
|
269
|
-
return returnVal;
|
|
270
|
-
}
|
|
271
|
-
references.Parent.forEach(toId => {
|
|
224
|
+
for (const toId of references.Parent) {
|
|
272
225
|
const otherFeature = this._underConstructionById[toId];
|
|
273
226
|
if (otherFeature) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
227
|
+
let dominated = false;
|
|
228
|
+
for (const id of ids) {
|
|
229
|
+
const domKey = `Parent,${toId}`;
|
|
230
|
+
const rec = this._completedReferences[id] || (this._completedReferences[id] = {});
|
|
231
|
+
if (rec[domKey]) {
|
|
232
|
+
dominated = true;
|
|
233
|
+
}
|
|
234
|
+
rec[domKey] = true;
|
|
235
|
+
}
|
|
236
|
+
if (!dominated) {
|
|
237
|
+
for (const location of otherFeature) {
|
|
238
|
+
location.child_features.push(feature);
|
|
239
|
+
}
|
|
279
240
|
}
|
|
280
241
|
}
|
|
281
242
|
else {
|
|
282
243
|
let ref = this._underConstructionOrphans[toId];
|
|
283
244
|
if (!ref) {
|
|
284
|
-
ref = {
|
|
285
|
-
Parent: [],
|
|
286
|
-
Derives_from: [],
|
|
287
|
-
};
|
|
245
|
+
ref = { Parent: [], Derives_from: [] };
|
|
288
246
|
this._underConstructionOrphans[toId] = ref;
|
|
289
247
|
}
|
|
290
248
|
ref.Parent.push(feature);
|
|
291
249
|
}
|
|
292
|
-
}
|
|
293
|
-
references.Derives_from
|
|
250
|
+
}
|
|
251
|
+
for (const toId of references.Derives_from) {
|
|
294
252
|
const otherFeature = this._underConstructionById[toId];
|
|
295
253
|
if (otherFeature) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
254
|
+
let dominated = false;
|
|
255
|
+
for (const id of ids) {
|
|
256
|
+
const domKey = `Derives_from,${toId}`;
|
|
257
|
+
const rec = this._completedReferences[id] || (this._completedReferences[id] = {});
|
|
258
|
+
if (rec[domKey]) {
|
|
259
|
+
dominated = true;
|
|
260
|
+
}
|
|
261
|
+
rec[domKey] = true;
|
|
262
|
+
}
|
|
263
|
+
if (!dominated) {
|
|
264
|
+
for (const location of otherFeature) {
|
|
265
|
+
location.derived_features.push(feature);
|
|
266
|
+
}
|
|
301
267
|
}
|
|
302
268
|
}
|
|
303
269
|
else {
|
|
304
270
|
let ref = this._underConstructionOrphans[toId];
|
|
305
271
|
if (!ref) {
|
|
306
|
-
ref = {
|
|
307
|
-
Parent: [],
|
|
308
|
-
Derives_from: [],
|
|
309
|
-
};
|
|
272
|
+
ref = { Parent: [], Derives_from: [] };
|
|
310
273
|
this._underConstructionOrphans[toId] = ref;
|
|
311
274
|
}
|
|
312
275
|
ref.Derives_from.push(feature);
|
|
313
276
|
}
|
|
314
|
-
}
|
|
277
|
+
}
|
|
315
278
|
}
|
|
316
279
|
}
|
|
317
280
|
//# sourceMappingURL=parse.js.map
|
package/esm/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAE9B,MAAM,mBAAmB,GAAG;IAC1B,MAAM,EAAE,gBAAyB;IACjC,YAAY,EAAE,kBAA2B;CAC1C,CAAA;AAED,MAAM,OAAO,WAAW;IAMtB,YAAY,WAAkD;QAC5D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,eAAe,GAAG,SAAS,CAAA;IAClC,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAA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AAY,EAAE,CAAC;YAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;YACtD,IAAI,YAAY,EAAE,CAAC;gBACjB,IAAI,SAAS,GAAG,KAAK,CAAA;gBACrB,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;oBACrB,MAAM,MAAM,GAAG,gBAAgB,IAAI,EAAE,CAAA;oBACrC,MAAM,GAAG,GAAG,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;oBACjF,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;wBAChB,SAAS,GAAG,IAAI,CAAA;oBAClB,CAAC;oBACD,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;gBACpB,CAAC;gBACD,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE,CAAC;wBACpC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;oBACzC,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,GAAG,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAA;gBAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;oBACT,GAAG,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAA;oBACtC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;gBAC5C,CAAC;gBACD,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/esm/util.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare function parseAttributes(attrString: string): GFF3Attributes;
|
|
|
33
33
|
* @returns The parsed feature
|
|
34
34
|
*/
|
|
35
35
|
export declare function parseFeature(line: string): GFF3FeatureLine;
|
|
36
|
+
export declare function parseFieldsArray(f: (string | null | undefined)[]): GFF3FeatureLine;
|
|
36
37
|
/**
|
|
37
38
|
* Parse a GFF3 directive line.
|
|
38
39
|
*
|
package/esm/util.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
// Fast, low-level functions for parsing and formatting GFF3.
|
|
2
2
|
// JavaScript port of Robert Buels's Bio::GFF3::LowLevel Perl module.
|
|
3
|
+
const escapeRegex = /%([0-9A-Fa-f]{2})/g;
|
|
4
|
+
const directiveRegex = /^\s*##\s*(\S+)\s*(.*)/;
|
|
5
|
+
const lineEndRegex = /\r?\n$/;
|
|
6
|
+
const whitespaceRegex = /\s+/;
|
|
7
|
+
const nonDigitRegex = /\D/g;
|
|
8
|
+
// eslint-disable-next-line no-control-regex
|
|
9
|
+
const attrEscapeRegex = /[\n;\r\t=%&,\u0000-\u001f\u007f-\u00ff]/g;
|
|
10
|
+
// eslint-disable-next-line no-control-regex
|
|
11
|
+
const columnEscapeRegex = /[\n\r\t%\u0000-\u001f\u007f-\u00ff]/g;
|
|
3
12
|
/**
|
|
4
13
|
* Unescape a string value used in a GFF3 attribute.
|
|
5
14
|
*
|
|
@@ -7,7 +16,10 @@
|
|
|
7
16
|
* @returns An unescaped string value
|
|
8
17
|
*/
|
|
9
18
|
export function unescape(stringVal) {
|
|
10
|
-
|
|
19
|
+
if (!stringVal.includes('%')) {
|
|
20
|
+
return stringVal;
|
|
21
|
+
}
|
|
22
|
+
return stringVal.replaceAll(escapeRegex, (_match, seq) => String.fromCharCode(parseInt(seq, 16)));
|
|
11
23
|
}
|
|
12
24
|
function _escape(regex, s) {
|
|
13
25
|
return String(s).replace(regex, ch => {
|
|
@@ -22,7 +34,7 @@ function _escape(regex, s) {
|
|
|
22
34
|
* @returns An escaped string value
|
|
23
35
|
*/
|
|
24
36
|
export function escape(rawVal) {
|
|
25
|
-
return _escape(
|
|
37
|
+
return _escape(attrEscapeRegex, rawVal);
|
|
26
38
|
}
|
|
27
39
|
/**
|
|
28
40
|
* Escape a value for use in a GFF3 column value.
|
|
@@ -31,7 +43,7 @@ export function escape(rawVal) {
|
|
|
31
43
|
* @returns An escaped column value
|
|
32
44
|
*/
|
|
33
45
|
export function escapeColumn(rawVal) {
|
|
34
|
-
return _escape(
|
|
46
|
+
return _escape(columnEscapeRegex, rawVal);
|
|
35
47
|
}
|
|
36
48
|
/**
|
|
37
49
|
* Parse the 9th column (attributes) of a GFF3 feature line.
|
|
@@ -44,26 +56,29 @@ export function parseAttributes(attrString) {
|
|
|
44
56
|
return {};
|
|
45
57
|
}
|
|
46
58
|
const attrs = {};
|
|
47
|
-
attrString
|
|
48
|
-
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
|
|
59
|
+
let str = attrString;
|
|
60
|
+
if (str.endsWith('\n')) {
|
|
61
|
+
str = str.slice(0, str.endsWith('\r\n') ? -2 : -1);
|
|
62
|
+
}
|
|
63
|
+
for (const a of str.split(';')) {
|
|
64
|
+
const eqIdx = a.indexOf('=');
|
|
65
|
+
if (eqIdx === -1) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const value = a.slice(eqIdx + 1);
|
|
69
|
+
if (!value.length) {
|
|
70
|
+
continue;
|
|
55
71
|
}
|
|
56
|
-
|
|
57
|
-
let arec = attrs[
|
|
72
|
+
const tag = a.slice(0, eqIdx).trim();
|
|
73
|
+
let arec = attrs[tag];
|
|
58
74
|
if (!arec) {
|
|
59
75
|
arec = [];
|
|
60
|
-
attrs[
|
|
76
|
+
attrs[tag] = arec;
|
|
61
77
|
}
|
|
62
|
-
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
78
|
+
for (const s of value.split(',')) {
|
|
79
|
+
arec.push(unescape(s.trim()));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
67
82
|
return attrs;
|
|
68
83
|
}
|
|
69
84
|
/**
|
|
@@ -73,21 +88,38 @@ export function parseAttributes(attrString) {
|
|
|
73
88
|
* @returns The parsed feature
|
|
74
89
|
*/
|
|
75
90
|
export function parseFeature(line) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
return parseFieldsArray(line.split('\t'));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parse a GFF3 feature from a pre-split fields array
|
|
95
|
+
*
|
|
96
|
+
* @param f - Array of 9 GFF3 column values (use null or '.' for empty values)
|
|
97
|
+
* @returns The parsed feature
|
|
98
|
+
*/
|
|
99
|
+
function norm(a) {
|
|
100
|
+
return a === '.' || a === '' || a === undefined ? null : a;
|
|
101
|
+
}
|
|
102
|
+
export function parseFieldsArray(f) {
|
|
103
|
+
const seq_id = norm(f[0]);
|
|
104
|
+
const source = norm(f[1]);
|
|
105
|
+
const type = norm(f[2]);
|
|
106
|
+
const start = norm(f[3]);
|
|
107
|
+
const end = norm(f[4]);
|
|
108
|
+
const score = norm(f[5]);
|
|
109
|
+
const strand = norm(f[6]);
|
|
110
|
+
const phase = norm(f[7]);
|
|
111
|
+
const attrString = norm(f[8]);
|
|
112
|
+
return {
|
|
113
|
+
seq_id: seq_id ? unescape(seq_id) : null,
|
|
114
|
+
source: source ? unescape(source) : null,
|
|
115
|
+
type: type ? unescape(type) : null,
|
|
116
|
+
start: start === null ? null : parseInt(start, 10),
|
|
117
|
+
end: end === null ? null : parseInt(end, 10),
|
|
118
|
+
score: score === null ? null : parseFloat(score),
|
|
119
|
+
strand,
|
|
120
|
+
phase,
|
|
121
|
+
attributes: attrString === null ? null : parseAttributes(attrString),
|
|
89
122
|
};
|
|
90
|
-
return parsed;
|
|
91
123
|
}
|
|
92
124
|
/**
|
|
93
125
|
* Parse a GFF3 directive line.
|
|
@@ -96,8 +128,7 @@ export function parseFeature(line) {
|
|
|
96
128
|
* @returns The parsed directive
|
|
97
129
|
*/
|
|
98
130
|
export function parseDirective(line) {
|
|
99
|
-
|
|
100
|
-
const match = /^\s*##\s*(\S+)\s*(.*)/.exec(line);
|
|
131
|
+
const match = directiveRegex.exec(line);
|
|
101
132
|
if (!match) {
|
|
102
133
|
return null;
|
|
103
134
|
}
|
|
@@ -105,21 +136,21 @@ export function parseDirective(line) {
|
|
|
105
136
|
let [, , contents] = match;
|
|
106
137
|
const parsed = { directive: name };
|
|
107
138
|
if (contents.length) {
|
|
108
|
-
contents = contents.replace(
|
|
139
|
+
contents = contents.replace(lineEndRegex, '');
|
|
109
140
|
parsed.value = contents;
|
|
110
141
|
}
|
|
111
142
|
// do a little additional parsing for sequence-region and genome-build directives
|
|
112
143
|
if (name === 'sequence-region') {
|
|
113
|
-
const c = contents.split(
|
|
144
|
+
const c = contents.split(whitespaceRegex, 3);
|
|
114
145
|
return {
|
|
115
146
|
...parsed,
|
|
116
147
|
seq_id: c[0],
|
|
117
|
-
start:
|
|
118
|
-
end:
|
|
148
|
+
start: c[1]?.replaceAll(nonDigitRegex, ''),
|
|
149
|
+
end: c[2]?.replaceAll(nonDigitRegex, ''),
|
|
119
150
|
};
|
|
120
151
|
}
|
|
121
152
|
else if (name === 'genome-build') {
|
|
122
|
-
const [source, buildName] = contents.split(
|
|
153
|
+
const [source, buildName] = contents.split(whitespaceRegex, 2);
|
|
123
154
|
return {
|
|
124
155
|
...parsed,
|
|
125
156
|
source,
|
|
@@ -136,28 +167,18 @@ export function parseDirective(line) {
|
|
|
136
167
|
*/
|
|
137
168
|
export function formatAttributes(attrs) {
|
|
138
169
|
const attrOrder = [];
|
|
139
|
-
|
|
170
|
+
for (const [tag, val] of Object.entries(attrs)) {
|
|
140
171
|
if (!val) {
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
let valstring;
|
|
144
|
-
if (val.hasOwnProperty('toString')) {
|
|
145
|
-
valstring = escape(val.toString());
|
|
146
|
-
// } else if (Array.isArray(val.values)) {
|
|
147
|
-
// valstring = val.values.map(escape).join(',')
|
|
172
|
+
continue;
|
|
148
173
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
valstring = escape(val);
|
|
154
|
-
}
|
|
155
|
-
attrOrder.push(`${escape(tag)}=${valstring}`);
|
|
156
|
-
});
|
|
174
|
+
attrOrder.push(`${escape(tag)}=${val.map(escape).join(',')}`);
|
|
175
|
+
}
|
|
157
176
|
return attrOrder.length ? attrOrder.join(';') : '.';
|
|
158
177
|
}
|
|
159
178
|
function _formatSingleFeature(f, seenFeature) {
|
|
160
|
-
const attrString =
|
|
179
|
+
const attrString =
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
181
|
+
f.attributes === null || f.attributes === undefined
|
|
161
182
|
? '.'
|
|
162
183
|
: formatAttributes(f.attributes);
|
|
163
184
|
const fields = [
|
|
@@ -262,7 +283,10 @@ export function formatItem(itemOrItems) {
|
|
|
262
283
|
return formatSingleItem(itemOrItems);
|
|
263
284
|
}
|
|
264
285
|
function _isFeatureLineWithRefs(featureLine) {
|
|
265
|
-
return (
|
|
286
|
+
return (
|
|
287
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
288
|
+
featureLine.child_features !== undefined &&
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
266
290
|
featureLine.derived_features !== undefined);
|
|
267
291
|
}
|
|
268
292
|
//# sourceMappingURL=util.js.map
|